Skip to content

Commit

Permalink
Catch loading errors when tests are discovered. Allow loading to cont…
Browse files Browse the repository at this point in the history
…inue.
  • Loading branch information
thomthom committed Jan 4, 2024
1 parent 98ec03b commit 4ec864b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/testup/test_discoverer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ def discover_testcases(testsuite_path)
# Log.debug ">>>> Sandbox.load(...)"
testcase_source_files.each { |testcase_file|
# Log.debug ">>>> #{testcase_file}"
Sandbox.load(testcase_file)
begin
Sandbox.load(testcase_file)
rescue TestCaseLoadError => error
# TODO: Indicate in the UI that a test suite had loading errors.
testcase_name = File.basename(testcase_file, '.*')
warn "Failed to load test case: #{testcase_name} (#{testcase_file})"
warn error.original_error.inspect
warn error.original_error.backtrace.join("\n")
end
}
# Log.debug ">>>> Sandbox.test_classes(...)"
Log.trace :discover, ">>> test_cases: #{Sandbox.test_classes.size}"
Expand Down Expand Up @@ -125,9 +133,6 @@ def self.load(testcase_filename)
begin
Kernel.load testcase_filename
rescue ScriptError, StandardError => error
testcase_name = File.basename(testcase_filename, '.*')
warn "#{error.class} Loading #{testcase_name}"
warn self.format_load_backtrace(error)
raise TestCaseLoadError.new(error)
end
end
Expand Down

0 comments on commit 4ec864b

Please sign in to comment.