Skip to content

Commit

Permalink
Update test framework to default to only show failures (#9986)
Browse files Browse the repository at this point in the history
* Update test framework to default to only show failures

* Fix
  • Loading branch information
AdRiley authored May 21, 2024
1 parent 3a3052d commit 3b59b40
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions distribution/lib/Standard/Test/0.0.0-dev/src/Suite.enso
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ type Suite
pending_groups = matching_specs.filter (p-> p.first.is_pending) . length
case should_exit of
True ->
IO.println ""
IO.println <| succ_tests.to_text + " tests succeeded."
IO.println <| failed_tests.to_text + " tests failed."
IO.println <| skipped_tests.to_text + " tests skipped."
IO.println <| pending_groups.to_text + " groups skipped."
IO.println ""
exit_code = if failed_tests > 0 then 1 else 0
System.exit exit_code
False ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type Suite_Config
## Creates an Suite_Config based off environment and caller location
from_environment : Suite_Config
from_environment =
print_only_failures = Environment.get "REPORT_ONLY_FAILED" != Nothing
print_only_failures = Environment.get "REPORT_ALL_TESTS" . is_nothing
junit_folder = Environment.get "ENSO_TEST_JUNIT_DIR"
use_ansi_colors = Environment.get "ENSO_TEST_ANSI_COLORS" . is_nothing . not
caller_script = find_caller_script Runtime.get_stack_trace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,16 @@ print_single_result (test_result : Test_Result) (config : Suite_Config) =
txt = " - " + test_result.spec_name + " " + times_suffix
IO.println (maybe_green_text txt config)
Spec_Result.Failure msg details ->
IO.println ""
txt = " - [FAILED] " + test_result.spec_name + " " + times_suffix
IO.println (maybe_red_text txt config)
IO.println (" Reason: " + msg)
if details.is_nothing.not then
IO.println (decorate_stack_trace details)
IO.println ""
Spec_Result.Pending reason ->
if config.print_only_failures.not then
IO.println (maybe_grey_text (" - [PENDING] " + test_result.spec_name) config)
IO.println (" Reason: " + reason)
IO.println (maybe_grey_text (" - [PENDING] " + test_result.spec_name) config)
IO.println (" Reason: " + reason)


## Prints all the results, optionally writing them to a jUnit XML output.
Expand Down Expand Up @@ -156,7 +157,7 @@ print_group_report group_name test_results config builder =
builder.append ' </testcase>\n'
builder.append ' </testsuite>\n'

should_print_behavior = config.print_only_failures.not || test_results.any (r -> r.is_fail)
should_print_behavior = config.print_only_failures.not || test_results.any (r -> r.is_fail) || test_results.any (r -> r.is_pending)
if should_print_behavior then
tests_succeeded = test_results.fold 0 acc-> res->
if res.is_success then acc + 1 else acc
Expand Down

0 comments on commit 3b59b40

Please sign in to comment.