Skip to content

Commit 0f2cf27

Browse files
committed
test.sh: add ability to specify CARGO
1 parent 0c4e7ff commit 0f2cf27

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

capstone-rs/ci/test.sh

+9-8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Error() {
3030
RUST_BACKTRACE=1
3131
SHOULD_FAIL=${SHOULD_FAIL:-} # Default to false
3232
VALGRIND_TESTS=${VALGRIND_TESTS:-}
33+
CARGO="${CARGO:-cargo}"
3334

3435
# Feature vars
3536
if [ -n "${ALL_FEATURES:-}" -a -n "${NO_DEFAULT_FEATURES:-}" ]; then
@@ -135,15 +136,15 @@ run_kcov() {
135136
json_format_args="--quiet --message-format=json"
136137

137138
# Test binaries
138-
cargo_test_args="cargo test --no-run"
139+
cargo_test_args="${CARGO} test --no-run"
139140
${cargo_test_args} -v
140141
TEST_BINS="$(${cargo_test_args} ${json_format_args} \
141142
| jq -r "select(.profile.test == true) | .filenames[]")"
142143

143144
# Exaple binaries
144145
EXAMPLE_BINS=
145146
for example in $SIMPLE_RUN_EXAMPLES; do
146-
cargo_build_example_args="cargo build --example $example"
147+
cargo_build_example_args="${CARGO} build --example $example"
147148
${cargo_build_example_args} -v
148149
example_bin="$(${cargo_build_example_args} ${json_format_args} \
149150
| jq -r '.executable | strings')"
@@ -191,7 +192,7 @@ cov() {
191192
}
192193

193194
bench() {
194-
cargo bench
195+
${CARGO} bench
195196
}
196197

197198
profile_args() {
@@ -211,7 +212,7 @@ test_rust_file() {
211212

212213
capstone_dir="$(pwd)"
213214
cd "$tmp_dir"
214-
cargo new --bin test_project -v
215+
${CARGO} new --bin test_project -v
215216
cd test_project
216217
echo "capstone = { path = \"$capstone_dir\" }" >> Cargo.toml
217218
cat Cargo.toml
@@ -223,7 +224,7 @@ test_rust_file() {
223224
$(profile_args)
224225
--verbose
225226
)
226-
cargo check "${cargo_cmd_args[@]}" || exit 1
227+
${CARGO} check "${cargo_cmd_args[@]}" || exit 1
227228

228229
rm -rf "$tmp_dir"
229230
) || exit 1
@@ -240,16 +241,16 @@ run_tests() {
240241
"${CARGO_FEATURE_ARGS[@]}"
241242
)
242243
expect_exit_status "$SHOULD_FAIL" \
243-
cargo test "${cargo_cmd_args[@]}" \
244+
${CARGO} test "${cargo_cmd_args[@]}" \
244245
--color=always -- --color=always \
245246
2>&1 | tee "$TMPFILE"
246247
# Use 2>&1 above instead of '|&' because OS X uses Bash 3
247248
for example in $SIMPLE_RUN_EXAMPLES; do
248-
cargo run "${cargo_cmd_args[@]}" --example "$example"
249+
${CARGO} run "${cargo_cmd_args[@]}" --example "$example"
249250
done
250251
(
251252
cd ../cstool
252-
cargo run $(profile_args) -- \
253+
${CARGO} run $(profile_args) -- \
253254
--arch x86 --mode mode64 --file ../capstone-rs/test-inputs/x86_64.bin_ls.bin |
254255
head -n20
255256
)

0 commit comments

Comments
 (0)