diff --git a/src/nimble.nim b/src/nimble.nim index 25a54790e..1e969f237 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -1394,11 +1394,10 @@ proc develop(options: var Options) = proc test(options: Options) = ## Executes all tests starting with 't' in the ``tests`` directory. - ## Subdirectories are not walked. var pkgInfo = getPkgInfo(getCurrentDir(), options) var - files = toSeq(walkDir(getCurrentDir() / "tests")) + files = toSeq(walkDirRec(getCurrentDir() / "tests", {pcFile, pcLinkToFile}, relative = true)) tests, failures: int if files.len < 1: @@ -1408,24 +1407,23 @@ proc test(options: Options) = if not execHook(options, actionCustom, true): raise nimbleError("Pre-hook prevented further execution.") - files.sort((a, b) => cmp(a.path, b.path)) + files.sort((a, b) => cmp(a, b)) + files = files.map((a) => "tests" / a) for file in files: - let (_, name, ext) = file.path.splitFile() - if ext == ".nim" and name[0] == 't' and file.kind in {pcFile, pcLinkToFile}: + let (_, name, ext) = file.splitFile() + if ext == ".nim" and name[0] == 't': var optsCopy = options optsCopy.action = Action(typ: actionCompile) - optsCopy.action.file = file.path + optsCopy.action.file = file optsCopy.action.additionalArguments = options.action.arguments optsCopy.action.backend = pkgInfo.backend optsCopy.getCompilationFlags() = options.getCompilationFlags() # treat run flags as compile for default test task optsCopy.getCompilationFlags().add(options.action.custRunFlags) optsCopy.getCompilationFlags().add("-r") + optsCopy.getCompilationFlags().add("--out=" & ("build/" / file.changeFileExt(ExeExt))) optsCopy.getCompilationFlags().add("--path:.") - let - binFileName = file.path.changeFileExt(ExeExt) - existsBefore = fileExists(binFileName) if options.continueTestsOnFailure: inc tests @@ -1436,15 +1434,6 @@ proc test(options: Options) = else: execBackend(pkgInfo, optsCopy) - let - existsAfter = fileExists(binFileName) - canRemove = not existsBefore and existsAfter - if canRemove: - try: - removeFile(binFileName) - except OSError as exc: - display("Warning:", "Failed to delete " & binFileName & ": " & - exc.msg, Warning, MediumPriority) if failures == 0: display("Success:", "All tests passed", Success, HighPriority) diff --git a/tests/ttestcommand.nim b/tests/ttestcommand.nim index dc8dd1d9f..357f3f5a1 100644 --- a/tests/ttestcommand.nim +++ b/tests/ttestcommand.nim @@ -33,13 +33,6 @@ suite "test command": check outp.processOutput.inLines("overriden") check outp.processOutput.inLines("true") - test "certain files are ignored": - cd "testCommand/testsIgnore": - let (outp, exitCode) = execNimble("test") - check exitCode == QuitSuccess - check(not outp.processOutput.inLines("Should be ignored")) - check outp.processOutput.inLines("First test") - test "CWD is root of package": cd "testCommand/testsCWD": let (outp, exitCode) = execNimble("test")