From 4ef25a2d036da25c8e568b0bba426cc591fe7f19 Mon Sep 17 00:00:00 2001 From: jangko Date: Tue, 2 Aug 2022 19:45:12 +0700 Subject: [PATCH] using multiple nim version in CI --- .github/workflows/ci.yml | 7 +++++-- graphql.nimble | 12 +++++++++++- graphql/private/utf.nim | 18 +++++++++--------- graphql/test_common.nim | 3 ++- tests/test_httpserver.nim | 6 ++++-- tests/test_parser.nim | 3 ++- tests/test_schemaintros.nim | 3 ++- tests/test_validation.nim | 3 ++- 8 files changed, 37 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e83a10c..0707e9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ jobs: max-parallel: 20 matrix: test_lang: [c] + branch: [version-1-2, version-1-4, version-1-6, devel] target: - os: linux cpu: amd64 @@ -30,7 +31,7 @@ jobs: os: windows builder: windows-2019 - name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.test_lang }}' + name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.test_lang }}-(Nim ${{ matrix.branch }})' runs-on: ${{ matrix.builder }} steps: - name: Checkout nim-graphql @@ -143,7 +144,9 @@ jobs: else MAKE_CMD="make" fi - env MAKE="$MAKE_CMD -j2" ARCH_OVERRIDE=$PLATFORM CC=gcc bash build_nim.sh nim csources dist/nimble NimBinaries + env MAKE="$MAKE_CMD -j2" ARCH_OVERRIDE=$PLATFORM NIM_COMMIT=${{ matrix.branch }} \ + QUICK_AND_DIRTY_COMPILER=1 QUICK_AND_DIRTY_NIMBLE=1 CC=gcc \ + bash build_nim.sh nim csources dist/nimble NimBinaries echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH - name: Run nim-graphql tests diff --git a/graphql.nimble b/graphql.nimble index 9472a5a..b41b243 100644 --- a/graphql.nimble +++ b/graphql.nimble @@ -25,6 +25,15 @@ requires "nim >= 1.2.0", "https://github.com/status-im/nim-unittest2" proc test(env, path: string, shouldRun = true) = + # nnkArglist was changed to nnkArgList, so can't always use --styleCheck:error + # https://github.com/nim-lang/Nim/pull/17529 + # https://github.com/nim-lang/Nim/pull/19822 + let styleCheckStyle = + if (NimMajor, NimMinor) < (1, 6): + "hint" + else: + "error" + # Compilation language is controlled by TEST_LANG var lang = "c" if existsEnv"TEST_LANG": @@ -33,7 +42,8 @@ proc test(env, path: string, shouldRun = true) = let run = if shouldRun: " -r" else: "" exec "nim " & lang & " " & env & run & - " --styleCheck:usages --styleCheck:error --hints:off --warnings:off " & path + " --styleCheck:usages --styleCheck:" & styleCheckStyle & + " --hints:off --warnings:off " & path task test, "Run all tests": test "--threads:off", "tests/test_all" diff --git a/graphql/private/utf.nim b/graphql/private/utf.nim index 2a127b7..68f3b41 100644 --- a/graphql/private/utf.nim +++ b/graphql/private/utf.nim @@ -31,7 +31,7 @@ const Utf16Shift = 10 Utf16Base = 0x0010000 Utf16Mask = 0x3FF - Utf16Maxbmp= 0xFFFF + Utf16MaxBmp= 0xFFFF MaxUtf = 0x10FFFF DefaultReplacement* = 0xFFFD @@ -93,7 +93,7 @@ proc utf*(_: type Utf16, c1, c2: int): int = ((c1 - highBegin) shl Utf16Shift) + (c2 - lowBegin) + Utf16Base proc inc*(_: type Utf16, cp: int, res: var int): bool = - if cp <= Utf16Maxbmp: + if cp <= Utf16MaxBmp: if cp >= highBegin and cp <= lowBegin: return false else: @@ -164,19 +164,19 @@ proc utf8Len*(_: type Utf16, text: openArray[uint16]): Result[int, string] = if c1 >= highBegin and c1 <= highEnd: inc i if i >= text.len: - return err(InvalidUtf16) + return err(InvalidUTF16) # surrogate pairs let c2 = text[i] if c2 < lowBegin or c2 > lowEnd: - return err(InvalidUtf16) + return err(InvalidUTF16) let cp = Utf16.utf(c1, c2) if not Utf8.inc(cp, res): - return err(InvalidUtf16) + return err(InvalidUTF16) elif c1 >= lowBegin and c1 <= lowEnd: - return err(InvalidUtf16) + return err(InvalidUTF16) inc i if not Utf8.inc(c1, res): - return err(InvalidUtf16) + return err(InvalidUTF16) ok(res) @@ -237,7 +237,7 @@ proc append*(_: type Utf8, text: var (string | seq[byte]), c1, c2: int): bool = Utf8.append(text, Utf16.utf(c1, c2)) proc append*(_: type Utf16, text: var seq[uint16], cp: int): bool = - if cp <= Utf16Maxbmp: + if cp <= Utf16MaxBmp: if cp >= highBegin and cp <= lowBegin: return false else: @@ -318,7 +318,7 @@ type lo*: uint16 proc toPair*(_: type Utf16, cp: int): Utf16Pair = - if cp <= Utf16Maxbmp: + if cp <= Utf16MaxBmp: if cp >= highBegin and cp <= lowBegin: Utf16Pair(state: Utf16Error) else: diff --git a/graphql/test_common.nim b/graphql/test_common.nim index 5048e81..9d1f065 100644 --- a/graphql/test_common.nim +++ b/graphql/test_common.nim @@ -114,7 +114,8 @@ proc runSuite(ctx: GraphqlRef, savePoint: NameCounter, fileName: string, counter let parts = splitFile(fileName) let cases = Toml.loadFile(fileName, TestCase) suite parts.name: - for unit in cases.units: + for x in cases.units: + let unit = x # prevent nim >= 1.6 cannot capture lent test unit.name: if unit.skip: ctx.purgeQueries(true) diff --git a/tests/test_httpserver.nim b/tests/test_httpserver.nim index c628cbd..051a64d 100644 --- a/tests/test_httpserver.nim +++ b/tests/test_httpserver.nim @@ -116,7 +116,8 @@ proc runSuite(client: GraphqlHttpClientRef, fileName: string, counter: Counter) let parts = splitFile(fileName) let cases = Toml.loadFile(fileName, TestCase) suite parts.name: - for unit in cases.units: + for x in cases.units: + let unit = x # prevent nim >= 1.6 cannot capture lent test unit.name: if unit.skip: skip() @@ -211,7 +212,8 @@ when isMainModule: let cases = Toml.loadFile(fileName, TestCase) let server = createServer(serverAddress) server.start() - for unit in cases.units: + for x in cases.units: + let unit = x # prevent nim >= 1.6 cannot capture lent if unit.name != conf.unit: continue test unit.name: diff --git a/tests/test_parser.nim b/tests/test_parser.nim index 9115910..ad45892 100644 --- a/tests/test_parser.nim +++ b/tests/test_parser.nim @@ -85,7 +85,8 @@ proc suite3() = for fileName in walkDirRec("tests" / "schemas"): fileNames.add fileName - for fileName in fileNames: + for x in fileNames: + let fileName = x # prevent nim >= 1.6 cannot capture lent test fileName: check runGoodDoc(fileName) == true diff --git a/tests/test_schemaintros.nim b/tests/test_schemaintros.nim index d792863..6897e36 100644 --- a/tests/test_schemaintros.nim +++ b/tests/test_schemaintros.nim @@ -57,7 +57,8 @@ proc main() = continue fileNames.add fileName - for fileName in fileNames: + for x in fileNames: + let fileName = x # prevent nim >= 1.6 cannot capture lent let parts = splitFile(fileName) test parts.name: ctx.runValidator(fileName, testStatusIMPL) diff --git a/tests/test_validation.nim b/tests/test_validation.nim index 938d774..6621dc3 100644 --- a/tests/test_validation.nim +++ b/tests/test_validation.nim @@ -144,7 +144,8 @@ proc runSuite(ctx: GraphqlRef, savePoint: NameCounter, fileName: string, counter let parts = splitFile(fileName) let cases = Toml.loadFile(fileName, TestCase) suite parts.name: - for unit in cases.units: + for x in cases.units: + let unit = x # prevent nim >= 1.6 cannot capture lent test unit.name: if unit.skip: skip()