fix: make nimble build and nimble test work out of the box

- Add bin/binDir keys so `nimble build` compiles src/nimcheck.nim into
  bin/nimcheck instead of failing with "Nothing to build" (the previous
  `task build` was dead code: nimble never dispatches a custom task that
  shares a name with a builtin command).
- Route all test tasks through thisDir()-based absolute paths so they no
  longer depend on the caller's current working directory.
- Fix test_json/test_yaml/test_toml tasks, which pointed at nonexistent
  tests/test_json.nim, tests/test_yaml.nim, tests/test_toml.nim; they now
  correctly run the real *_exhaustive.nim suites, matching the Makefile.
This commit is contained in:
retoor 2026-07-12 22:36:39 +02:00
parent 608974021d
commit df2b327a5d

View File

@ -5,51 +5,56 @@ author = "molodetz"
description = "Universal source code validation framework - validates source files across all common languages with tokenizer-based analysis, auto-detection, and JSON diagnostics."
license = "MIT"
srcDir = "src"
binDir = "bin"
bin = @["nimcheck"]
# Dependencies
requires "nim >= 2.0.0"
import std/os
# Tasks
proc runTestFile(fileName: string, extraFlags: string = "") =
let testPath = thisDir() / "tests" / fileName
exec "nim c " & extraFlags & " -r \"" & testPath & "\""
task test, "Run all tests":
exec "nim c -r tests/test_all.nim"
runTestFile("test_all.nim")
task test_nim, "Run Nim-specific tests":
exec "nim c -r tests/test_nim.nim"
runTestFile("test_nim.nim")
task test_python, "Run Python-specific tests":
exec "nim c -r tests/test_python.nim"
runTestFile("test_python.nim")
task test_bash, "Run Bash-specific tests":
exec "nim c -r tests/test_bash.nim"
runTestFile("test_bash.nim")
task test_js, "Run JavaScript-specific tests":
exec "nim c -r tests/test_javascript.nim"
runTestFile("test_javascript.nim")
task test_php, "Run PHP-specific tests":
exec "nim c -r tests/test_php.nim"
runTestFile("test_php.nim")
task test_html, "Run HTML-specific tests":
exec "nim c -r tests/test_html.nim"
runTestFile("test_html.nim")
task test_jinja, "Run Jinja-specific tests":
exec "nim c -r tests/test_jinja.nim"
runTestFile("test_jinja.nim")
task test_json, "Run JSON-specific tests":
exec "nim c -r tests/test_json.nim"
runTestFile("test_json_exhaustive.nim")
task test_yaml, "Run YAML-specific tests":
exec "nim c -r tests/test_yaml.nim"
runTestFile("test_yaml_exhaustive.nim")
task test_toml, "Run TOML-specific tests":
exec "nim c -r tests/test_toml.nim"
runTestFile("test_toml_exhaustive.nim")
task test_mixed, "Run mixed file tests":
exec "nim c -r tests/test_mixed.nim"
runTestFile("test_mixed.nim")
task debug, "Run tests in debug mode":
exec "nim c -d:nimcheckDebug -r tests/test_all.nim"
task build, "Build the library":
exec "nim c --lib src/nimcheck.nim"
runTestFile("test_all.nim", "-d:nimcheckDebug")
# End