From c302619d1bcc6c5b3711d4651dd3208c5b5e8f64 Mon Sep 17 00:00:00 2001 From: JackieWeiss <137733474+JackieWeiss@users.noreply.github.com> Date: Sat, 20 Jan 2024 17:59:30 +0000 Subject: [PATCH] tests: run more tests with all targets by default (#1118) Summary ======= Enabled all test targets for some tests, fixed tests where necessary. Better test coverage for JS and VM. Details ======= - Reordered the target category strings to be in alphabetical order to make later adjustments easier. - The `targets` key is removed for all tests except one to disable a target where the target doesn't make sense. - `write(stdout, ...)` is replaced with `echo ...` to support the JS and VM targets. - Some `static: ` blocks have been removed and replaced with the VM target where not specific to compile-time execution. - Tests that fail but should work are marked as `knownIssue`. part of https://github.com/nim-works/nimskull/issues/1075 --- testament/testament.nim | 3 ++- tests/align/talign.nim | 3 ++- tests/arithm/tarithm.nim | 9 +++++---- tests/arithm/tashr.nim | 20 -------------------- tests/arithm/tdiv.nim | 2 -- tests/assert/tassert.nim | 10 ++++++---- tests/assert/tassert_c.nim | 11 ++++++++--- tests/assert/tunittests.nim | 1 + tests/assign/tassign.nim | 8 ++++---- tests/assign/tcall_with_rvo.nim | 1 - tests/assign/tin_place_construction.nim | 3 +-- tests/assign/tobject_assign.nim | 3 +++ tests/assign/toverload_asgn2.nim | 2 +- 13 files changed, 33 insertions(+), 43 deletions(-) diff --git a/testament/testament.nim b/testament/testament.nim index 4a0a0e23890..ee7a0f770a4 100644 --- a/testament/testament.nim +++ b/testament/testament.nim @@ -1110,7 +1110,8 @@ func nativeTarget(): TTarget {.inline.} = func defaultTargets(category: Category): set[TTarget] = const standardTargets = {nativeTarget()} case category.string - of "lang", "lang_callable", "exception": + of "alias", "align", "ambsym", "arithm", "assert", "assign", "exception", + "lang", "lang_callable": {targetC, targetJs, targetVM} of "arc", "avr", "destructor", "distros", "dll", "gc", "osproc", "parallel", "realtimeGC", "threads", "views", "valgrind": diff --git a/tests/align/talign.nim b/tests/align/talign.nim index a079bdb4641..fbc4b674c47 100644 --- a/tests/align/talign.nim +++ b/tests/align/talign.nim @@ -1,6 +1,5 @@ discard """ ccodeCheck: "\\i @'NIM_ALIGN(128) NI mylocal1' .*" -targets: "c" labels: "pragma alignment generic" description: ''' . First one is is for Azure. The keyword ``alignof`` only exists in ``c++11`` @@ -9,6 +8,8 @@ description: ''' . From https://github.com/nim-lang/Nim/issues/13122 {.align.} pragma is not applied if there is a generic field ''' +targets: "!js" +knownIssue.vm: "VM does not support casting a ptr to a uint" """ import globalalignas diff --git a/tests/arithm/tarithm.nim b/tests/arithm/tarithm.nim index 25d0e655b68..1e7021b35b6 100644 --- a/tests/arithm/tarithm.nim +++ b/tests/arithm/tarithm.nim @@ -21,6 +21,11 @@ description: ''' . It is expected that the order of operands on these operators should not affect the operation. ''' +knownIssue.js: ''' + The JavaScript backend generates non BigInteger integer literals for these + calculations resulting in a rounding error for integers over 2^53-1 due + to JavaScript using floating point numbers internally. +''' """ import typetraits @@ -127,8 +132,6 @@ block tshr: doAssert( (VI8 shr 1) == -4, "Actual: " & $(VI8 shr 1)) T() - static: - T() block tUnsignedOps: proc testUnsignedOps(): bool = @@ -145,8 +148,6 @@ block tUnsignedOps: result = true doAssert testUnsignedOps() - static: - doAssert testUnsignedOps() block issue_5216_bitwise_and: doAssert (name typeof((0x0A'i8 and 0x7F'i32) shl 7'i32)) == "int32" diff --git a/tests/arithm/tashr.nim b/tests/arithm/tashr.nim index 74ae771803b..78ce5830fbe 100644 --- a/tests/arithm/tashr.nim +++ b/tests/arithm/tashr.nim @@ -1,5 +1,4 @@ discard """ - targets: "c js" labels: "arithmetic bitwise shift int" description: ''' . From https://github.com/nim-lang/Nim/issues/6255 @@ -33,22 +32,3 @@ block semfold_test: doAssert ashr(-123'i32, 1) == -62 doAssert ashr(-123'i64, 1) == -62 doAssert ashr(-123 , 1) == -62 - -static: # VM test - doAssert ashr(-123'i8 , 1) == -62 - doAssert ashr(-123'i16, 1) == -62 - doAssert ashr(-123'i32, 1) == -62 - doAssert ashr(-123'i64, 1) == -62 - doAssert ashr(-123 , 1) == -62 - - var y1 = -123'i8 - var y2 = -123'i16 - var y3 = -123'i32 - var y4 = -123'i64 - var y5 = -123 - - doAssert ashr(y1, 1) == -62 - doAssert ashr(y2, 1) == -62 - doAssert ashr(y3, 1) == -62 - doAssert ashr(y4, 1) == -62 - doAssert ashr(y5, 1) == -62 diff --git a/tests/arithm/tdiv.nim b/tests/arithm/tdiv.nim index 0f382dbe57b..e198eb579c3 100644 --- a/tests/arithm/tdiv.nim +++ b/tests/arithm/tdiv.nim @@ -1,5 +1,4 @@ discard """ - targets: "c js" labels: "js arithmetic int" description: ''' . Fix div uint64 without truncation for JS. @@ -18,6 +17,5 @@ block divUint64: doAssert z == 269113 doAssert a == 112130 - static: divTest() divTest() diff --git a/tests/assert/tassert.nim b/tests/assert/tassert.nim index a14fec317be..533cd1f59af 100644 --- a/tests/assert/tassert.nim +++ b/tests/assert/tassert.nim @@ -1,5 +1,7 @@ discard """ - outputsub: "assertion failure!this shall be always written" + outputsub: '''assertion failure! +this shall be always written +''' exitcode: "1" """ # test assert and exception handling @@ -11,10 +13,10 @@ proc callC() = callA() try: callC() except AssertionDefect: - write(stdout, "assertion failure!") + echo "assertion failure!" except: - write(stdout, "unknown exception!") + echo "unknown exception!" finally: - system.write(stdout, "this shall be always written") + echo "this shall be always written" assert(false) #OUT assertion failure!this shall be always written diff --git a/tests/assert/tassert_c.nim b/tests/assert/tassert_c.nim index 5c8f529adf4..2570b7de8b5 100644 --- a/tests/assert/tassert_c.nim +++ b/tests/assert/tassert_c.nim @@ -1,11 +1,16 @@ discard """ - cmd: "nim $target $options --excessiveStackTrace:off $file" + matrix: "--excessiveStackTrace:off" output: '''true''' + knownIssue.js vm:''' + JavaScript produces a different stacktrace output message than the C + target. + VM does not support 'getStackTrace' on an Exception. + ''' """ const expected = """ -tassert_c.nim(35) tassert_c -tassert_c.nim(34) foo +tassert_c.nim(40) tassert_c +tassert_c.nim(39) foo assertions.nim(*) failedAssertImpl assertions.nim(*) raiseAssert fatal.nim(*) sysFatal""" diff --git a/tests/assert/tunittests.nim b/tests/assert/tunittests.nim index 5775740c16d..b43eeb36511 100644 --- a/tests/assert/tunittests.nim +++ b/tests/assert/tunittests.nim @@ -1,5 +1,6 @@ discard """ output: "" +knownIssue.vm: "VM does not support 'copyMem'" """ import utemplates import uclosures diff --git a/tests/assign/tassign.nim b/tests/assign/tassign.nim index 60aebc78d60..c21d105dcab 100644 --- a/tests/assign/tassign.nim +++ b/tests/assign/tassign.nim @@ -5,7 +5,8 @@ TEMP=C:\Programs\xyz\bin 8 5 0 0 pre test a:test b:1 c:2 haha:3 assignment test a:test b:1 c:2 haha:3 -abc123 +abc +123 ''' """ @@ -72,7 +73,7 @@ block tcopy: p = find(example, "=") a = substr(example, 0, p-1) b = substr(example, p+1) - writeLine(stdout, a & '=' & b) + echo a & '=' & b main() @@ -212,8 +213,7 @@ when false: block tgeneric_assign_varargs: template fatal(msgs: varargs[string]) = for msg in msgs: - stdout.write(msg) - stdout.write('\n') + echo msg fatal "abc", "123" diff --git a/tests/assign/tcall_with_rvo.nim b/tests/assign/tcall_with_rvo.nim index e9d60dd9b84..275d585b0d3 100644 --- a/tests/assign/tcall_with_rvo.nim +++ b/tests/assign/tcall_with_rvo.nim @@ -1,5 +1,4 @@ discard """ - targets: "c js vm" description: ''' Ensure that the return-value optimization (=RVO) is disabled where it would affect observable semantics diff --git a/tests/assign/tin_place_construction.nim b/tests/assign/tin_place_construction.nim index 5457a39184a..a1bfaea1feb 100644 --- a/tests/assign/tin_place_construction.nim +++ b/tests/assign/tin_place_construction.nim @@ -1,5 +1,4 @@ discard """ - targets: "c js vm" description: ''' Ensure that the in-place aggregate construction optimization doesn't affect observable semantics @@ -90,4 +89,4 @@ block object_callee: var obj = Obj(a: proc (): int = 1) # if in-place construction is used, a nil-access defect will occur obj = Obj(a: nil, b: obj.a()) - doAssert obj == Obj(a: nil, b: 1) \ No newline at end of file + doAssert obj == Obj(a: nil, b: 1) diff --git a/tests/assign/tobject_assign.nim b/tests/assign/tobject_assign.nim index 7ed9ce90812..c02e9fb82c8 100644 --- a/tests/assign/tobject_assign.nim +++ b/tests/assign/tobject_assign.nim @@ -3,6 +3,9 @@ discard """ Regression test for assigning to an uninitialized `seq` slot that has a type header ''' + knownIssue.vm: ''' + 'localtime' is not yet supported with the VM backend + ''' """ # bug https://github.com/nim-lang/nim/issues/16706 diff --git a/tests/assign/toverload_asgn2.nim b/tests/assign/toverload_asgn2.nim index 50539c2d9dc..2af9d858b99 100644 --- a/tests/assign/toverload_asgn2.nim +++ b/tests/assign/toverload_asgn2.nim @@ -1,7 +1,7 @@ discard """ output: '''i value 88 2aa''' - knownIssue: "possible issue where result is not treated as var Concrete in passAround" + knownIssue: "possible issue where result is not treated as var Concrete in passAround" """ import moverload_asgn2