From 9c3596d9de809a5933fd777cec1183c2cdf521ec Mon Sep 17 00:00:00 2001 From: Jordan Hrycaj Date: Fri, 8 Jul 2022 10:34:21 +0100 Subject: [PATCH] Migrate to `unittest2` (#125) * Migrate to `unittest2` why: Global symbol overflow when running NIM 1.2 on Github ci suggests that unit tests run sort of separately. The replacement library `unittest2` provides that. * Build ci dependencies --- .github/workflows/ci.yml | 2 ++ stew.nimble | 3 ++- tests/ranges/tbitranges.nim | 2 +- tests/ranges/tstackarrays.nim | 2 +- tests/ranges/ttypedranges.nim | 2 +- tests/test_arrayops.nim | 2 +- tests/test_assign2.nim | 2 +- tests/test_base10.nim | 2 +- tests/test_base32.nim | 2 +- tests/test_base58.nim | 2 +- tests/test_base64.nim | 2 +- tests/test_bitops2.nim | 2 +- tests/test_bitseqs.nim | 2 +- tests/test_byteutils.nim | 2 +- tests/test_ctops.nim | 2 +- tests/test_endians2.nim | 2 +- tests/test_interval_set.nim | 2 +- tests/test_io2.nim | 2 +- tests/test_keyed_queue.nim | 3 ++- tests/test_leb128.nim | 2 +- tests/test_macros.nim | 2 +- tests/test_objects.nim | 2 +- tests/test_ptrops.nim | 2 +- tests/test_sequtils2.nim | 2 +- tests/test_sets.nim | 2 +- tests/test_sorted_set.nim | 2 +- tests/test_templateutils.nim | 2 +- tests/test_varints.nim | 2 +- tests/test_winacl.nim | 2 +- 29 files changed, 32 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0172dbc..a935410 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -155,6 +155,7 @@ jobs: fi nim --version nimble --version + nimble install -y --depsOnly env TEST_LANG=c nimble test env TEST_LANG=cpp nimble test @@ -173,5 +174,6 @@ jobs: - name: Test using VCC if: runner.os == 'Windows' run: | + nimble install -y --depsOnly env TEST_LANG=c nimble testvcc env TEST_LANG=cpp nimble testvcc diff --git a/stew.nimble b/stew.nimble index d2fdbe2..1a52c25 100644 --- a/stew.nimble +++ b/stew.nimble @@ -7,7 +7,8 @@ description = "Backports, standard library candidates and small utilities that license = "Apache License 2.0" skipDirs = @["tests"] -requires "nim >= 1.2.0" +requires "nim >= 1.2.0", + "unittest2" ### Helper functions proc test(args, path: string) = diff --git a/tests/ranges/tbitranges.nim b/tests/ranges/tbitranges.nim index 3589b61..38116b5 100644 --- a/tests/ranges/tbitranges.nim +++ b/tests/ranges/tbitranges.nim @@ -1,5 +1,5 @@ import - random, unittest, + random, unittest2, ../../stew/ranges/bitranges, ../../stew/bitseqs proc randomBytes(n: int): seq[byte] = diff --git a/tests/ranges/tstackarrays.nim b/tests/ranges/tstackarrays.nim index 45c8966..4132b80 100644 --- a/tests/ranges/tstackarrays.nim +++ b/tests/ranges/tstackarrays.nim @@ -1,5 +1,5 @@ import - unittest, math, + unittest2, math, ../../stew/ptrops, ../../stew/ranges/[stackarrays] diff --git a/tests/ranges/ttypedranges.nim b/tests/ranges/ttypedranges.nim index d99c0b3..8877153 100644 --- a/tests/ranges/ttypedranges.nim +++ b/tests/ranges/ttypedranges.nim @@ -1,5 +1,5 @@ import - unittest, sets, + unittest2, sets, ../../stew/ranges/[typedranges, ptr_arith] suite "Typed ranges": diff --git a/tests/test_arrayops.nim b/tests/test_arrayops.nim index ccc8f2f..f1d7dc5 100644 --- a/tests/test_arrayops.nim +++ b/tests/test_arrayops.nim @@ -10,7 +10,7 @@ {.used.} import - std/unittest, + unittest2, ../stew/arrayops suite "arrayops": diff --git a/tests/test_assign2.nim b/tests/test_assign2.nim index f5ebe26..1defc90 100644 --- a/tests/test_assign2.nim +++ b/tests/test_assign2.nim @@ -1,5 +1,5 @@ import - std/unittest, + unittest2, ../stew/assign2 suite "assign2": diff --git a/tests/test_base10.nim b/tests/test_base10.nim index 81a3ba2..2593b82 100644 --- a/tests/test_base10.nim +++ b/tests/test_base10.nim @@ -1,4 +1,4 @@ -import unittest +import unittest2 import ../stew/base10 when defined(nimHasUsed): {.used.} diff --git a/tests/test_base32.nim b/tests/test_base32.nim index 7d34dfd..3621665 100644 --- a/tests/test_base32.nim +++ b/tests/test_base32.nim @@ -1,4 +1,4 @@ -import unittest +import unittest2 import ../stew/base32 when defined(nimHasUsed): {.used.} diff --git a/tests/test_base58.nim b/tests/test_base58.nim index 8309cb3..ab0fbe3 100644 --- a/tests/test_base58.nim +++ b/tests/test_base58.nim @@ -1,4 +1,4 @@ -import unittest +import unittest2 import ../stew/base58 when defined(nimHasUsed): {.used.} diff --git a/tests/test_base64.nim b/tests/test_base64.nim index 34d37c2..21e9a44 100644 --- a/tests/test_base64.nim +++ b/tests/test_base64.nim @@ -1,4 +1,4 @@ -import unittest +import unittest2 import ../stew/[base64, byteutils] when defined(nimHasUsed): {.used.} diff --git a/tests/test_bitops2.nim b/tests/test_bitops2.nim index 1f81217..593760c 100644 --- a/tests/test_bitops2.nim +++ b/tests/test_bitops2.nim @@ -1,4 +1,4 @@ -import unittest +import unittest2 import ../stew/bitops2 diff --git a/tests/test_bitseqs.nim b/tests/test_bitseqs.nim index bbc06b9..1accfdb 100644 --- a/tests/test_bitseqs.nim +++ b/tests/test_bitseqs.nim @@ -1,5 +1,5 @@ import - unittest, strformat, + unittest2, strformat, ../stew/[bitseqs] suite "Bit fields": diff --git a/tests/test_byteutils.nim b/tests/test_byteutils.nim index c1a6f7c..bdfe750 100644 --- a/tests/test_byteutils.nim +++ b/tests/test_byteutils.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - std/unittest, + unittest2, ../stew/byteutils proc compilationTest {.exportc: "compilationTest".} = diff --git a/tests/test_ctops.nim b/tests/test_ctops.nim index f44d746..854fb00 100644 --- a/tests/test_ctops.nim +++ b/tests/test_ctops.nim @@ -1,4 +1,4 @@ -import unittest +import unittest2 import ../stew/ctops suite "Constant-time operations test suite": diff --git a/tests/test_endians2.nim b/tests/test_endians2.nim index 5971f30..8546835 100644 --- a/tests/test_endians2.nim +++ b/tests/test_endians2.nim @@ -1,4 +1,4 @@ -import unittest +import unittest2 import ../stew/endians2 diff --git a/tests/test_interval_set.nim b/tests/test_interval_set.nim index 726b963..5b363df 100644 --- a/tests/test_interval_set.nim +++ b/tests/test_interval_set.nim @@ -10,7 +10,7 @@ # distributed except according to those terms. import - std/unittest, + unittest2, ../stew/interval_set const diff --git a/tests/test_io2.nim b/tests/test_io2.nim index c943fc7..96b8ca2 100644 --- a/tests/test_io2.nim +++ b/tests/test_io2.nim @@ -1,4 +1,4 @@ -import unittest +import unittest2 import ../stew/io2 suite "OS Input/Output procedures test suite": diff --git a/tests/test_keyed_queue.nim b/tests/test_keyed_queue.nim index f7cb974..ad537f8 100644 --- a/tests/test_keyed_queue.nim +++ b/tests/test_keyed_queue.nim @@ -9,7 +9,8 @@ # according to those terms. import - std/[algorithm, sequtils, strformat, strutils, tables, unittest], + std/[algorithm, sequtils, strformat, strutils, tables], + unittest2, ../stew/keyed_queue, ../stew/keyed_queue/kq_debug diff --git a/tests/test_leb128.nim b/tests/test_leb128.nim index 0f7d11a..0fe569f 100644 --- a/tests/test_leb128.nim +++ b/tests/test_leb128.nim @@ -1,5 +1,5 @@ import - unittest, random, + unittest2, random, ../stew/[byteutils, leb128, results] const edgeValues = { diff --git a/tests/test_macros.nim b/tests/test_macros.nim index b7d2c88..e79a4e6 100644 --- a/tests/test_macros.nim +++ b/tests/test_macros.nim @@ -1,5 +1,5 @@ import - unittest, + unittest2, ../stew/shims/macros diff --git a/tests/test_objects.nim b/tests/test_objects.nim index 78386ee..a043ea7 100644 --- a/tests/test_objects.nim +++ b/tests/test_objects.nim @@ -1,5 +1,5 @@ import - unittest, typetraits, + unittest2, typetraits, ../stew/objects when defined(nimHasUsed): diff --git a/tests/test_ptrops.nim b/tests/test_ptrops.nim index f78da61..185bb86 100644 --- a/tests/test_ptrops.nim +++ b/tests/test_ptrops.nim @@ -7,7 +7,7 @@ # # at your option. This file may not be copied, modified, or distributed except according to those terms. -import unittest +import unittest2 import ../stew/ptrops diff --git a/tests/test_sequtils2.nim b/tests/test_sequtils2.nim index 3c52f10..d6066c2 100644 --- a/tests/test_sequtils2.nim +++ b/tests/test_sequtils2.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - std/unittest, + unittest2, ../stew/sequtils2 suite "sequtils2": diff --git a/tests/test_sets.nim b/tests/test_sets.nim index 5ee6735..bd0b8c0 100644 --- a/tests/test_sets.nim +++ b/tests/test_sets.nim @@ -1,5 +1,5 @@ import - unittest, + unittest2, ../stew/shims/sets suite "shims/sets": diff --git a/tests/test_sorted_set.nim b/tests/test_sorted_set.nim index 7583f67..9fb3478 100644 --- a/tests/test_sorted_set.nim +++ b/tests/test_sorted_set.nim @@ -11,7 +11,7 @@ import std/[algorithm, sequtils, strformat, tables], ../stew/sorted_set, - unittest + unittest2 const keyList = [ diff --git a/tests/test_templateutils.nim b/tests/test_templateutils.nim index b597739..67ce117 100644 --- a/tests/test_templateutils.nim +++ b/tests/test_templateutils.nim @@ -1,5 +1,5 @@ import - unittest, + unittest2, ../stew/templateutils var computations = newSeq[string]() diff --git a/tests/test_varints.nim b/tests/test_varints.nim index fd4b0ab..d5d195e 100644 --- a/tests/test_varints.nim +++ b/tests/test_varints.nim @@ -1,5 +1,5 @@ import - unittest, random, + unittest2, random, ../stew/[varints, byteutils] const edgeValues = { diff --git a/tests/test_winacl.nim b/tests/test_winacl.nim index a86852c..ae8c5ba 100644 --- a/tests/test_winacl.nim +++ b/tests/test_winacl.nim @@ -1,4 +1,4 @@ -import std/unittest +import unittest2 import ../stew/io2 when defined(windows):