Skip to content

Commit

Permalink
Merge pull request #4 from appfolio/prevent-name-error-on-test-case-d…
Browse files Browse the repository at this point in the history
…ecode

Capture NameError when decoding test case name
  • Loading branch information
cjlarose authored Apr 7, 2019
2 parents a7d3072 + 86a5001 commit 28a1c97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/parallel_tests/fine_grain_test/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ def self.encode(test_case)
def self.decode(string)
suite, name = string.split(/ /, 2)
name = name.gsub("\\n", "\n").gsub("\\\\", "\\")
new(Object.module_eval("::#{suite}", __FILE__, __LINE__), name)
suite_object = begin
Object.module_eval("::#{suite}", __FILE__, __LINE__)
rescue NameError
nil
end
new(suite_object, name) if suite_object
end

def ==(other)
Expand Down
6 changes: 6 additions & 0 deletions test/parallel_tests/fine_grain_test/test_case_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def test_decode__should_handle_backslashes
assert_equal self.class, test_case.suite
assert_equal "hello\\there", test_case.name
end

def test_decode__should_return_nil_when_suite_is_not_defined
str = "ParallelTests::FineGrainTest::DoesNotExist hello\\\\there"

assert_nil TestCase.decode(str)
end
end
end
end

0 comments on commit 28a1c97

Please sign in to comment.