File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55- Fix echo does not break test execution results
66- Add bashunit facade to enable custom assertions
77- Document how to verify the ` sha256sum ` of the final executable
8- - Enable display execution time on MacOS with ` SHOW_EXECUTION_TIME `
8+ - Enable display execution time on macOS with ` SHOW_EXECUTION_TIME `
9+ - Support for displaying the clock without ` perl ` (for non-macOS)
910- Add ` -l|--log-junit <log.xml> ` option
1011- Add ` -r|--report-html <report.html> ` option
1112
Original file line number Diff line number Diff line change 11#! /bin/bash
22
33function clock::now() {
4- perl -MTime::HiRes -e ' printf("%.0f\n",Time::HiRes::time()*1000)'
4+ if perl --version > /dev/null 2>&1 ; then
5+ perl -MTime::HiRes -e ' printf("%.0f\n",Time::HiRes::time()*1000)'
6+ elif [[ " $_OS " != " OSX" ]]; then
7+ date +%s%N
8+ else
9+ echo " "
10+ fi
511}
612
713_START_TIME=$( clock::now)
814
915function clock::runtime_in_milliseconds() {
10- echo $(( $(clock:: now) - _START_TIME ))
16+ end_time=$( clock::now)
17+ if [[ -n $end_time ]]; then
18+ echo $(( end_time - _START_TIME ))
19+ else
20+ echo " "
21+ fi
1122}
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ __ORIGINAL_OS=" "
4+
5+ function set_up_before_script() {
6+ __ORIGINAL_OS=$_OS
7+ }
8+
9+ function tear_down_after_script() {
10+ export _OS=$__ORIGINAL_OS
11+ }
12+
13+ function mock_non_existing_fn() {
14+ return 127;
15+ }
16+
17+ function test_now_with_perl() {
18+ mock perl echo " 1720705883457"
19+
20+ assert_equals " 1720705883457" " $( clock::now) "
21+ }
22+
23+ function test_now_on_linux_without_perl() {
24+ export _OS=" Linux"
25+ mock perl mock_non_existing_fn
26+ mock date echo " 1720705883457"
27+
28+ assert_equals " 1720705883457" " $( clock::now) "
29+ }
30+ function test_now_on_windows_without_perl() {
31+ export _OS=" Windows"
32+ mock perl mock_non_existing_fn
33+ mock date echo " 1720705883457"
34+
35+ assert_equals " 1720705883457" " $( clock::now) "
36+ }
37+
38+ function test_now_on_osx_without_perl() {
39+ export _OS=" OSX"
40+ mock perl mock_non_existing_fn
41+
42+ assert_equals " " " $( clock::now) "
43+ }
44+
45+ function test_runtime_in_milliseconds_when_not_empty_time() {
46+ mock perl echo " 1720705883457"
47+
48+ assert_not_empty " $( clock::runtime_in_milliseconds) "
49+ }
50+
51+ function test_runtime_in_milliseconds_when_empty_time() {
52+ export _OS=" OSX"
53+ mock perl mock_non_existing_fn
54+
55+ assert_empty " $( clock::runtime_in_milliseconds) "
56+ }
Original file line number Diff line number Diff line change @@ -266,11 +266,6 @@ function test_total_asserts_is_the_sum_of_passed_skipped_incomplete_snapshot_and
266266}
267267
268268function test_render_execution_time() {
269- if [[ $_OS == " OSX" ]]; then
270- skip " Skipping in OSX"
271- return
272- fi
273-
274269 local render_result
275270 render_result=$(
276271 # shellcheck disable=SC2034
@@ -282,11 +277,6 @@ function test_render_execution_time() {
282277}
283278
284279function test_not_render_execution_time() {
285- if [[ $_OS == " OSX" ]]; then
286- skip " Skipping in OSX"
287- return
288- fi
289-
290280 local render_result
291281 render_result=$(
292282 # shellcheck disable=SC2034
You can’t perform that action at this time.
0 commit comments