From 686555cd347badfe6c48c4ac49afade1ef8409ad Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Tue, 16 Mar 2021 16:22:52 -0700 Subject: [PATCH] `nimble test` keeps git status clean; prevents accidental checking in of binaries etc (#786) * * try as much as possible to build test artifacts under a single dir (can be improved later) * simplify gitignore logic * fixup after rebase * fix test --- .gitignore | 26 ++++++++++++++++---------- tests/.gitignore | 37 +++++++++++++++---------------------- tests/config.nims | 4 ++++ tests/tester.nim | 4 +++- 4 files changed, 38 insertions(+), 33 deletions(-) create mode 100644 tests/config.nims diff --git a/.gitignore b/.gitignore index bac71d6a..4661d605 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ +# ignore files wo extension (posix binaries) +* +!*.* +!*/ + + # Any path *.swp *~ @@ -7,15 +13,6 @@ nimcache/ /src/babel /src/nimble -# executables from test and build -/nimble -src/nimblepkg/cli -src/nimblepkg/packageinfo -src/nimblepkg/packageparser -src/nimblepkg/reversedeps -src/nimblepkg/version -src/nimblepkg/download - # Windows executables *.exe *.dll @@ -31,4 +28,13 @@ src/nimblepkg/download *.orig # Test procedure artifacts -nimble_*.nims +/buildTests + +# executables from test and build (already gitignored but keeping for documentation) +# /nimble +# src/nimblepkg/cli +# src/nimblepkg/packageinfo +# src/nimblepkg/packageparser +# src/nimblepkg/reversedeps +# src/nimblepkg/version +# src/nimblepkg/download diff --git a/tests/.gitignore b/tests/.gitignore index 30d6bd7d..a46b1a44 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,24 +1,17 @@ -tester +# ideally this shouldn't even be needed and all generated files would go under ../buildTests/ + +# tester /nimble-test -/buildDir -/binaryPackage/v1/binaryPackage -/binaryPackage/v2/binaryPackage -/develop/dependent/src/dependent -/issue27/issue27 -/issue206/issue/issue206bin -/issue289/issue289 -/issue428/nimbleDir/ -/nimbleDir/ -/packageStructure/c/c -/packageStructure/y/y -/testCommand/testOverride/myTester -/testCommand/testsFail/tests/a -/testCommand/testsFail/tests/b -/testCommand/testsPass/tests/one -/testCommand/testsPass/tests/three -/testCommand/testsPass/tests/two -/nimscript/nimscript -/packageStructure/validBinary/y -/testCommand/testsFail/tests/t2 -/passNimFlags/passNimFlags /issue799/issue799 +/issue308515/v1/binname.out +/issue308515/v2/binname.out +/localdeps/nimbledeps/ +/multi/ +/packagea/ + + +# occurs on multiple levels +nimbleDir/ + +# generated nims files +*_*.nims diff --git a/tests/config.nims b/tests/config.nims new file mode 100644 index 00000000..6dc509fc --- /dev/null +++ b/tests/config.nims @@ -0,0 +1,4 @@ +# this also doesn't work (even in nims): --outdir:"$nimcache/buildTests" +import os +let buildDir = currentSourcePath().parentDir.parentDir / "buildTests" +switch("outdir", buildDir) diff --git a/tests/tester.nim b/tests/tester.nim index f7620b6a..ed5aefc4 100644 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -9,6 +9,7 @@ import osproc, unittest, strutils, os, sequtils, sugar, strformat let rootDir = getCurrentDir().parentDir() let nimblePath = rootDir / "src" / addFileExt("nimble", ExeExt) let installDir = rootDir / "tests" / "nimbleDir" +let buildTests = rootDir / "buildTests" const path = "../src/nimble" const stringNotFound = -1 @@ -962,8 +963,9 @@ suite "issues": cd "issue727": var (output, exitCode) = execNimbleYes("c", "src/abc") check exitCode == QuitSuccess - check fileExists("src/abc".addFileExt(ExeExt)) + check fileExists(buildTests / "abc".addFileExt(ExeExt)) check not fileExists("src/def".addFileExt(ExeExt)) + check not fileExists(buildTests / "def".addFileExt(ExeExt)) (output, exitCode) = execNimbleYes("uninstall", "-i", "timezones") check exitCode == QuitSuccess