generated from exercism/generic-test-runner
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update readme * Implement run(-test).sh files * Add Dockerfile * Remove asdf installation * Sort test results in run.sh * remove the need to sort result contents in run-tests.sh * Add tests/**/Scarb.lock & target to gitignore * Add all-fail tests * Update all-file + empty-file not yet working * Fix error case in run.sh * Move sorting to run-tests.sh * Fix comparison in run-tests.sh * Regenerate empty-file's expected_results.json * generate partial-fail's expected_results.json * generate success's & syntax-error's expected_results.json * Include relative file path in the error message * UPdate Dockerfile to make run-in-docker work * Improve 'done' msgs in run-x.sh scripts * Switch Docker (and scarb install) to alpine * Remove solution_dir prefix after reading errors up to 'could not compile' * Add msg if results match * Remove echo of run-tests done * Refactor --------- Co-authored-by: Nenad <[email protected]>
- Loading branch information
Nenad Misić
and
Nenad
authored
Jul 22, 2024
1 parent
09591da
commit a2833b9
Showing
27 changed files
with
386 additions
and
65 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1 +1,3 @@ | ||
/tests/**/*/results.json | ||
/tests/**/Scarb.lock | ||
/tests/**/target |
This file contains 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 |
---|---|---|
@@ -1,8 +1,30 @@ | ||
FROM alpine:3.18 | ||
ARG REPO=alpine | ||
ARG IMAGE=3.18 | ||
FROM ${REPO}:${IMAGE} AS builder | ||
|
||
ARG VERSION=v2.6.5 | ||
ARG RELEASE=scarb-${VERSION}-x86_64-unknown-linux-musl | ||
|
||
RUN apk add --no-cache curl | ||
|
||
RUN mkdir opt/test-runner | ||
RUN mkdir opt/test-runner/bin | ||
WORKDIR /tmp | ||
ADD https://github.com/software-mansion/scarb/releases/download/${VERSION}/${RELEASE}.tar.gz . | ||
RUN tar -xf ${RELEASE}.tar.gz \ | ||
&& rm -rf /tmp/${RELEASE}/doc \ | ||
&& mv /tmp/${RELEASE} /opt/test-runner/bin/scarb | ||
|
||
FROM ${REPO}:${IMAGE} AS runner | ||
|
||
# install packages required to run the tests | ||
RUN apk add --no-cache jq coreutils | ||
# hadolint ignore=DL3018 | ||
RUN apk add --no-cache jq | ||
|
||
COPY --from=builder /opt/test-runner/bin/scarb /opt/test-runner/bin/scarb | ||
ENV PATH=$PATH:/opt/test-runner/bin/scarb/bin | ||
|
||
WORKDIR /opt/test-runner | ||
COPY . . | ||
# Initialize a scarb cache | ||
ENTRYPOINT ["/opt/test-runner/bin/run.sh"] |
This file contains 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 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 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 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 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 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,4 @@ | ||
[package] | ||
name = "leap" | ||
version = "0.1.0" | ||
edition = "2023_11" |
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": 1, | ||
"status": "fail", | ||
"message": "TODO: replace with correct output" | ||
"message": "leap_leap::leap::year_divisible_by_400_is_leap_year - Panicked with \"assertion failed: `is_leap_year(2000)`.\".\nleap_leap::leap::year_divisible_by_4_and_5_is_still_a_leap_year - Panicked with \"assertion failed: `is_leap_year(1960)`.\".\nleap_leap::leap::year_divisible_by_4_not_divisible_by_100_in_leap_year - Panicked with \"assertion failed: `is_leap_year(1996)`.\".\nleap_leap::leap::year_divisible_by_2_not_divisible_by_4_in_common_year - Panicked with \"assertion failed: `!is_leap_year(1970)`.\".\nleap_leap::leap::year_divisible_by_400_but_not_by_125_is_still_a_leap_year - Panicked with \"assertion failed: `is_leap_year(2400)`.\".\nleap_leap::leap::year_not_divisible_by_4_in_common_year - Panicked with \"assertion failed: `!is_leap_year(2015)`.\".\nleap_leap::leap::year_divisible_by_200_not_divisible_by_400_in_common_year - Panicked with \"assertion failed: `!is_leap_year(1800)`.\".\nleap_leap::leap::year_divisible_by_100_not_divisible_by_400_in_common_year - Panicked with \"assertion failed: `!is_leap_year(2100)`.\".\nleap_leap::leap::year_divisible_by_100_but_not_by_3_is_still_not_a_leap_year - Panicked with \"assertion failed: `!is_leap_year(1900)`.\"." | ||
} |
This file contains 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,3 @@ | ||
pub fn is_leap_year(year: u64) -> bool { | ||
!(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) | ||
} |
This file contains 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,54 @@ | ||
use leap::is_leap_year; | ||
|
||
#[test] | ||
fn year_not_divisible_by_4_in_common_year() { | ||
assert!(!is_leap_year(2015)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_2_not_divisible_by_4_in_common_year() { | ||
assert!(!is_leap_year(1970)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_4_not_divisible_by_100_in_leap_year() { | ||
assert!(is_leap_year(1996)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_4_and_5_is_still_a_leap_year() { | ||
assert!(is_leap_year(1960)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_100_not_divisible_by_400_in_common_year() { | ||
assert!(!is_leap_year(2100)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_100_but_not_by_3_is_still_not_a_leap_year() { | ||
assert!(!is_leap_year(1900)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_400_is_leap_year() { | ||
assert!(is_leap_year(2000)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_400_but_not_by_125_is_still_a_leap_year() { | ||
assert!(is_leap_year(2400)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_200_not_divisible_by_400_in_common_year() { | ||
assert!(!is_leap_year(1800)); | ||
} |
This file contains 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,4 @@ | ||
[package] | ||
name = "leap" | ||
version = "0.1.0" | ||
edition = "2023_11" |
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": 1, | ||
"status": "fail", | ||
"message": "TODO: replace with correct output" | ||
"status": "error", | ||
"message": "error: Identifier not found.\n --> /tests/leap.cairo:1:11\nuse leap::is_leap_year;\n ^**********^" | ||
} |
This file contains 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 @@ | ||
|
This file contains 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,54 @@ | ||
use leap::is_leap_year; | ||
|
||
#[test] | ||
fn year_not_divisible_by_4_in_common_year() { | ||
assert!(!is_leap_year(2015)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_2_not_divisible_by_4_in_common_year() { | ||
assert!(!is_leap_year(1970)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_4_not_divisible_by_100_in_leap_year() { | ||
assert!(is_leap_year(1996)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_4_and_5_is_still_a_leap_year() { | ||
assert!(is_leap_year(1960)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_100_not_divisible_by_400_in_common_year() { | ||
assert!(!is_leap_year(2100)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_100_but_not_by_3_is_still_not_a_leap_year() { | ||
assert!(!is_leap_year(1900)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_400_is_leap_year() { | ||
assert!(is_leap_year(2000)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_400_but_not_by_125_is_still_a_leap_year() { | ||
assert!(is_leap_year(2400)); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn year_divisible_by_200_not_divisible_by_400_in_common_year() { | ||
assert!(!is_leap_year(1800)); | ||
} |
This file contains 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,4 @@ | ||
[package] | ||
name = "leap" | ||
version = "0.1.0" | ||
edition = "2023_11" |
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": 1, | ||
"status": "fail", | ||
"message": "TODO: replace with correct output" | ||
"message": "leap_leap::leap::year_divisible_by_100_but_not_by_3_is_still_not_a_leap_year - Panicked with \"assertion failed: `!is_leap_year(1900)`.\".\nleap_leap::leap::year_divisible_by_100_not_divisible_by_400_in_common_year - Panicked with \"assertion failed: `!is_leap_year(2100)`.\".\nleap_leap::leap::year_divisible_by_200_not_divisible_by_400_in_common_year - Panicked with \"assertion failed: `!is_leap_year(1800)`.\"." | ||
} |
This file contains 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,3 @@ | ||
pub fn is_leap_year(year: u64) -> bool { | ||
year % 4 == 0 && (year % 101 != 0 || year % 400 == 0) | ||
} |
Oops, something went wrong.