Skip to content

tests: cargo clean before checking stubs compile #1445

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

Merged
merged 2 commits into from
Feb 8, 2022
Merged
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
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -123,6 +123,9 @@ jobs:
run: ./_test/check_exercises.sh
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}

- name: Cargo clean (to prevent previous compilation from unintentionally interfering with later ones)
run: ./_test/cargo_clean_all.sh

- name: Ensure stubs compile
env:
DENYWARNINGS: ${{ matrix.deny_warnings }}
16 changes: 16 additions & 0 deletions _test/cargo_clean_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

status=0
repo="$(cd "$(dirname "$0")/.." && pwd)"

for ex in "$repo"/exercises/*/*/; do
name=$(grep '^name =' "$ex/Cargo.toml" | cut -d\" -f2)
if [ -z "$name" ]; then
echo "don't know name of $ex"
status=1
continue
fi
cargo clean --manifest-path "$ex/Cargo.toml" --package "$name"
Copy link
Member Author

Choose a reason for hiding this comment

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

given it only cleans the exercise package and not dependencies, I would understand objections to calling this "clean_all", in which case I would have to think of a better name. cargo_clean_exercises?

done

exit $status
10 changes: 5 additions & 5 deletions exercises/practice/perfect-numbers/.meta/example.rs
Original file line number Diff line number Diff line change
@@ -3,11 +3,11 @@ pub fn classify(num: u64) -> Option<Classification> {
return None;
}
let sum: u64 = (1..num).filter(|i| num % i == 0).sum();
match sum.cmp(&num) {
std::cmp::Ordering::Equal => Some(Classification::Perfect),
std::cmp::Ordering::Less => Some(Classification::Deficient),
std::cmp::Ordering::Greater => Some(Classification::Abundant),
}
Some(match sum.cmp(&num) {
std::cmp::Ordering::Equal => Classification::Perfect,
std::cmp::Ordering::Less => Classification::Deficient,
std::cmp::Ordering::Greater => Classification::Abundant,
})
}

#[derive(Debug, PartialEq, Eq)]