Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can testament be installed? #519

Closed
timotheecour opened this issue Jan 11, 2021 · 2 comments · Fixed by nim-lang/Nim#16767
Closed

can testament be installed? #519

timotheecour opened this issue Jan 11, 2021 · 2 comments · Fixed by nim-lang/Nim#16767

Comments

@timotheecour
Copy link
Owner

timotheecour commented Jan 11, 2021

testament currently relies on files known at CT in several places eg:

  • testament/lib/stdtest/specialpaths.nim
  • nimRoot eg:
  of "r", "run":
    # "/pathto/tests/stdlib/nre/captures.nim" -> "stdlib" + "tests/stdlib/nre/captures.nim"
    var subPath = p.key.string
    let nimRoot = currentSourcePath / "../.."
      # makes sure points to this regardless of cwd or which nim is used to compile this.
    doAssert dirExists(nimRoot/testsDir) # sanity check
    if subPath.isAbsolute: subPath = subPath.relativePath(nimRoot)
  • (EDIT) getCurrentCompilerExe

bug 1

this can cause problems if testament is installed (eg via choosenim)

according to @xflywind:

Just the testament installed has issues, if I compile testament by myself, it is fine

nim c -r testament/testament.nim r tests/errmsgs/t1154.nim ok
testament/testament.exe r tests/errmsgs/t1154.nim ok
testament r tests/errmsgs/t1154.nim
testament.nim(798, 14) dirExists(nimRoot / testsDir) [AssertionDefect]

EDIT: now shows:

Error: unhandled exception: testament.nim(798, 13) dirExists(nimRoot / testsDir) D:\a\nightlies\nightlies\nim-1.5.1\tests\ doesn't exist! [AssertionDefect]

constraints

should work in various conditions eg:

  • testament r tests/bar/tbar.nim
  • testament r /pathto/tests/bar/tbar.nim
  • nim r testament/testament.nim r tests/bar/tbar.nim
  • testament/testament --nim:/pathto/nim r tests/bar/tbar.nim
  • work with testament as a tool for user projects
    etc

solution 1

  • don't install testament and require users to compile and run it themselves

solution 2

  • use some logic analog to getPrefixDir in compiler/options.nim that infers location of prefixDir and allows overriding it at runtime.
    Not ideal if it prevents having nimRootDir, stdlibDir, testsDir, buildDir etc known at CT

solution 3

maybe simply a targetted fix for bug 1 can be made, eg by inferring the location of nimRoot or testsDir at runtime from the input file passed to testament r inputfile, eg:

testament r /pathto/tests/stdlib/nre/captures.nim
=>
"stdlib" + "tests/stdlib/nre/captures.nim"

by walking up the inputfile until we find the right directory; a question is how to do that reliably so that for eg it's not fooled by: nim r /pathto/tests/sub/tests/tbar.nim

links

@timotheecour
Copy link
Owner Author

=> nim-lang#16767

@timotheecour
Copy link
Owner Author

bug 1 fixed via nim-lang#16767, closing;
if there are further issues we can re-open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant