From 563f9d734f05419e0b4b4f9775b2f4ef6300f586 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Wed, 29 Aug 2018 03:51:07 -0700 Subject: [PATCH] add nim c -r nimsuggest/tester to travis --- .travis.yml | 2 +- nimsuggest/tester.nim | 20 ++++++++++++++++++-- nimsuggest/tests/tchk1.nim | 1 + nimsuggest/tests/tdot4.nim | 1 + nimsuggest/tests/tinclude.nim | 1 + nimsuggest/tests/tstrutils.nim | 1 + nimsuggest/tests/tsug_regression.nim | 1 + nimsuggest/tests/ttype_decl.nim | 1 + nimsuggest/tests/twithin_macro.nim | 1 + nimsuggest/tests/twithin_macro_prefix.nim | 1 + 10 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b07de1df1f0db..0f74c56acf592 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,4 +50,4 @@ script: - ./koch web - ./koch csource - ./koch nimsuggest -# - nim c -r nimsuggest/tester + - nim c -r nimsuggest/tester diff --git a/nimsuggest/tester.nim b/nimsuggest/tester.nim index b962a9f83f2c7..63095d4901256 100644 --- a/nimsuggest/tester.nim +++ b/nimsuggest/tester.nim @@ -7,9 +7,10 @@ import os, osproc, strutils, streams, re, sexp, net type Test = object - cmd, dest: string + filename, cmd, dest: string startup: seq[string] script: seq[(string, string)] + disabled: bool const curDir = when defined(windows): "" else: "" @@ -21,6 +22,7 @@ proc parseTest(filename: string; epcMode=false): Test = const cursorMarker = "#[!]#" let nimsug = curDir & addFileExt("nimsuggest", ExeExt) let libpath = findExe("nim").splitFile().dir /../ "lib" + result.filename = filename result.dest = getTempDir() / extractFilename(filename) result.cmd = nimsug & " --tester " & result.dest result.script = @[] @@ -42,7 +44,14 @@ proc parseTest(filename: string; epcMode=false): Test = if x.contains("""""""""): inc specSection elif specSection == 1: - if x.startsWith("$nimsuggest"): + if x.startsWith("disabled:"): + if x.startsWith("disabled:true"): + result.disabled = true + else: + # be strict about format + doAssert x.startsWith("disabled:false") + result.disabled = false + elif x.startsWith("$nimsuggest"): result.cmd = x % ["nimsuggest", nimsug, "file", filename, "lib", libpath] elif x.startsWith("!"): if result.cmd.len == 0: @@ -223,8 +232,14 @@ proc doReport(filename, answer, resp: string; report: var string) = report.add "\n Expected: " & resp report.add "\n But got: " & answer +proc skipDisabledTest(test: Test): bool = + if test.disabled: + echo "disabled: " & test.filename + result = test.disabled + proc runEpcTest(filename: string): int = let s = parseTest(filename, true) + if s.skipDisabledTest: return 0 for cmd in s.startup: if not runCmd(cmd, s.dest): quit "invalid command: " & cmd @@ -267,6 +282,7 @@ proc runEpcTest(filename: string): int = proc runTest(filename: string): int = let s = parseTest filename + if s.skipDisabledTest: return 0 for cmd in s.startup: if not runCmd(cmd, s.dest): quit "invalid command: " & cmd diff --git a/nimsuggest/tests/tchk1.nim b/nimsuggest/tests/tchk1.nim index 7b0b5d5b4edff..2b60ed09451d8 100644 --- a/nimsuggest/tests/tchk1.nim +++ b/nimsuggest/tests/tchk1.nim @@ -15,6 +15,7 @@ proc main = #[!]# discard """ +disabled:true $nimsuggest --tester $file >chk $1 chk;;skUnknown;;;;Hint;;???;;-1;;-1;;"tchk1 [Processing]";;0 diff --git a/nimsuggest/tests/tdot4.nim b/nimsuggest/tests/tdot4.nim index 8510162acb085..762534310f98e 100644 --- a/nimsuggest/tests/tdot4.nim +++ b/nimsuggest/tests/tdot4.nim @@ -1,4 +1,5 @@ discard """ +disabled:true $nimsuggest --tester --maxresults:2 $file >sug $1 sug;;skProc;;tdot4.main;;proc (inp: string): string;;$file;;10;;5;;"";;100;;None diff --git a/nimsuggest/tests/tinclude.nim b/nimsuggest/tests/tinclude.nim index 0616b7164d703..0fda43911c1ce 100644 --- a/nimsuggest/tests/tinclude.nim +++ b/nimsuggest/tests/tinclude.nim @@ -1,4 +1,5 @@ discard """ +disabled:true $nimsuggest --tester compiler/nim.nim >def compiler/semexprs.nim:25:50 def;;skType;;ast.PSym;;PSym;;*ast.nim;;707;;2;;"";;100 diff --git a/nimsuggest/tests/tstrutils.nim b/nimsuggest/tests/tstrutils.nim index ce3e29a1552e4..9462c3d99e825 100644 --- a/nimsuggest/tests/tstrutils.nim +++ b/nimsuggest/tests/tstrutils.nim @@ -1,4 +1,5 @@ discard """ +disabled:true $nimsuggest --tester lib/pure/strutils.nim >def lib/pure/strutils.nim:2529:6 def;;skTemplate;;system.doAssert;;proc (cond: bool, msg: string): typed;;*/lib/system.nim;;*;;9;;"same as `assert` but is always turned on and not affected by the\x0A``--assertions`` command line switch.";;100 diff --git a/nimsuggest/tests/tsug_regression.nim b/nimsuggest/tests/tsug_regression.nim index ce66aafb21357..1b23da80607bd 100644 --- a/nimsuggest/tests/tsug_regression.nim +++ b/nimsuggest/tests/tsug_regression.nim @@ -17,6 +17,7 @@ proc main = map0.#[!]# discard """ +disabled:true $nimsuggest --tester $file >sug $1 sug;;skProc;;tables.getOrDefault;;proc (t: Table[getOrDefault.A, getOrDefault.B], key: A): B;;$lib/pure/collections/tables.nim;;178;;5;;"";;100;;None diff --git a/nimsuggest/tests/ttype_decl.nim b/nimsuggest/tests/ttype_decl.nim index 846eb7b1b60ae..e66d39a1c47d1 100644 --- a/nimsuggest/tests/ttype_decl.nim +++ b/nimsuggest/tests/ttype_decl.nim @@ -1,4 +1,5 @@ discard """ +disabled:true $nimsuggest --tester --maxresults:3 $file >sug $1 sug;;skType;;ttype_decl.Other;;Other;;$file;;10;;2;;"";;0;;None diff --git a/nimsuggest/tests/twithin_macro.nim b/nimsuggest/tests/twithin_macro.nim index e0df03542953b..9c36ffd0f1226 100644 --- a/nimsuggest/tests/twithin_macro.nim +++ b/nimsuggest/tests/twithin_macro.nim @@ -202,6 +202,7 @@ echo r.age_human_yrs() echo r discard """ +disabled:true $nimsuggest --tester $file >sug $1 sug;;skField;;age;;int;;$file;;167;;6;;"";;100;;None diff --git a/nimsuggest/tests/twithin_macro_prefix.nim b/nimsuggest/tests/twithin_macro_prefix.nim index 86e406c5dff3b..1402b762ae25c 100644 --- a/nimsuggest/tests/twithin_macro_prefix.nim +++ b/nimsuggest/tests/twithin_macro_prefix.nim @@ -202,6 +202,7 @@ echo r.age_human_yrs() echo r discard """ +disabled:true $nimsuggest --tester $file >sug $1 sug;;skField;;age;;int;;$file;;167;;6;;"";;100;;Prefix