Repository navigation
Merged unclebob main back - #6
Merged
Merged
Conversation
Why: every Go run printed "No coverage data for <file>; its sites are uncovered". `go test -coverprofile` keys files by import path (`github.com/acme/tool/cmd/tool/main.go`); mutator looked them up by absolute disk path (`/.../tool/cmd/tool/main.go`). Neither path ends with the other, so no Go file ever matched and only --no-coverage ran sites. What: `_go_lines` asks crapper's `go_import_name` for the profile's name of the file (nearest go.mod module line plus path inside the module) and `_lookup` tries that name as an exact key, then the existing suffix match. Other languages pass no name and are unchanged. Needs crapper c757ec7 or later. Proof: two new specs (module at the root, module in a subdirectory with a different name) failed with None first, now pass; 78 pass. crapper: _go_lines 6.0, covered_lines 5.0, _lookup 4.0. dryer: no candidates. mutator on the changed lines: one equivalent survivor (insert(0) vs insert(1)) removed by appending the name; no survivors left.
Why: delete_tree walked the worker tree and called rmdir once. Gradle can still be flushing a test report then, so a directory that looked empty raises OSError [Errno 39] Directory not empty (or a file vanishes before unlink) and the whole mutation run aborts. What: delete_tree retries the walk, with injectable sleep and attempt count so tests do not wait. A vanished file is unlinked with missing_ok. Symlinks are still unlinked, never followed into the real project. Proof: six new tests (late file, vanished file, missing path, regular file, symlink left alone, exhausted retries re-raise). 78 tests were green before; 84 pass now. crapper: delete_tree 5.0, _delete_once 5.0, every function in workers.py under 10. dryer: no candidates. mutator on the nine changed sites: 9 killed, 0 survived, 0 uncovered.
Why: crapper.discover treats any test-named folder at any depth as a test path. That silently skipped production fixtures such as src/agnesse/slim/test/SymbolManagingTableTable.java, even when the file was named directly, because "test" appeared in the path. What: Mutator now walks the tree itself. A path relative to the project root is a test path when its first component is a TEST_DIRS name (test, tests, spec, specs, or __tests__), or when it sits under src/test or src/tests, the Maven and Gradle layout. SKIP_DIRS are still skipped at any depth. Filename-based test files are still detected by crapper.discover.is_test_file, applied to the filename so the any-depth directory check is not reused. crapper itself is unchanged. README and --help describe the new rule. Proof: 12 new tests in test_sources.py plus help assertions. 84 tests were green before; 96 pass now. crapper on the changed files: every new function is under 10 (iter_source_files 9.0, is_test_path 5.0, is_mutable_source 5.0); parse_args remains 30.2, the existing option-parser exception. dryer: no candidates. mutator on sources.py: 25 killed, 0 survived, 0 uncovered. Dry run against /tmp/agn at 58fd81c37: SymbolManagingTableTable.java is discovered along with 54 other files under src/agnesse/slim/test/; no files under test/ are.
Swift needs the same operator decisions as Java, plus the ?? fallback TypeScript already flips, and a negation of boolean conditions so guard is covered. A logical ! and a unary - are deleted; a force-unwrap is not. Statements and returns are not removed, because the other languages do not remove them either. private and fileprivate declarations use defn-/. A closure crapper does not report stays on the enclosing function, and a stored closure is its own entry, so the snapshot namespace matches .metrics/crap.edn. Proved by tests/test_swift.py. Those tests failed first: only true/false and 0/1 were sites, private funcs were defn/, and a run exited 0 because the comparison and the guard negation were missing. They pass, and the existing suite still passes (101 tests). Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
crapper treats Tests, AppTests, and *Tests.swift as tests, but mutator only asked is_test_file about the filename. That kept a file such as Tests/DemoTests/Board.swift, so a run would mutate the test suite. .build, .swiftpm, and DerivedData were already SKIP_DIRS. A Swift path is now a test path when a directory component ends with Tests, or the file name ends with Tests.swift. A deeper directory named test, the Java fixture layout, is still mutated. Proved by the source walk and by selecting Sources/Demo/Box.swift next to Tests/DemoTests/Board.swift and BoxTests.swift. The walk failed first because those three Tests paths were still chosen. Both tests pass. Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
A SwiftPM package is tested with swift test from the directory that holds Package.swift. An Xcode or iOS project is tested with xcodebuild test. The scheme is --xcode-scheme, otherwise the first shared scheme, otherwise the project name. --xcode-destination is one argument, so a simulator name with spaces is not split. A file inside a package is not also sent to xcodebuild. iOS still needs a Mac with Xcode; the command is only constructed here. Workers no longer link .build, .swiftpm, or DerivedData. A symlink would make swift test and xcodebuild write the real tree's build products, and parallel workers would share them. Proved by tests/test_swift.py. The command tests failed first because Swift returned false, xcode_destination was not a parameter, and a worker linked .build. A run with fake swift and xcodebuild on PATH then showed swift test and xcodebuild test -destination with the scheme. Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
llvm-cov JSON and xccov JSON land in target/coverage/swift. crapper turns those into regions or function summaries. A region with a hit marks that line covered. An xccov summary has no lines, so the function line is covered when the summary's covered count is above zero. A file missing from the report stays uncovered and is not run. Proved by tests/test_coverage.py, which failed first because a Swift file with a report still returned no lines, and by a scan that marks an unhit line uncovered. The reports are the same JSON shapes crapper reads; mutator does not parse them itself. Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
The README and --help now name Swift with the other languages, list the operators (including which edits are not made), and say how Tests, *Tests.swift, .build, .swiftpm, and DerivedData are skipped. They also give swift test, xcodebuild test, --xcode-scheme, and --xcode-destination, and say an iOS run needs a Mac with Xcode. Proved by the help test, which checks that --help names swift test, xcodebuild, and *Tests.swift. Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
Stopping a guard at else was the same as stopping at the following brace, and the binding flag started false only to be cleared by the keyword. Those edits survived because no test could see a difference, so the duplicate paths are gone. *Tests.swift stays crapper's filename rule; this check only adds Tests directories. A tiny package run with swift test records killed and survived on Demo.place and restores the source. The test skips when swift is not installed. The full suite, including that run on Swift 6.4.3, passed (115 tests). Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
xcodebuild was given the absolute path of the real project, and the worker only symlinked that bundle. The tool realpaths the project, so every mutant compiled the unmutated tree and survived. The command now names the project relative to the working directory, which the worker maps onto its overlay. The overlay copies an .xcodeproj or .xcworkspace instead of linking it, so realpath stays on the copy that holds the mutant. A file that only ends in .xcodeproj stays a link. Proved by a fake xcodebuild that realpaths the project and reads the Swift file the project names. The comparison and the negated condition are killed, and a constant survives. The same check uses a workspace. A baseline that exits 1 records no kills. The tests failed first on an absolute path, then on a symlink that escaped the worker. The suite passes (118 tests, and the SwiftPM run is skipped because swift is not installed). Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
A reader quote is a quoting_lit, so '(+ 1 0) was not covered by the (quote ...) test. The skip returned True there and the mutant survived. A + inside a vector is not a call, a symbol True is not a boolean, and the anchor of a Clojure site is its own line. _clojure_text repeated its type check with a child-count clause, and _is_head's final return never ran because the symbol is a child of its list. Both are gone. Proved by the Clojure site tests. mutator on src/mutator/sites.py then scored 66 killed, 0 survived, 0 uncovered. The suite passes (119 tests, and the SwiftPM run is skipped because swift is not installed). Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
Swift uses the same operator decisions as Java, plus ?? and negation of boolean conditions. swift test runs a package. xcodebuild runs an Xcode or iOS project from the working directory, and the worker keeps a real copy of the project so the mutant is what gets compiled. Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
crapper now reports a region as (start, end, count). The join still unpacked (line, count), so the Swift coverage tests crashed, and a mutation on the last line of a covered region was left uncovered. line_covered decides each line. A nested region with count zero stays uncovered, and a line in no region stays uncovered. An xccov summary is unchanged. The file-wide mutator run then found six older survivors in the path join. A trailing slash still marks the file, the first of two equal paths keeps its hits, and a shorter prefix beats a shorter suffix. Comparisons that could not change a result are gone. Proved by pytest (125 passed, 1 skipped; swift is not installed). crapper's worst score besides parse_args is _prepare_coverage at 9.4; _swift_hits is 6.0. dryer --threshold 0.8 reports no candidates. mutator on src/mutator/coverage.py killed 49, with 0 survived and 0 uncovered. Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
A covered llvm-cov region now marks every line from its start through its end. line_covered keeps a nested zero-count region uncovered. Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
actool does not follow a symlinked .xcassets, so the worker build fails with a missing AppIcon and a mutant that still compiles is reported killed. Copy the catalog, including resources that were themselves links, and keep linking other files. Proved by the worker overlay test and a stand-in xcodebuild that rejects a symlinked catalog. 127 passed, 1 skipped. Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
A worker that fails before any mutation was recording every mutant as killed. Run the tests once on the unmutated overlay and stop the way a failed baseline does. The tests also kill the mutants in the functions this change touches. Proved by a stand-in xcodebuild that fails only inside a worker, and by mutator on engine.py and workers.py: 140 killed, 0 survived, 0 uncovered. pytest: 139 passed, 1 skipped. Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
…logs-3072 Copy Xcode asset catalogs into workers and ignore a broken overlay. Co-authored-by: Robert C. Martin <unclebob@cleancoder.com>
Dart and Swift were added at the same insertion points. Kept both, and took main's shape where main changed code the Dart branch extended: - coverage.py: main's `_go_lines(root, ...)` call, with the dart branch kept beside the new swift branch. - sites.py: union of the operator parent sets; kept main's _SWIFT_CONDITIONS and _SWIFT_SKIP. - runner.py: main's xcode helpers and _swift_plan beside _dart_plan. Dart stays in _PLANS; swift stays special-cased in test_plan because it carries the scheme and destination. - functions.py: both privacy rules. - cli.py, pyproject.toml, README.md: both languages listed, with the README table rows kept contiguous and the Dart prose after the table.
Dart support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.