Skip to content

Commit 9078335

Browse files
Allow unskipping tests
1 parent a075f13 commit 9078335

File tree

22 files changed

+408
-28
lines changed

22 files changed

+408
-28
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ WORKDIR /opt/test-runner
1313

1414
RUN apk add bash jq
1515

16+
ENV DOTNET_NOLOGO=true
17+
ENV DOTNET_CLI_TELEMETRY_OPTOUT=true
18+
1619
COPY --from=build /root/.nuget/packages/ /root/.nuget/packages/
1720
COPY . .
1821
ENTRYPOINT ["/opt/test-runner/bin/run.sh"]

bin/run-tests.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ for test_dir in tests/*; do
2222

2323
bin/run.sh "${test_dir_name}" "${test_dir_path}" "${test_dir_path}"
2424

25-
# OPTIONAL: Normalize the results file
26-
# If the results.json file contains information that changes between
27-
# different test runs (e.g. timing information or paths), you should normalize
28-
# the results file to allow the diff comparison below to work as expected
29-
# sed -i -E \
30-
# -e 's/Elapsed time: [0-9]+\.[0-9]+ seconds//g' \
31-
# -e "s~${test_dir_path}~/solution~g" \
32-
# "${results_file_path}"
25+
# Normalize the results file
26+
sed -i -E \
27+
-e 's/Duration: [0-9]+ ms//g' \
28+
-e 's/ \[0-9]+ ms]//g' \
29+
-e "s~${test_dir_path}~/solution~g" \
30+
"${results_file_path}"
3331

3432
echo "${test_dir_name}: comparing results.json to expected_results.json"
3533
diff "${results_file_path}" "${expected_results_file_path}"

bin/run.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,41 @@ fi
2424
slug="$1"
2525
input_dir="${2%/}"
2626
output_dir="${3%/}"
27+
exercise=$(echo "${slug}" | sed -r 's/(^|-)([a-z])/\U\2/g')
28+
tests_file="${input_dir}/$(jq -r '.files.test[0]' "${input_dir}/.meta/config.json")"
29+
tests_file_original="${tests_file}.original"
2730
results_file="${output_dir}/results.json"
2831

2932
# Create the output directory if it doesn't exist
3033
mkdir -p "${output_dir}"
3134

3235
echo "${slug}: testing..."
3336

37+
cp "${tests_file}" "${tests_file_original}"
38+
39+
# Unskip tests
40+
sed -i -E 's/Skip *:= *"Remove this Skip property to run this test"//' "${tests_file}"
41+
3442
pushd "${input_dir}" > /dev/null
3543

3644
# Run the tests for the provided implementation file and redirect stdout and
3745
# stderr to capture it
3846
test_output=$(dotnet test --no-restore 2>&1)
3947
exit_code=$?
4048

49+
echo $test_output
50+
4151
popd > /dev/null
4252

53+
# Restore the original file
54+
mv -f "${tests_file_original}" "${tests_file}"
55+
4356
# Write the results.json file based on the exit code of the command that was
4457
# just executed that tested the implementation file
4558
if [ ${exit_code} -eq 0 ]; then
4659
jq -n '{version: 1, status: "pass"}' > ${results_file}
4760
else
48-
# OPTIONAL: Sanitize the output
49-
# In some cases, the test output might be overly verbose, in which case stripping
50-
# the unneeded information can be very helpful to the student
61+
# Sanitize the output
5162
# sanitized_test_output=$(printf "${test_output}" | sed -n '/Test results:/,$p')
5263

5364
# OPTIONAL: Manually add colors to the output to help scanning the output for errors
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Public Module Leap
2+
Public Function IsLeapYear(ByVal year As Integer) As Boolean
3+
Return year Mod 400 = 0 OrElse (year Mod 100 <> 0 AndAlso year Mod 4 = 0)
4+
End Function
5+
End Module
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"blurb": "Given a year, report if it is a leap year.",
3+
"authors": [
4+
"ch020"
5+
],
6+
"contributors": [
7+
"axtens"
8+
],
9+
"files": {
10+
"solution": [
11+
"Leap.vb"
12+
],
13+
"test": [
14+
"LeapTests.vb"
15+
],
16+
"example": [
17+
".meta/Example.vb"
18+
]
19+
},
20+
"source": "JavaRanch Cattle Drive, exercise 3",
21+
"source_url": "http://www.javaranch.com/leap.jsp"
22+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[6466b30d-519c-438e-935d-388224ab5223]
13+
description = "year not divisible by 4 in common year"
14+
15+
[ac227e82-ee82-4a09-9eb6-4f84331ffdb0]
16+
description = "year divisible by 2, not divisible by 4 in common year"
17+
18+
[4fe9b84c-8e65-489e-970b-856d60b8b78e]
19+
description = "year divisible by 4, not divisible by 100 in leap year"
20+
21+
[7fc6aed7-e63c-48f5-ae05-5fe182f60a5d]
22+
description = "year divisible by 4 and 5 is still a leap year"
23+
24+
[78a7848f-9667-4192-ae53-87b30c9a02dd]
25+
description = "year divisible by 100, not divisible by 400 in common year"
26+
27+
[9d70f938-537c-40a6-ba19-f50739ce8bac]
28+
description = "year divisible by 100 but not by 3 is still not a leap year"
29+
30+
[42ee56ad-d3e6-48f1-8e3f-c84078d916fc]
31+
description = "year divisible by 400 is leap year"
32+
33+
[57902c77-6fe9-40de-8302-587b5c27121e]
34+
description = "year divisible by 400 but not by 125 is still a leap year"
35+
36+
[c30331f6-f9f6-4881-ad38-8ca8c12520c1]
37+
description = "year divisible by 200, not divisible by 400 in common year"

tests/example-all-fail/LeapTests.vb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,42 @@ Public Class LeapTests
66
Assert.[False](Leap.IsLeapYear(2015))
77
End Sub
88

9-
<Fact(Skip:="Remove this Skip property to run this test")>
9+
<Fact()>
1010
Public Sub Year_divisible_by_2_not_divisible_by_4_in_common_year()
1111
Assert.[False](Leap.IsLeapYear(1970))
1212
End Sub
1313

14-
<Fact(Skip:="Remove this Skip property to run this test")>
14+
<Fact()>
1515
Public Sub Year_divisible_by_4_not_divisible_by_100_in_leap_year()
1616
Assert.[True](Leap.IsLeapYear(1996))
1717
End Sub
1818

19-
<Fact(Skip:="Remove this Skip property to run this test")>
19+
<Fact()>
2020
Public Sub Year_divisible_by_4_and_5_is_still_a_leap_year()
2121
Assert.[True](Leap.IsLeapYear(1960))
2222
End Sub
2323

24-
<Fact(Skip:="Remove this Skip property to run this test")>
24+
<Fact()>
2525
Public Sub Year_divisible_by_100_not_divisible_by_400_in_common_year()
2626
Assert.[False](Leap.IsLeapYear(2100))
2727
End Sub
2828

29-
<Fact(Skip:="Remove this Skip property to run this test")>
29+
<Fact()>
3030
Public Sub Year_divisible_by_100_but_not_by_3_is_still_not_a_leap_year()
3131
Assert.[False](Leap.IsLeapYear(1900))
3232
End Sub
3333

34-
<Fact(Skip:="Remove this Skip property to run this test")>
34+
<Fact()>
3535
Public Sub Year_divisible_by_400_in_leap_year()
3636
Assert.[True](Leap.IsLeapYear(2000))
3737
End Sub
3838

39-
<Fact(Skip:="Remove this Skip property to run this test")>
39+
<Fact()>
4040
Public Sub Year_divisible_by_400_but_not_by_125_is_still_a_leap_year()
4141
Assert.[True](Leap.IsLeapYear(2400))
4242
End Sub
4343

44-
<Fact(Skip:="Remove this Skip property to run this test")>
44+
<Fact()>
4545
Public Sub Year_divisible_by_200_not_divisible_by_400_in_common_year()
4646
Assert.[False](Leap.IsLeapYear(1800))
4747
End Sub
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Public Module Leap
2+
Public Function IsLeapYear(ByVal year As Integer) As Boolean
3+
Return year Mod 400 = 0 OrElse (year Mod 100 <> 0 AndAlso year Mod 4 = 0)
4+
End Function
5+
End Module
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"blurb": "Given a year, report if it is a leap year.",
3+
"authors": [
4+
"ch020"
5+
],
6+
"contributors": [
7+
"axtens"
8+
],
9+
"files": {
10+
"solution": [
11+
"Leap.vb"
12+
],
13+
"test": [
14+
"LeapTests.vb"
15+
],
16+
"example": [
17+
".meta/Example.vb"
18+
]
19+
},
20+
"source": "JavaRanch Cattle Drive, exercise 3",
21+
"source_url": "http://www.javaranch.com/leap.jsp"
22+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[6466b30d-519c-438e-935d-388224ab5223]
13+
description = "year not divisible by 4 in common year"
14+
15+
[ac227e82-ee82-4a09-9eb6-4f84331ffdb0]
16+
description = "year divisible by 2, not divisible by 4 in common year"
17+
18+
[4fe9b84c-8e65-489e-970b-856d60b8b78e]
19+
description = "year divisible by 4, not divisible by 100 in leap year"
20+
21+
[7fc6aed7-e63c-48f5-ae05-5fe182f60a5d]
22+
description = "year divisible by 4 and 5 is still a leap year"
23+
24+
[78a7848f-9667-4192-ae53-87b30c9a02dd]
25+
description = "year divisible by 100, not divisible by 400 in common year"
26+
27+
[9d70f938-537c-40a6-ba19-f50739ce8bac]
28+
description = "year divisible by 100 but not by 3 is still not a leap year"
29+
30+
[42ee56ad-d3e6-48f1-8e3f-c84078d916fc]
31+
description = "year divisible by 400 is leap year"
32+
33+
[57902c77-6fe9-40de-8302-587b5c27121e]
34+
description = "year divisible by 400 but not by 125 is still a leap year"
35+
36+
[c30331f6-f9f6-4881-ad38-8ca8c12520c1]
37+
description = "year divisible by 200, not divisible by 400 in common year"

0 commit comments

Comments
 (0)