diff --git a/lib/julia_adapter.rb b/lib/julia_adapter.rb index 16dfcd3e..2616463c 100644 --- a/lib/julia_adapter.rb +++ b/lib/julia_adapter.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class JuliaAdapter < TestingFrameworkAdapter - COUNT_REGEXP = /(?[^|\s]*)\s+\|\s+(?\d+)\s+(?>(?\d+)\s+)?(?\d+)\s+(?\d+\.\d+)s/ + TEST_OUTPUT_REGEXP = /Test Summary:\s+\|\s+(?.*)\n(?[^|]*)\s+\|\s+(?.*)/ + TEST_STATS_REGEXP = /(?[^|\s]+)/ ASSERTION_ERROR_REGEXP = /(?[^:]*): (?.*?) at (?[^:]*):(?\d+)\s*(?.*?)\s*Stacktrace:/m LOAD_ERROR_REGEXP = /ERROR: LoadError: (?.*?)\s*Stacktrace:/m def self.framework_name @@ -17,11 +18,24 @@ class JuliaAdapter < TestingFrameworkAdapter end def parse_test_results(output) - test_lines = output.to_enum(:scan, COUNT_REGEXP).map { Regexp.last_match } || [{}] - test_result = test_lines.last + test_lines = output.to_enum(:scan, TEST_OUTPUT_REGEXP).map { Regexp.last_match } || [{}] + test_output = test_lines.last - passed = test_result[:pass].try(:to_i) || 0 - count = test_result[:total].try(:to_i) || 0 + test_keys_match = test_output[:test_stat_keys].to_s.to_enum(:scan, TEST_STATS_REGEXP).map { Regexp.last_match } || [] + test_values_match = test_output[:test_stat_values].to_enum(:scan, TEST_STATS_REGEXP).map { Regexp.last_match } || [] + + test_keys = test_keys_match.map(&:to_s) + test_values = test_values_match.map(&:to_s) + + # Final variables to be used for further processing: + _test_set = test_output[:testset] + test_result = test_keys.zip(test_values).to_h + + # Expected entries in `test_result` are: Pass, Fail, Error, Broken, Total, Time + # See https://github.com/JuliaLang/julia/blob/ebe1a37af57cb472101d6ede43329ea5ef2e0138/stdlib/Test/src/Test.jl#L1163-L1180 + + passed = test_result['Pass'].try(:to_i) || 0 + count = test_result['Total'].try(:to_i) || 0 failed = test_result[:fail].try(:to_i) || (count - passed) || 0 if failed.zero? {count:, passed: count}