mirror of
https://github.com/unclebob/crapper.git
synced 2026-11-26 18:18:49 +00:00
Keep unit file ids when a Swift function omits filenames.
A function that lists filenames still resolves region[5] in that list, so a list ordered differently from unit["files"] stays on the right file. A report that omits the array, including mutator's fixtures, keeps the unit file list. Proved by the empty-filenames and missing-filenames tests, 226 pytest tests, mutator 125 passed and 1 skipped, crapper worst CRAP 9.0, dryer clean on coverage.py at 0.8, and mutator on coverage.py: 239 killed, 0 survived, 0 uncovered. Co-authored-by: Robert C. Martin <[email protected]>
This commit is contained in:
co-authored by
Robert C. Martin
parent
5c023a3e7e
commit
25d681296a
+10
-4
@@ -360,7 +360,7 @@ def test_a_function_region_follows_that_functions_filenames():
|
||||
assert not entry.line_covered(5)
|
||||
|
||||
|
||||
def test_a_region_with_no_function_filenames_is_not_placed_by_unit_index():
|
||||
def test_a_region_without_function_filenames_uses_the_unit_file_list():
|
||||
text = json.dumps(
|
||||
{
|
||||
"type": "llvm.coverage.json.export",
|
||||
@@ -370,14 +370,20 @@ def test_a_region_with_no_function_filenames_is_not_placed_by_unit_index():
|
||||
{"filename": "First.swift"},
|
||||
{"filename": "Second.swift"},
|
||||
],
|
||||
"functions": [{"regions": [[4, 1, 5, 1, 1, 0, 0, 0]]}],
|
||||
"functions": [
|
||||
{"regions": [[4, 1, 5, 1, 1, 0, 0, 0]]},
|
||||
{"filenames": [], "regions": [[1, 1, 1, 2, 1, 1, 0, 0]]},
|
||||
],
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
files = parse_swift_coverage(text)
|
||||
assert not files["First.swift"].line_covered(4)
|
||||
assert not files["First.swift"].line_covered(5)
|
||||
assert files["First.swift"].line_covered(4)
|
||||
assert files["First.swift"].line_covered(5)
|
||||
assert not files["First.swift"].line_covered(1)
|
||||
assert files["Second.swift"].regions == [(1, 1, 1)]
|
||||
assert files["Second.swift"].line_covered(1)
|
||||
assert not files["Second.swift"].line_covered(5)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user