Skip to content

Commit

Permalink
introduce lake command to run test
Browse files Browse the repository at this point in the history
  • Loading branch information
Seasawher committed Apr 1, 2024
1 parent 2f28d34 commit 81053fe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ jobs:
echo "$HOME/.elan/bin" >> $GITHUB_PATH
- name: build
run: lake build

- name: run mdgen
run: lake exe mdgen Test/Src Test/Out
run: lake build --quiet

- name: run test
run: lean --run Test.lean
run: lake run test
6 changes: 0 additions & 6 deletions Test.lean
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/-! # how to test
1. first, run `lake exe mdgen Test/Src Test/Out`
2. run `lean --run Test.lean`
-/

def main : IO UInt32 := do
let firstActual ← IO.FS.readFile ⟨"Test/Out/First.md"
let firstExpected ← IO.FS.readFile ⟨"Test/Exp/First.md"
Expand Down
16 changes: 16 additions & 0 deletions lakefile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,19 @@ lean_lib «Mdgen» where
@[default_target]
lean_exe «mdgen» where
root := `Mdgen

def runCmd (cmd : String) (args : Array String) : ScriptM Bool := do
let out ← IO.Process.output {
cmd := cmd
args := args
}
let hasError := out.exitCode != 0
if hasError then
IO.eprint out.stderr
return hasError

-- run `lake run test`
script test do
if ← runCmd "lake" #["exe", "mdgen", "Test/Src", "Test/Out"] then return 1
if ← runCmd "lean" #["--run", "Test.lean"] then return 1
return 0

0 comments on commit 81053fe

Please sign in to comment.