From 1737bb9f9e3fffeceaac480f359b4d90ba07a3e1 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Sun, 2 Oct 2022 12:42:09 +0800 Subject: [PATCH 1/3] disable threads when booting the compiler (#20478) --- compiler/nim.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/nim.cfg b/compiler/nim.cfg index 853a657b39..926cb4c28f 100644 --- a/compiler/nim.cfg +++ b/compiler/nim.cfg @@ -6,6 +6,7 @@ define:booting define:nimcore define:nimPreviewFloatRoundtrip define:nimPreviewSlimSystem +threads:off #import:"$projectpath/testability" From 0769b160c5e1e3f17a87c4a50c0c8d4ba076858f Mon Sep 17 00:00:00 2001 From: Bung Date: Sun, 2 Oct 2022 12:42:41 +0800 Subject: [PATCH 2/3] less test time costs (#20479) --- tests/collections/ttables.nim | 7 ++----- tests/generics/tgeneric3.nim | 8 ++++---- tests/objects/tobject.nim | 5 ++--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/collections/ttables.nim b/tests/collections/ttables.nim index 638f4241b6..95f9418a00 100644 --- a/tests/collections/ttables.nim +++ b/tests/collections/ttables.nim @@ -177,16 +177,14 @@ block tableconstr: block ttables2: proc TestHashIntInt() = var tab = initTable[int,int]() - let n = 100_000 + let n = 10 for i in 1..n: tab[i] = i for i in 1..n: var x = tab[i] if x != i : echo "not found ", i - proc run1() = - for i in 1 .. 50: - TestHashIntInt() + TestHashIntInt() # bug #2107 @@ -198,7 +196,6 @@ block ttables2: delTab[5] = 5 - run1() echo "2" block tablesref: diff --git a/tests/generics/tgeneric3.nim b/tests/generics/tgeneric3.nim index 07ab822ae4..29a73afc68 100644 --- a/tests/generics/tgeneric3.nim +++ b/tests/generics/tgeneric3.nim @@ -1,9 +1,9 @@ discard """ output: ''' 312 -1000000 -1000000 -500000 +1000 +1000 +500 0 ''' """ @@ -445,7 +445,7 @@ proc test() = var it1 = internalFind(root, 312) echo it1.value - for i in 1..1_000_000: + for i in 1..1_000: root = internalPut(root, i, i, oldvalue) var cnt = 0 diff --git a/tests/objects/tobject.nim b/tests/objects/tobject.nim index 543a863765..207cda0bc0 100644 --- a/tests/objects/tobject.nim +++ b/tests/objects/tobject.nim @@ -1,4 +1,3 @@ -import unittest type Obj = object foo: int @@ -10,9 +9,9 @@ block: # object basic methods block: # it should convert an object to a string var obj = makeObj(1) # Should be "obj: (foo: 1)" or similar. - check($obj == "(foo: 1)") + doAssert($obj == "(foo: 1)") block: # it should test equality based on fields - check(makeObj(1) == makeObj(1)) + doAssert(makeObj(1) == makeObj(1)) # bug #10203 From 81e7811e01b22518cb5e533cf75ed5dda0873415 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Sun, 2 Oct 2022 12:44:10 +0800 Subject: [PATCH 3/3] fixes nim check with orc (#20456) * fixes nim check with orc * fixes tests * add tests * fixes tests * Update tests/arc/t20456.nim --- compiler/nim.nim | 4 ++++ tests/arc/t20456.nim | 7 +++++++ tests/errmsgs/tsigmatch.nim | 2 +- tests/misc/m20456.nims | 1 + tests/misc/t20456_2.nim | 14 ++++++++++++++ 5 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/arc/t20456.nim create mode 100644 tests/misc/m20456.nims create mode 100644 tests/misc/t20456_2.nim diff --git a/compiler/nim.nim b/compiler/nim.nim index 2a6b3bc1b7..b98a514d73 100644 --- a/compiler/nim.nim +++ b/compiler/nim.nim @@ -97,6 +97,10 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) = if not self.loadConfigsAndProcessCmdLine(cache, conf, graph): return + if conf.cmd == cmdCheck and optWasNimscript notin conf.globalOptions and + conf.backend == backendInvalid: + conf.backend = backendC + if conf.selectedGC == gcUnselected: if conf.backend in {backendC, backendCpp, backendObjc}: initOrcDefines(conf) diff --git a/tests/arc/t20456.nim b/tests/arc/t20456.nim new file mode 100644 index 0000000000..ace79255a0 --- /dev/null +++ b/tests/arc/t20456.nim @@ -0,0 +1,7 @@ +discard """ + cmd: "nim check $file" + action: "compile" +""" + +when not defined(gcOrc): + {.error: "orc".} diff --git a/tests/errmsgs/tsigmatch.nim b/tests/errmsgs/tsigmatch.nim index 8f32ef9e66..49b3559829 100644 --- a/tests/errmsgs/tsigmatch.nim +++ b/tests/errmsgs/tsigmatch.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nim check --showAllMismatches:on --hints:off $file" + cmd: "nim check --mm:refc --showAllMismatches:on --hints:off $file" nimout: ''' tsigmatch.nim(111, 4) Error: type mismatch: got but expected one of: diff --git a/tests/misc/m20456.nims b/tests/misc/m20456.nims new file mode 100644 index 0000000000..8a93131295 --- /dev/null +++ b/tests/misc/m20456.nims @@ -0,0 +1 @@ +echo 123 \ No newline at end of file diff --git a/tests/misc/t20456_2.nim b/tests/misc/t20456_2.nim new file mode 100644 index 0000000000..37e52c4522 --- /dev/null +++ b/tests/misc/t20456_2.nim @@ -0,0 +1,14 @@ +discard """ + joinable: false +""" + +import std/[osproc, os, strformat] +from stdtest/specialpaths import testsDir + +when defined(nimPreviewSlimSystem): + import std/assertions + +const + nim = getCurrentCompilerExe() + file = testsDir / "misc" / "m20456.nims" +doAssert execCmd(fmt"{nim} check {file}") == 0