forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 234
[toolchain] Harden installation failure handling and RapidJSON CMake support #7583
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
Open
QuantumMisaka
wants to merge
7
commits into
deepmodeling:develop
Choose a base branch
from
QuantumMisaka:toolchain-issues
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+460
−33
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e39e284
test: cover toolchain wrapper failure propagation
QuantumMisaka 934515f
fix: preserve toolchain wrapper installer failures
QuantumMisaka b65c318
test: cover toolchain argument failure exits
QuantumMisaka 53d1f77
fix: propagate toolchain argument parsing failures
QuantumMisaka 077ed5b
test: cover RapidJSON CMake package compatibility
QuantumMisaka 583c5dc
fix: support installed RapidJSON CMake packages
QuantumMisaka 1a17635
fix: require RapidJSON exported CMake target
QuantumMisaka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| run_toolchain_with_log() { | ||
| local log_file="$1" | ||
| shift | ||
|
|
||
| "$@" | tee "$log_file" | ||
| local installer_status=${PIPESTATUS[0]} | ||
|
|
||
| return "$installer_status" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| #!/usr/bin/env bash | ||
| set -u | ||
|
|
||
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" | ||
| TOOLCHAIN_DIR="${REPO_ROOT}/toolchain" | ||
| FAILURES=0 | ||
|
|
||
| fail() { | ||
| printf 'FAIL: %s\n' "$*" >&2 | ||
| FAILURES=$((FAILURES + 1)) | ||
| } | ||
|
|
||
| copy_toolchain() { | ||
| local tmpdir="$1" | ||
| local entry name | ||
| mkdir -p "${tmpdir}/toolchain" | ||
| while IFS= read -r -d '' entry; do | ||
| name="${entry##*/}" | ||
| case "$name" in | ||
| build|install) continue ;; | ||
| esac | ||
| cp -a "$entry" "${tmpdir}/toolchain/" | ||
| done < <(find "${TOOLCHAIN_DIR}" -mindepth 1 -maxdepth 1 -print0) | ||
| } | ||
|
|
||
| run_installer_in_copy() { | ||
| local tmpdir="$1" | ||
| shift | ||
| (cd "${tmpdir}/toolchain" && ./install_abacus_toolchain_new.sh "$@") >"${tmpdir}/output.log" 2>&1 | ||
| } | ||
|
|
||
| assert_invalid_input_fails() { | ||
| local name="$1" | ||
| local expected_text="$2" | ||
| shift 2 | ||
|
|
||
| local tmpdir status | ||
| tmpdir="$(mktemp -d)" | ||
| copy_toolchain "$tmpdir" | ||
|
|
||
| run_installer_in_copy "$tmpdir" "$@" | ||
| status=$? | ||
|
|
||
| if [[ "$status" -eq 0 ]]; then | ||
| cat "${tmpdir}/output.log" >&2 | ||
| fail "${name} exited 0; expected nonzero" | ||
| fi | ||
|
|
||
| if ! grep -Fq -- "$expected_text" "${tmpdir}/output.log"; then | ||
| cat "${tmpdir}/output.log" >&2 | ||
| fail "${name} did not report expected error: ${expected_text}" | ||
| fi | ||
|
|
||
| if ! grep -Fq "install_abacus_toolchain_new.sh [OPTIONS]" "${tmpdir}/output.log"; then | ||
| cat "${tmpdir}/output.log" >&2 | ||
| fail "${name} output did not contain usage text" | ||
| fi | ||
|
|
||
| if [[ -e "${tmpdir}/toolchain/install/setup" ]]; then | ||
| fail "${name} wrote install/setup even though argument parsing failed" | ||
| fi | ||
|
|
||
| rm -rf "$tmpdir" | ||
| } | ||
|
|
||
| assert_valid_dry_run_succeeds() { | ||
| local name="$1" | ||
| shift | ||
|
|
||
| local tmpdir status | ||
| tmpdir="$(mktemp -d)" | ||
| copy_toolchain "$tmpdir" | ||
|
|
||
| run_installer_in_copy "$tmpdir" "$@" | ||
| status=$? | ||
|
|
||
| if [[ "$status" -ne 0 ]]; then | ||
| cat "${tmpdir}/output.log" >&2 | ||
| fail "${name} exited ${status}; expected 0" | ||
| fi | ||
|
|
||
| if ! grep -Fq "Configuration files generated successfully (dry-run mode)" "${tmpdir}/output.log"; then | ||
| cat "${tmpdir}/output.log" >&2 | ||
| fail "${name} output did not contain dry-run success text" | ||
| fi | ||
|
|
||
| if grep -Fq "Attempting secure download" "${tmpdir}/output.log"; then | ||
| cat "${tmpdir}/output.log" >&2 | ||
| fail "${name} attempted a package download during dry-run" | ||
| fi | ||
|
|
||
| rm -rf "$tmpdir" | ||
| } | ||
|
|
||
| assert_valid_help_succeeds() { | ||
| local tmpdir status | ||
| tmpdir="$(mktemp -d)" | ||
| copy_toolchain "$tmpdir" | ||
|
|
||
| run_installer_in_copy "$tmpdir" --help | ||
| status=$? | ||
|
|
||
| if [[ "$status" -ne 0 ]]; then | ||
| cat "${tmpdir}/output.log" >&2 | ||
| fail "--help exited ${status}; expected 0" | ||
| fi | ||
|
|
||
| if ! grep -Fq "install_abacus_toolchain_new.sh [OPTIONS]" "${tmpdir}/output.log"; then | ||
| cat "${tmpdir}/output.log" >&2 | ||
| fail "--help output did not contain usage text" | ||
| fi | ||
|
|
||
| rm -rf "$tmpdir" | ||
| } | ||
|
|
||
| assert_invalid_input_fails "invalid package version" "Invalid package version format" --dry-run --package-version bad:wrong | ||
| assert_invalid_input_fails "missing package version value" "--package-version requires at least one package:version argument" --dry-run --package-version | ||
| assert_invalid_input_fails "invalid mpi mode" "Invalid MPI mode: invalid" --dry-run --mpi-mode invalid | ||
| assert_invalid_input_fails "invalid gpu version" "Invalid GPU version" --dry-run --gpu-ver bad | ||
| assert_valid_dry_run_succeeds "explicit system openblas dry-run" --dry-run --with-openblas=system | ||
| assert_valid_help_succeeds | ||
|
|
||
| if [[ "$FAILURES" -ne 0 ]]; then | ||
| printf '%s installer argument failure test(s) failed\n' "$FAILURES" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| printf 'installer argument failure tests passed\n' |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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 breaks the modernlized target behavior and will most likely bring only issues.