-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
improve nimsuggest/tester, minor improvements to koch.nim #17879
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |
| # Every test file can have a #[!]# comment that is deleted from the input | ||
| # before 'nimsuggest' is invoked to ensure this token doesn't make a | ||
| # crucial difference for Nim's parser. | ||
| # When debugging, to run a single test, use for e.g.: | ||
| # `nim r nimsuggest/tester.nim nimsuggest/tests/tsug_accquote.nim` | ||
|
|
||
| import os, osproc, strutils, streams, re, sexp, net | ||
|
|
||
|
|
@@ -13,16 +15,16 @@ type | |
| disabled: bool | ||
|
|
||
| const | ||
| curDir = when defined(windows): "" else: "" | ||
| DummyEof = "!EOF!" | ||
|
|
||
| template tpath(): untyped = getAppDir() / "tests" | ||
| tpath = "nimsuggest/tests" | ||
| # we could also use `stdtest/specialpaths` | ||
|
|
||
| import std/compilesettings | ||
|
|
||
| proc parseTest(filename: string; epcMode=false): Test = | ||
| const cursorMarker = "#[!]#" | ||
| let nimsug = curDir & addFileExt("nimsuggest", ExeExt) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previous code was picking up the nimsuggest in PATH instead of the one in bin/nimsuggest that was just built in new behavior is more consistent with how we test other tools |
||
| let nimsug = "bin" / addFileExt("nimsuggest", ExeExt) | ||
| doAssert nimsug.fileExists, nimsug | ||
| const libpath = querySetting(libPath) | ||
| result.filename = filename | ||
| result.dest = getTempDir() / extractFilename(filename) | ||
|
|
@@ -63,7 +65,7 @@ proc parseTest(filename: string; epcMode=false): Test = | |
| elif x.startsWith(">"): | ||
| # since 'markers' here are not complete yet, we do the $substitutions | ||
| # afterwards | ||
| result.script.add((x.substr(1).replaceWord("$path", tpath()), "")) | ||
| result.script.add((x.substr(1).replaceWord("$path", tpath), "")) | ||
| elif x.len > 0: | ||
| # expected output line: | ||
| let x = x % ["file", filename, "lib", libpath] | ||
|
|
@@ -104,7 +106,7 @@ proc parseCmd(c: string): seq[string] = | |
| proc edit(tmpfile: string; x: seq[string]) = | ||
| if x.len != 3 and x.len != 4: | ||
| quit "!edit takes two or three arguments" | ||
| let f = if x.len >= 4: tpath() / x[3] else: tmpfile | ||
| let f = if x.len >= 4: tpath / x[3] else: tmpfile | ||
| try: | ||
| let content = readFile(f) | ||
| let newcontent = content.replace(x[1], x[2]) | ||
|
|
@@ -121,12 +123,12 @@ proc exec(x: seq[string]) = | |
|
|
||
| proc copy(x: seq[string]) = | ||
| if x.len != 3: quit "!copy takes two arguments" | ||
| let rel = tpath() | ||
| let rel = tpath | ||
| copyFile(rel / x[1], rel / x[2]) | ||
|
|
||
| proc del(x: seq[string]) = | ||
| if x.len != 2: quit "!del takes one argument" | ||
| removeFile(tpath() / x[1]) | ||
| removeFile(tpath / x[1]) | ||
|
|
||
| proc runCmd(cmd, dest: string): bool = | ||
| result = cmd[0] == '!' | ||
|
|
@@ -317,7 +319,7 @@ proc runTest(filename: string): int = | |
| try: | ||
| inp.writeLine("quit") | ||
| inp.flush() | ||
| except: | ||
| except IOError, OSError: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more strict; follows #17817 (comment) |
||
| # assume it's SIGPIPE, ie, the child already died | ||
| discard | ||
| close(p) | ||
|
|
@@ -334,7 +336,7 @@ proc main() = | |
| failures += runTest(xx) | ||
| failures += runEpcTest(xx) | ||
| else: | ||
| for x in walkFiles(tpath() / "t*.nim"): | ||
| for x in walkFiles(tpath / "t*.nim"): | ||
| echo "Test ", x | ||
| let xx = expandFilename x | ||
| when not defined(windows): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made no sense; and empty string should not mean cwd