mirror of
https://github.com/status-im/nim-unittest2.git
synced 2025-02-21 14:18:08 +00:00
commit
06063acac7
148
.github/workflows/ci.yml
vendored
Normal file
148
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
name: nim-unittest2 CI
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
timeout-minutes: 15
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 20
|
||||
matrix:
|
||||
target:
|
||||
- os: linux
|
||||
cpu: amd64
|
||||
- os: linux
|
||||
cpu: i386
|
||||
- os: macos
|
||||
cpu: amd64
|
||||
- os: windows
|
||||
cpu: amd64
|
||||
branch: [version-1-2, version-1-4, devel]
|
||||
include:
|
||||
- target:
|
||||
os: linux
|
||||
builder: ubuntu-20.04
|
||||
- target:
|
||||
os: macos
|
||||
builder: macos-10.15
|
||||
- target:
|
||||
os: windows
|
||||
builder: windows-2019
|
||||
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})'
|
||||
runs-on: ${{ matrix.builder }}
|
||||
steps:
|
||||
- name: Git checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Derive environment variables
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
|
||||
ARCH=64
|
||||
PLATFORM=x64
|
||||
else
|
||||
ARCH=32
|
||||
PLATFORM=x86
|
||||
fi
|
||||
echo "ARCH=$ARCH" >> $GITHUB_ENV
|
||||
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
|
||||
|
||||
if [[ '${{ matrix.target.os }}' == 'windows' ]]; then
|
||||
MAKE_CMD="mingw32-make"
|
||||
else
|
||||
MAKE_CMD="make"
|
||||
fi
|
||||
echo "MAKE_CMD=$MAKE_CMD" >> $GITHUB_ENV
|
||||
|
||||
ncpu=
|
||||
case '${{ runner.os }}' in
|
||||
'Linux')
|
||||
ncpu=$(nproc)
|
||||
;;
|
||||
'macOS')
|
||||
ncpu=$(sysctl -n hw.ncpu)
|
||||
;;
|
||||
'Windows')
|
||||
ncpu=$NUMBER_OF_PROCESSORS
|
||||
;;
|
||||
esac
|
||||
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
|
||||
echo "ncpu=$ncpu" >> $GITHUB_ENV
|
||||
|
||||
- name: Install build dependencies (Linux i386)
|
||||
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update -qq
|
||||
sudo DEBIAN_FRONTEND='noninteractive' apt-get install \
|
||||
--no-install-recommends -yq gcc-multilib g++-multilib
|
||||
mkdir -p external/bin
|
||||
cat << EOF > external/bin/gcc
|
||||
#!/bin/bash
|
||||
exec $(which gcc) -m32 -mno-adx "\$@"
|
||||
EOF
|
||||
cat << EOF > external/bin/g++
|
||||
#!/bin/bash
|
||||
exec $(which g++) -m32 -mno-adx "\$@"
|
||||
EOF
|
||||
chmod 755 external/bin/gcc external/bin/g++
|
||||
echo "${{ github.workspace }}/external/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Restore MinGW-W64 (Windows) from cache
|
||||
if: runner.os == 'Windows'
|
||||
id: windows-mingw-cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: external/mingw-${{ matrix.target.cpu }}
|
||||
key: 'mingw-${{ matrix.target.cpu }}'
|
||||
|
||||
- name: Restore Nim DLLs dependencies (Windows) from cache
|
||||
if: runner.os == 'Windows'
|
||||
id: windows-dlls-cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: external/dlls-${{ matrix.target.cpu }}
|
||||
key: 'dlls-${{ matrix.target.cpu }}'
|
||||
|
||||
- name: Install MinGW64 dependency (Windows)
|
||||
if: >
|
||||
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
|
||||
runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p external
|
||||
curl -L "https://nim-lang.org/download/mingw$ARCH-6.3.0.7z" -o "external/mingw-${{ matrix.target.cpu }}.7z"
|
||||
7z x -y "external/mingw-${{ matrix.target.cpu }}.7z" -oexternal/
|
||||
mv external/mingw$ARCH external/mingw-${{ matrix.target.cpu }}
|
||||
|
||||
- name: Install DLLs dependencies (Windows)
|
||||
if: >
|
||||
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
|
||||
runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p external
|
||||
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
|
||||
7z x -y external/windeps.zip -oexternal/dlls-${{ matrix.target.cpu }}
|
||||
|
||||
- name: Path to cached dependencies (Windows)
|
||||
if: >
|
||||
runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "${{ github.workspace }}/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
|
||||
echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
|
||||
|
||||
- name: Build the Nim compiler
|
||||
shell: bash
|
||||
run: |
|
||||
git clone -b ${{ matrix.branch }} --depth 1 git://github.com/nim-lang/nim nim/
|
||||
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
|
||||
env MAKE="${MAKE_CMD} -j${ncpu}" ARCH_OVERRIDE=${PLATFORM} CC=gcc QUICK_AND_DIRTY_COMPILER=1 bash build_nim.sh nim csources dist/nimble NimBinaries
|
||||
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
nim --hints:off --verbosity:0 test
|
||||
|
@ -51,7 +51,8 @@ See the [tests](./tests) for more examples!
|
||||
## Testing `unittest2`
|
||||
|
||||
```text
|
||||
nimble test
|
||||
# this calls a task in "config.nims"
|
||||
nim test
|
||||
```
|
||||
|
||||
## License
|
||||
|
8
config.nims
Normal file
8
config.nims
Normal file
@ -0,0 +1,8 @@
|
||||
task test, "Run tests":
|
||||
for f in listFiles("tests"):
|
||||
if f.len > 4 and f[^4..^1] == ".nim":
|
||||
let cmd = "nim c -r -f --threads:on --hints:off --verbosity:0 --skipParentCfg:on --skipUserCfg:on " & f
|
||||
echo cmd
|
||||
exec cmd
|
||||
rmFile(f[0..^5].toExe())
|
||||
|
@ -149,7 +149,10 @@ when paralleliseTests:
|
||||
proc repeatableSync*() =
|
||||
sync()
|
||||
for flowVar in flowVars:
|
||||
blockUntil(flowVar)
|
||||
when (NimMajor, NimMinor, NimPatch) >= (1, 4, 0):
|
||||
blockUntil(flowVar[])
|
||||
else:
|
||||
blockUntil(flowVar)
|
||||
flowVars = @[]
|
||||
|
||||
# make sure all the spawned tests are done before exiting
|
||||
@ -231,6 +234,9 @@ const
|
||||
nimUnittestColor {.strdefine.} = "auto" ## auto|on|off
|
||||
nimUnittestAbortOnError {.booldefine.} = false
|
||||
|
||||
initLock(formattersLock)
|
||||
initLock(testFiltersLock)
|
||||
|
||||
template deprecateEnvVarHere() =
|
||||
# xxx issue a runtime warning to deprecate this envvar.
|
||||
discard
|
||||
@ -554,7 +560,9 @@ proc testStarted(name: string) =
|
||||
withLock formattersLock:
|
||||
{.gcsafe.}:
|
||||
for formatter in formatters:
|
||||
formatter.testStarted(name)
|
||||
if not formatter.isNil:
|
||||
# Useless check that somehow prevents a method dispatch failure on macOS
|
||||
formatter.testStarted(name)
|
||||
|
||||
proc testEnded(testResult: TestResult) =
|
||||
withLock formattersLock:
|
||||
@ -639,7 +647,10 @@ template test*(name, body) =
|
||||
## .. code-block::
|
||||
##
|
||||
## [OK] roses are red
|
||||
bind shouldRun, checkpoints, formatters, ensureInitialized, testEnded, exceptionTypeName
|
||||
bind shouldRun, checkpoints, ensureInitialized, testEnded, exceptionTypeName
|
||||
withLock formattersLock:
|
||||
{.gcsafe.}:
|
||||
bind formatters
|
||||
|
||||
# `gensym` can't be in here because it's not a first-class pragma
|
||||
when paralleliseTests:
|
||||
|
@ -6,9 +6,3 @@ description = "unittest fork with support for parallel test execution"
|
||||
license = "MIT"
|
||||
requires "nim >= 0.19.4"
|
||||
|
||||
task test, "Run tests":
|
||||
for f in listFiles("tests"):
|
||||
if f.len > 4 and f[^4..^1] == ".nim":
|
||||
exec "nim c -r -f --hints:off --verbosity:0 " & f
|
||||
rmFile(f[0..^5].toExe())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user