Skip to content

Commit 4417a29

Browse files
authored
Merge pull request #1445 from petertseng/clean
tests: `cargo clean` before checking stubs compile
2 parents b9c024d + e27c799 commit 4417a29

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

.github/workflows/tests.yml

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ jobs:
123123
run: ./_test/check_exercises.sh
124124
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}
125125

126+
- name: Cargo clean (to prevent previous compilation from unintentionally interfering with later ones)
127+
run: ./_test/cargo_clean_all.sh
128+
126129
- name: Ensure stubs compile
127130
env:
128131
DENYWARNINGS: ${{ matrix.deny_warnings }}

_test/cargo_clean_all.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
status=0
4+
repo="$(cd "$(dirname "$0")/.." && pwd)"
5+
6+
for ex in "$repo"/exercises/*/*/; do
7+
name=$(grep '^name =' "$ex/Cargo.toml" | cut -d\" -f2)
8+
if [ -z "$name" ]; then
9+
echo "don't know name of $ex"
10+
status=1
11+
continue
12+
fi
13+
cargo clean --manifest-path "$ex/Cargo.toml" --package "$name"
14+
done
15+
16+
exit $status

exercises/practice/perfect-numbers/.meta/example.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ pub fn classify(num: u64) -> Option<Classification> {
33
return None;
44
}
55
let sum: u64 = (1..num).filter(|i| num % i == 0).sum();
6-
match sum.cmp(&num) {
7-
std::cmp::Ordering::Equal => Some(Classification::Perfect),
8-
std::cmp::Ordering::Less => Some(Classification::Deficient),
9-
std::cmp::Ordering::Greater => Some(Classification::Abundant),
10-
}
6+
Some(match sum.cmp(&num) {
7+
std::cmp::Ordering::Equal => Classification::Perfect,
8+
std::cmp::Ordering::Less => Classification::Deficient,
9+
std::cmp::Ordering::Greater => Classification::Abundant,
10+
})
1111
}
1212

1313
#[derive(Debug, PartialEq, Eq)]

0 commit comments

Comments
 (0)