Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
joneugster committed Dec 21, 2023
1 parent 4085adf commit 57b4b98
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build
run-name: Build the project
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: install elan
run: |
set -o pipefail
curl -sSfL https://github.com/leanprover/elan/releases/download/v3.0.0/elan-x86_64-unknown-linux-gnu.tar.gz | tar xz
./elan-init -y
echo "$HOME/.elan/bin" >> $GITHUB_PATH
- uses: actions/checkout@v4
- name: print lean and lake versions
run: |
lean --version
lake --version
- run: lake build
- name: verify `lake exe graph` works
run: |
lake exe graph
rm import_graph.dot
- name: run tests
id: test
run: |
find test/*.lean -exec lake env lean {} \;
57 changes: 57 additions & 0 deletions test/Imports.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import ImportGraph.Imports
import ImportGraph.RequiredModules

open Lean

def importTest : CoreM Unit := do
let x ← redundantImports
logInfo s!"{x.toArray}"

/-
info:
Found the following transitively redundant imports:
ImportGraph.RequiredModules
-/
#redundant_imports

/-
info:
import ImportGraph.Imports
-/
#minimize_imports

/-
info:
[ImportGraph.Imports]
-/
#find_home importTest


open Elab Command in
elab "#my_test" : command => do
-- functionality of `#redundant_imports`
let expected := #[`ImportGraph.RequiredModules]
let ri ← liftCoreM redundantImports
if (ri.toArray != expected) then
logError s!"Failed: `redundantImports` returned {ri.toArray} instead of {expected}"

-- functionality of `#find_home`
let expected := #[`ImportGraph.Imports]
let mi ← liftCoreM <| Lean.Name.findHome `importTest none
if (mi.toArray != expected) then
logError s!"Failed: `findHome` returned {mi.toArray} instead of {expected}"

-- functionality of `#find_home!`
let expected := #[`ImportGraph.Imports]
let mi! ← liftCoreM <| Lean.Name.findHome `importTest (← getEnv)
if (mi!.toArray != expected) then
logError s!"Failed: `findHome (!)` returned {mi!.toArray} instead of {expected}"

logInfo s!"{mi.toArray}"
pure ()

/-
info:
#[ImportGraph.RequiredModules]
-/
#my_test

0 comments on commit 57b4b98

Please sign in to comment.