Skip to content

Commit 334c0b2

Browse files
authored
verify_exercises_in_docker: fix handling of example Cargo files (#2136)
Solutions that used different dependencies than the ones specified in the template Cargo.toml would fail in the verify_exercises_in_docker script. To fix that, the file is included in the "filed.example" list, such that it is copied into the temporary solution directory, and moved to Cargo.toml.
1 parent 3c4f1bb commit 334c0b2

8 files changed

Lines changed: 17 additions & 7 deletions

File tree

bin/verify_exercises_in_docker.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ copy_example_or_examplar_to_solution() {
2727
| while read -r src_and_dst; do
2828
cp "$(jq -r '.src' <<< "${src_and_dst}")" "$(jq -r '.dst' <<< "${src_and_dst}")"
2929
done
30+
if test -f Cargo-example.toml ; then
31+
mv Cargo-example.toml Cargo.toml
32+
fi
3033
}
3134

3235
pull_docker_image() {

exercises/practice/alphametics/.meta/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"tests/alphametics.rs"
3333
],
3434
"example": [
35-
".meta/example.rs"
35+
".meta/example.rs",
36+
".meta/Cargo-example.toml"
3637
]
3738
},
3839
"blurb": "Given an alphametics puzzle, find the correct solution.",

exercises/practice/book-store/.meta/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"tests/book_store.rs"
2424
],
2525
"example": [
26-
".meta/example.rs"
26+
".meta/example.rs",
27+
".meta/Cargo-example.toml"
2728
]
2829
},
2930
"blurb": "To try and encourage more sales of different books from a popular 5 book series, a bookshop has decided to offer discounts of multiple-book purchases.",

exercises/practice/decimal/.meta/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"tests/decimal.rs"
2525
],
2626
"example": [
27-
".meta/example.rs"
27+
".meta/example.rs",
28+
".meta/Cargo-example.toml"
2829
]
2930
},
3031
"blurb": "Implement a Decimal type",

exercises/practice/diffie-hellman/.meta/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"tests/diffie_hellman.rs"
2727
],
2828
"example": [
29-
".meta/example.rs"
29+
".meta/example.rs",
30+
".meta/Cargo-example.toml"
3031
]
3132
},
3233
"blurb": "Diffie-Hellman key exchange.",

exercises/practice/grep/.meta/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"tests/grep.rs"
2424
],
2525
"example": [
26-
".meta/example.rs"
26+
".meta/example.rs",
27+
".meta/Cargo-example.toml"
2728
]
2829
},
2930
"blurb": "Search a file for lines matching a regular expression pattern. Return the line number and contents of each matching line.",

exercises/practice/pig-latin/.meta/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"tests/pig_latin.rs"
2828
],
2929
"example": [
30-
".meta/example.rs"
30+
".meta/example.rs",
31+
".meta/Cargo-example.toml"
3132
]
3233
},
3334
"blurb": "Implement a program that translates from English to Pig Latin.",

exercises/practice/poker/.meta/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"tests/poker.rs"
2828
],
2929
"example": [
30-
".meta/example.rs"
30+
".meta/example.rs",
31+
".meta/Cargo-example.toml"
3132
]
3233
},
3334
"blurb": "Pick the best hand(s) from a list of poker hands.",

0 commit comments

Comments
 (0)