mirror of
https://github.com/status-im/constantine.git
synced 2025-02-21 16:38:24 +00:00
Build and run tests in parallel (#41)
* Build and run tests in parallel * Workaround travis OSX Homebrew bug * semicolons ... * Don't auto-update before installing homebrew packages
This commit is contained in:
parent
3d1b1fab98
commit
f8fb54faef
3
.gitignore
vendored
3
.gitignore
vendored
@ -12,3 +12,6 @@ build/
|
||||
|
||||
# Sage
|
||||
*.sage.py
|
||||
|
||||
# Tests
|
||||
test_*.txt
|
||||
|
@ -51,11 +51,17 @@ addons:
|
||||
apt:
|
||||
packages:
|
||||
- libgmp-dev
|
||||
- parallel
|
||||
homebrew:
|
||||
packages:
|
||||
- gmp
|
||||
# Travis `bundle` bug: https://travis-ci.community/t/macos-build-fails-because-of-homebrew-bundle-unknown-command/7296/28
|
||||
# - parallel
|
||||
|
||||
before_install:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install parallel;
|
||||
fi
|
||||
- |
|
||||
if [ "${CHANNEL}" = stable ]; then
|
||||
BRANCH="v$(curl https://nim-lang.org/channels/stable)"
|
||||
@ -92,7 +98,7 @@ before_script:
|
||||
script:
|
||||
- nimble refresh
|
||||
- nimble install gmp stew
|
||||
- nimble test
|
||||
- nimble test_parallel
|
||||
branches:
|
||||
except:
|
||||
- gh-pages
|
||||
|
@ -185,7 +185,7 @@ steps:
|
||||
- bash: |
|
||||
echo "PATH=${PATH}"
|
||||
export ucpu=${UCPU}
|
||||
nimble test
|
||||
nimble test_parallel
|
||||
displayName: 'Testing the package (including GMP)'
|
||||
condition: ne(variables['Agent.OS'], 'Windows_NT')
|
||||
|
||||
|
@ -8,8 +8,12 @@ srcDir = "src"
|
||||
### Dependencies
|
||||
requires "nim >= 1.1.0"
|
||||
|
||||
const buildParallel = "test_parallel.txt"
|
||||
|
||||
### Helper functions
|
||||
proc test(flags, path: string) =
|
||||
proc test(flags, path: string, commandFile = false) =
|
||||
# commandFile should be a "file" but Nimscript doesn't support IO
|
||||
# TODO: use a proper runner
|
||||
if not dirExists "build":
|
||||
mkDir "build"
|
||||
# Compilation language is controlled by WEAVE_TEST_LANG
|
||||
@ -21,10 +25,16 @@ proc test(flags, path: string) =
|
||||
if existsEnv"CC":
|
||||
cc = " --cc:" & getEnv"CC"
|
||||
|
||||
echo "\n========================================================================================"
|
||||
echo "Running [flags: ", flags, "] ", path
|
||||
echo "========================================================================================"
|
||||
exec "nim " & lang & cc & " " & flags & " --verbosity:0 --outdir:build -r --hints:off --warnings:off " & path
|
||||
let command = "nim " & lang & cc & " " & flags & " --verbosity:0 --outdir:build -r --hints:off --warnings:off " & path
|
||||
|
||||
if not commandFile:
|
||||
echo "\n========================================================================================"
|
||||
echo "Running [flags: ", flags, "] ", path
|
||||
echo "========================================================================================"
|
||||
exec command
|
||||
else:
|
||||
# commandFile.writeLine command
|
||||
exec "echo \'" & command & "\' >> " & buildParallel
|
||||
|
||||
proc runBench(benchName: string, compiler = "") =
|
||||
if not dirExists "build":
|
||||
@ -174,6 +184,92 @@ task test_no_gmp, "Run tests that don't require GMP":
|
||||
runBench("bench_fp12")
|
||||
runBench("bench_ec_swei_proj_g1")
|
||||
|
||||
task test_parallel, "Run all tests in parallel (via GNU parallel)":
|
||||
# -d:testingCurves is configured in a *.nim.cfg for convenience
|
||||
let cmdFile = true # open(buildParallel, mode = fmWrite) # Nimscript doesn't support IO :/
|
||||
exec "> " & buildParallel
|
||||
|
||||
# Primitives
|
||||
test "", "tests/test_primitives.nim", cmdFile
|
||||
|
||||
# Big ints
|
||||
test "", "tests/test_io_bigints.nim", cmdFile
|
||||
test "", "tests/test_bigints.nim", cmdFile
|
||||
test "", "tests/test_bigints_multimod.nim", cmdFile
|
||||
|
||||
test "", "tests/test_bigints_vs_gmp.nim", cmdFile
|
||||
|
||||
# Field
|
||||
test "", "tests/test_io_fields", cmdFile
|
||||
test "", "tests/test_finite_fields.nim", cmdFile
|
||||
test "", "tests/test_finite_fields_mulsquare.nim", cmdFile
|
||||
test "", "tests/test_finite_fields_sqrt.nim", cmdFile
|
||||
test "", "tests/test_finite_fields_powinv.nim", cmdFile
|
||||
|
||||
test "", "tests/test_finite_fields_vs_gmp.nim", cmdFile
|
||||
|
||||
# Towers of extension fields
|
||||
test "", "tests/test_fp2.nim", cmdFile
|
||||
test "", "tests/test_fp6.nim", cmdFile
|
||||
test "", "tests/test_fp12.nim", cmdFile
|
||||
|
||||
# Elliptic curve arithmetic
|
||||
test "", "tests/test_ec_weierstrass_projective_g1.nim", cmdFile
|
||||
test "", "tests/test_ec_bn254.nim", cmdFile
|
||||
test "", "tests/test_ec_bls12_381.nim", cmdFile
|
||||
|
||||
# cmdFile.close()
|
||||
# Execute everything in parallel with GNU parallel
|
||||
exec "parallel --keep-order --group < " & buildParallel
|
||||
|
||||
exec "> " & buildParallel
|
||||
|
||||
if sizeof(int) == 8: # 32-bit tests on 64-bit arch
|
||||
# Primitives
|
||||
test "-d:Constantine32", "tests/test_primitives.nim", cmdFile
|
||||
|
||||
# Big ints
|
||||
test "-d:Constantine32", "tests/test_io_bigints.nim", cmdFile
|
||||
test "-d:Constantine32", "tests/test_bigints.nim", cmdFile
|
||||
test "-d:Constantine32", "tests/test_bigints_multimod.nim", cmdFile
|
||||
|
||||
test "-d:Constantine32", "tests/test_bigints_vs_gmp.nim", cmdFile
|
||||
|
||||
# Field
|
||||
test "-d:Constantine32", "tests/test_io_fields", cmdFile
|
||||
test "-d:Constantine32", "tests/test_finite_fields.nim", cmdFile
|
||||
test "-d:Constantine32", "tests/test_finite_fields_mulsquare.nim", cmdFile
|
||||
test "-d:Constantine32", "tests/test_finite_fields_sqrt.nim", cmdFile
|
||||
test "-d:Constantine32", "tests/test_finite_fields_powinv.nim", cmdFile
|
||||
|
||||
test "-d:Constantine32", "tests/test_finite_fields_vs_gmp.nim", cmdFile
|
||||
|
||||
# Towers of extension fields
|
||||
test "-d:Constantine32", "tests/test_fp2.nim", cmdFile
|
||||
test "-d:Constantine32", "tests/test_fp6.nim", cmdFile
|
||||
test "-d:Constantine32", "tests/test_fp12.nim", cmdFile
|
||||
|
||||
# Elliptic curve arithmetic
|
||||
test "-d:Constantine32", "tests/test_ec_weierstrass_projective_g1.nim", cmdFile
|
||||
test "-d:Constantine32", "tests/test_ec_bn254.nim", cmdFile
|
||||
test "-d:Constantine32", "tests/test_ec_bls12_381.nim", cmdFile
|
||||
|
||||
# cmdFile.close()
|
||||
# Execute everything in parallel with GNU parallel
|
||||
exec "parallel --keep-order --group < " & buildParallel
|
||||
|
||||
# Now run the benchmarks
|
||||
#
|
||||
# Benchmarks compile and run
|
||||
# ignore Windows 32-bit for the moment
|
||||
# Ensure benchmarks stay relevant. Ignore Windows 32-bit at the moment
|
||||
if not defined(windows) or not (existsEnv"UCPU" or getEnv"UCPU" == "i686"):
|
||||
runBench("bench_fp")
|
||||
runBench("bench_fp2")
|
||||
runBench("bench_fp6")
|
||||
runBench("bench_fp12")
|
||||
runBench("bench_ec_swei_proj_g1")
|
||||
|
||||
task bench_fp, "Run benchmark 𝔽p with your default compiler":
|
||||
runBench("bench_fp")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user