diff options
Diffstat (limited to 'atlas/tester.nim')
-rw-r--r-- | atlas/tester.nim | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/atlas/tester.nim b/atlas/tester.nim new file mode 100644 index 000000000..98a640fd3 --- /dev/null +++ b/atlas/tester.nim @@ -0,0 +1,43 @@ +# Small program that runs the test cases + +import std / [strutils, os, sequtils] +from std/private/gitutils import diffFiles + +var failures = 0 + +when defined(develop): + const atlasExe = "bin" / "atlas".addFileExt(ExeExt) + if execShellCmd("nim c -o:$# atlas/atlas.nim" % [atlasExe]) != 0: + quit("FAILURE: compilation of atlas failed") +else: + const atlasExe = "atlas".addFileExt(ExeExt) + +proc exec(cmd: string) = + if execShellCmd(cmd) != 0: + quit "FAILURE: " & cmd + +proc sameDirContents(expected, given: string) = + for _, e in walkDir(expected): + let g = given / splitPath(e).tail + if fileExists(g): + if readFile(e) != readFile(g): + echo "FAILURE: files differ: ", e + echo diffFiles(e, g).output + inc failures + else: + echo "FAILURE: file does not exist: ", g + inc failures + +proc testWsConflict() = + const myproject = "atlas/tests/ws_conflict/myproject" + createDir(myproject) + exec atlasExe & " --project=" & myproject & " --showGraph --genLock use https://github.com/apkg" + sameDirContents("atlas/tests/ws_conflict/expected", myproject) + removeDir("atlas/tests/ws_conflict/apkg") + removeDir("atlas/tests/ws_conflict/bpkg") + removeDir("atlas/tests/ws_conflict/cpkg") + removeDir("atlas/tests/ws_conflict/dpkg") + removeDir(myproject) + +testWsConflict() +if failures > 0: quit($failures & " failures occurred.") |