Skip to content

Commit 26457a1

Browse files
authored
Fixed Issue #15 (#19)
Improved the pattern match in run.sh to detect and suppress odin test runner additional information on how to only run failed tests.
1 parent 73afc61 commit 26457a1

File tree

4 files changed

+117
-1
lines changed

4 files changed

+117
-1
lines changed

bin/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ run_tests() {
5353
# remove text that can change from run to run, or from system to system.
5454
sanitize_odin_test_output() {
5555
gawk -v pwd="${PWD}/" '
56-
/To run only the failed test,/ {exit}
56+
/To run only the failed tests?,/ {exit}
5757
/Finished [[:digit:]]+ tests? in / { sub(/ in [[:digit:].]+.s/, "") }
5858
{
5959
gsub(pwd, "") # trim full paths from filenames
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"version": 3,
3+
"status": "fail",
4+
"tests": [
5+
{
6+
"name": "year not divisible by 4 in common year",
7+
"status": "pass",
8+
"test_code": "testing.expect(t, !is_leap_year(2015))"
9+
},
10+
{
11+
"name": "year divisible by 2, not divisible by 4 in common year",
12+
"status": "pass",
13+
"test_code": "testing.expect(t, !is_leap_year(1970))"
14+
},
15+
{
16+
"name": "year divisible by 4, not divisible by 100 in leap year",
17+
"status": "pass",
18+
"test_code": "testing.expect(t, is_leap_year(1996))"
19+
},
20+
{
21+
"name": "year divisible by 4 and 5 is still a leap year",
22+
"status": "pass",
23+
"test_code": "testing.expect(t, is_leap_year(1960))"
24+
},
25+
{
26+
"name": "year divisible by 100, not divisible by 400 in common year",
27+
"message": "expected !is_leap_year(2100) to be true",
28+
"status": "fail",
29+
"test_code": "testing.expect(t, !is_leap_year(2100))"
30+
},
31+
{
32+
"name": "year divisible by 100 but not by 3 is still not a leap year",
33+
"message": "expected !is_leap_year(1900) to be true",
34+
"status": "fail",
35+
"test_code": "testing.expect(t, !is_leap_year(1900))"
36+
},
37+
{
38+
"name": "year divisible by 400 is leap year",
39+
"status": "pass",
40+
"test_code": "testing.expect(t, is_leap_year(2000))"
41+
},
42+
{
43+
"name": "year divisible by 400 but not by 125 is still a leap year",
44+
"status": "pass",
45+
"test_code": "testing.expect(t, is_leap_year(2400))"
46+
},
47+
{
48+
"name": "year divisible by 200, not divisible by 400 in common year",
49+
"message": "expected !is_leap_year(1800) to be true",
50+
"status": "fail",
51+
"test_code": "testing.expect(t, !is_leap_year(1800))"
52+
}
53+
]
54+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package multi_test_failures
2+
3+
is_leap_year :: proc(year: int) -> bool {
4+
return year % 400 == 0 || year % 4 == 0 && year % 100 != 1
5+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package multi_test_failures
2+
3+
import "core:testing"
4+
5+
@(test)
6+
/// description = year not divisible by 4 in common year
7+
test_year_not_divisible_by_4_in_common_year :: proc(t: ^testing.T) {
8+
testing.expect(t, !is_leap_year(2015))
9+
}
10+
11+
@(test)
12+
/// description = year divisible by 2, not divisible by 4 in common year
13+
test_year_divisible_by_2_not_divisible_by_4_in_common_year :: proc(t: ^testing.T) {
14+
testing.expect(t, !is_leap_year(1970))
15+
}
16+
17+
@(test)
18+
/// description = year divisible by 4, not divisible by 100 in leap year
19+
test_year_divisible_by_4_not_divisible_by_100_in_leap_year :: proc(t: ^testing.T) {
20+
testing.expect(t, is_leap_year(1996))
21+
}
22+
23+
@(test)
24+
/// description = year divisible by 4 and 5 is still a leap year
25+
test_year_divisible_by_4_and_5_is_still_a_leap_year :: proc(t: ^testing.T) {
26+
testing.expect(t, is_leap_year(1960))
27+
}
28+
29+
@(test)
30+
/// description = year divisible by 100, not divisible by 400 in common year
31+
test_year_divisible_by_100_not_divisible_by_400_in_common_year :: proc(t: ^testing.T) {
32+
testing.expect(t, !is_leap_year(2100))
33+
}
34+
35+
@(test)
36+
/// description = year divisible by 100 but not by 3 is still not a leap year
37+
test_year_divisible_by_100_but_not_by_3_is_still_not_a_leap_year :: proc(t: ^testing.T) {
38+
testing.expect(t, !is_leap_year(1900))
39+
}
40+
41+
@(test)
42+
/// description = year divisible by 400 is leap year
43+
test_year_divisible_by_400_is_leap_year :: proc(t: ^testing.T) {
44+
testing.expect(t, is_leap_year(2000))
45+
}
46+
47+
@(test)
48+
/// description = year divisible by 400 but not by 125 is still a leap year
49+
test_year_divisible_by_400_but_not_by_125_is_still_a_leap_year :: proc(t: ^testing.T) {
50+
testing.expect(t, is_leap_year(2400))
51+
}
52+
53+
@(test)
54+
/// description = year divisible by 200, not divisible by 400 in common year
55+
test_year_divisible_by_200_not_divisible_by_400_in_common_year :: proc(t: ^testing.T) {
56+
testing.expect(t, !is_leap_year(1800))
57+
}

0 commit comments

Comments
 (0)