-
Notifications
You must be signed in to change notification settings - Fork 1.7k
test.sh: use cargo --target for platforms other than linux, win or mac #9650
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
FEATURES="json-tests,ci-skip-issue" | ||
OPTIONS="--release" | ||
VALIDATE=1 | ||
THREADS=8 | ||
|
||
case $1 in | ||
--no-json) | ||
|
@@ -29,31 +30,58 @@ 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 | ||
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 | ||
|
||
|
||
case $CARGO_TARGET in | ||
(x86_64-unknown-linux-gnu|x86_64-apple-darwin|x86_64-pc-windows-msvc|'') | ||
# native builds | ||
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do they not require a $TARGET? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They use the default target. I don't want to break the script for those who run it locally and probably don't have the CARGO_TARGET variable set because it's not required and specific to the CI. |
||
|
||
# Validate chainspecs | ||
echo "________Validate chainspecs________" | ||
time ./scripts/validate_chainspecs.sh | ||
fi | ||
|
||
|
||
# Running the C++ example | ||
echo "________Running the C++ example________" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is only run in win,mac, and linux? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, @tomaka told me that that only makes sense. |
||
cd parity-clib-examples/cpp && \ | ||
mkdir -p build && \ | ||
cd build && \ | ||
cmake .. && \ | ||
make -j $THREADS && \ | ||
./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 $@ -- --test-threads $THREADS | ||
;; | ||
(*) | ||
if [ "$VALIDATE" -eq "1" ] | ||
then | ||
echo "________Validate build________" | ||
time cargo check --target $CARGO_TARGET --no-default-features | ||
time cargo check --target $CARGO_TARGET --manifest-path util/io/Cargo.toml --no-default-features | ||
time cargo check --target $CARGO_TARGET --manifest-path util/io/Cargo.toml --features "mio" | ||
|
||
# Validate chainspecs | ||
echo "________Validate chainspecs________" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. script duplicates a bit here, can we simplify it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I can do that. |
||
time ./scripts/validate_chainspecs.sh | ||
fi | ||
|
||
# Per default only build but not run the tests | ||
echo "________Building Parity Full Test Suite________" | ||
git submodule update --init --recursive | ||
time cargo test --no-run --target $CARGO_TARGET $OPTIONS --features "$FEATURES" --all $@ -- --test-threads $THREADS | ||
;; | ||
esac | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
optionto the test binaries:
MB
if darwin -> sysctl -n hw.ncpu
if windows -> echo %NUMBER_OF_PROCESSORS%
if linux -> $(nproc)