-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add script test canisters #2652
Conversation
@frederikrothenberger please review |
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.
Useful script 👍
Left a few comments but already approving.
scripts/test.canisters.sh
Outdated
# Run tests | ||
|
||
echo "Running integration tests." | ||
cargo test "${@}" |
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 test "${@}" | |
cargo test "${@}" | |
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.
Thanks!
scripts/test.canisters.sh
Outdated
@@ -0,0 +1,49 @@ | |||
#!/bin/bash |
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.
This is the only script with multiple dots in the name. What about calling it test-canisters.sh
?
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.
Yes, good point.
scripts/test.canisters.sh
Outdated
#!/bin/bash | ||
|
||
POCKET_IC_SERVER_VERSION=6.0.0 | ||
POCKET_IC_SERVER_PATH="pocket-ic" |
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.
Given you are dealing with paths here, what about making sure that the working directory really is the repository directory?
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.
We also usually set flags to fail early on error:
set -euo pipefail
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.
Good idea, done!
scripts/test-canisters.sh
Outdated
PREVIOUS_ARCHIVE_WASM_PATH="archive_previous.wasm.gz" | ||
|
||
# Check if the script is run from the root of the project | ||
project_root=$(git rev-parse --show-toplevel 2>/dev/null) |
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.
We normally just switch to the appropriate directory:
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPTS_DIR/.."
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.
Ah, ok, changed!
Motivation
Make it easy to run the canisters tests.
Tu run all the tests successfully, the environment needs to be set up. There was a readme file explaining part of it.
Changes
I moved the explanation to a script that can be run and it will download the necessary artifacts needed to run all the tests.
🟡 Some screens were changed