Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

test.sh: use cargo --target for platforms other than linux, win or mac #9650

Merged
merged 4 commits into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ cache:

test-linux-rust-stable: &test
stage: test
variables:
RUN_TESTS: "true"
script:
- scripts/gitlab/test.sh stable
tags:
- rust-stable

test-linux-rust-beta:
stage: test
variables:
RUN_TESTS: "true"
script:
- scripts/gitlab/test.sh beta
tags:
Expand All @@ -68,6 +72,8 @@ test-linux-rust-beta:

test-linux-rust-nightly:
stage: test
variables:
RUN_TESTS: "true"
script:
- scripts/gitlab/test.sh nightly
tags:
Expand All @@ -80,6 +86,7 @@ test-darwin-rust-stable:
CARGO_TARGET: x86_64-apple-darwin
CC: gcc
CXX: g++
RUN_TESTS: "true"
script:
- scripts/gitlab/test.sh stable
tags:
Expand Down Expand Up @@ -107,6 +114,7 @@ test-windows-rust-stable:
# No cargo caching, since fetch-locking on Windows gets stuck
variables:
CARGO_TARGET: x86_64-pc-windows-msvc
RUN_TESTS: "true"
script:
- sh scripts/gitlab/test.sh stable
tags:
Expand Down
83 changes: 58 additions & 25 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
FEATURES="json-tests,ci-skip-issue"
OPTIONS="--release"
VALIDATE=1
THREADS=8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason to hardcode the number of threads?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just set it as a variable here and did not want to change the behaviour in this pr. But generally I think it's okay to have a fixed number - unless we decide not to run jobs concurrently and then dynamically set it to the number of cores available on a runner node.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically Cargo is supposed to determine the ideal number of threads. In practice I'm not sure it's better than hardcoding it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo help test
If you want to control the
number of simultaneous running test cases, pass the --test-threads option
to the test binaries:

cargo test -- --test-threads=1

MB
if darwin -> sysctl -n hw.ncpu
if windows -> echo %NUMBER_OF_PROCESSORS%
if linux -> $(nproc)


case $1 in
--no-json)
Expand All @@ -29,31 +30,63 @@ esac

set -e

if [ "$VALIDATE" -eq "1" ]; then
# Validate --no-default-features build
echo "________Validate build________"
time cargo check --no-default-features
time cargo check --manifest-path util/io/Cargo.toml --no-default-features
time cargo check --manifest-path util/io/Cargo.toml --features "mio"

# Validate chainspecs
echo "________Validate chainspecs________"
time ./scripts/validate_chainspecs.sh
validate () {
if [ "$VALIDATE" -eq "1" ]
then
echo "________Validate build________"
time cargo check $@ --no-default-features
time cargo check $@ --manifest-path util/io/Cargo.toml --no-default-features
time cargo check $@ --manifest-path util/io/Cargo.toml --features "mio"

# Validate chainspecs
echo "________Validate chainspecs________"
time ./scripts/validate_chainspecs.sh
else
echo "# not validating due to \$VALIDATE!=1"
fi
}

cpp_test () {
# Running the C++ example
echo "________Running the C++ example________"
cd parity-clib-examples/cpp && \
mkdir -p build && \
cd build && \
cmake .. && \
make -j $THREADS && \
./parity-example && \
cd .. && \
rm -rf build && \
cd ../..
}

cargo_test () {
echo "________Running Parity Full Test Suite________"
git submodule update --init --recursive
time cargo test $OPTIONS --features "$FEATURES" --all $@ -- --test-threads $THREADS
}


if [ "$CARGO_TARGET" ]
then
validate --target $CARGO_TARGET
else
validate
fi

test "${RUN_TESTS}" = "true" && cpp_test

if [ "$CARGO_TARGET" ]
then

if [ "${RUN_TESTS}" = "true" ]
then
cargo_test --target $CARGO_TARGET $@
else
cargo_test --no-run --target $CARGO_TARGET $@
fi
else
cargo_test $@
fi

# Running the C++ example
echo "________Running the C++ example________"
cd parity-clib-examples/cpp && \
mkdir -p build && \
cd build && \
cmake .. && \
make -j 8 && \
./parity-example && \
cd .. && \
rm -rf build && \
cd ../..

# Running tests
echo "________Running Parity Full Test Suite________"
git submodule update --init --recursive
time cargo test $OPTIONS --features "$FEATURES" --all $1 -- --test-threads 8