You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit aebaca0
Browse filesBrowse the repository at this point in the historyBrowse files
A process whose tests run concurrently in threads drops its test map,
because per-test coverage cannot tell concurrent tests apart. That is
the right call for threaded `parallelize`, but `simplecov affected`
then said to enable `track_tests`, which was already on. A merge of
results only some of which recorded a map is in the same position.
The tracker now gives a reason when it drops its map. The result
carries it through `.resultset.json` and every merge, and
`coverage.json` records it as `contexts_dropped`. A merge that drops a
map for want of one in every result gives its own reason. `affected`,
`tests`, and `status` say the reason instead of pointing at
`track_tests`.
`contexts_dropped` is an optional key in schema 1.4, which is not yet
released.
Reported in
#1316 (comment)
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
17
17
18
18
- SimpleCov depends on the `prism` gem. Ruby 3.4 and 4.0 ship Prism as a default gem, so nothing new installs there, but Ruby 4.1 ships it as a bundled gem, which a bundle can load only when something in it depends on Prism. Without it, a project's bundle on Ruby 4.1 silently lost what needs Prism: static branch and method coverage for files the suite never loaded, telling a newly loaded file's load-time lines from its method bodies under `track_tests`, and narrowing `simplecov affected` to the changed methods. Prism still loads lazily, so a Ruby that cannot load it (JRuby on Windows) keeps working without those features.
19
19
- The HTML report keeps a test file's own loading apart from its tests. The tests panel lists the files whose loading ran a line under their own note, and a line only loading ran counts as covered outside tests in the source view and the file list, like other load-time code. See [#1316].
20
-
-`coverage.json` advances to schema 1.4, which changes no shape. It documents that a bare test file path in `contexts`, beside ids pointing into the same file, names that file's own loading rather than a test, now that `track_tests` records it. Schema 1.3 stays frozen for pinned consumers. See [#1316].
20
+
-`coverage.json` advances to schema 1.4. It adds the optional `contexts_dropped` string, saying why a run that tracked tests carries no `contexts`, and documents that a bare test file path in `contexts`, beside ids pointing into the same file, names that file's own loading rather than a test, now that `track_tests` records it. Schema 1.3 stays frozen for pinned consumers. See [#1316].
21
21
-`track_tests` credits a test file with what it runs while it loads, before any of its tests run, under the file's path with no line number (`spec/user_spec.rb`). Code a spec file runs to define its examples, like shared examples or helpers called in `describe` bodies, belonged to no test, so `simplecov affected` fell back to the full suite for a change to it. Files first loaded while a test file loads still belong to no test, and RSpec's `before(:suite)` hooks belong to no test either. `simplecov tests --redundant` never lists a test file's loading as a redundant test, and `simplecov status` does not count it as a recorded test. Watching files load, and parsing each file a test loads first with Prism, cost nothing measurable: on SimpleCov's own suite under Ruby 4.1 (6,172 examples, three runs each), `track_tests` adds 6% to the suite's CPU time, where it added 20% before this release's attribution changes. See [#1316].
22
22
- SimpleCov no longer warns on JRuby that coverage may be inaccurate without `--debug` (full-trace mode). JRuby's coverage no longer depends on it: SimpleCov's own suite on JRuby 10.0.7 reports every line identically with and without `--debug`, so the warning only told JRuby users to slow their test runs down for nothing.
23
23
- The HTML report is usable on phones. On narrow screens the theme toggles shrink to icons, a report with several groups picks them from a dropdown instead of a row of tabs, the file list drops its coverage bars and covered/total counts and wraps long paths, and the source view stacks its header. On small or short screens the source header and footer scroll away with the code instead of staying pinned. Below 960px wide the code font scales so 80 columns fit beside the line numbers and hit counts. See [#1312].
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
34
34
-`simplecov affected` falls back to the full suite when a changed statement outside any method ran only outside recorded tests, even if recorded tests ran other lines of the file, and names the changed line. A changed or added constant selected only the tests that ran the file's methods, leaving out tests that read the constant. Blank lines, comments, and added methods do not count, and a change to a heredoc's body counts through the statement that opens it. See [#1316].
35
35
-`track_tests` no longer credits a test with the lines a file ran as the test first loaded it. A file's class body, constants, and `def` lines run once on behalf of every later test, but the test that happened to load it was recorded as their only owner, so `simplecov affected` selected that one test for a change to them. The loading test is now credited only with the method body lines it ran, and the rest is left to no test, like a file loaded before the suite ran. See [#1316].
36
36
- A merge keeps the method and branch hits of a process that recorded no line hit for the file. A forked worker inherits the files its parent loaded with their counters cleared, and calling a method whose body shares its `def` line (a short endless method, for instance) then records a method hit and no line hit. The merge took that for a never-loaded file and dropped its hits in favor of the parent's zeroes, so methods the workers exercised were reported as uncovered. A file now counts as executed when any line, method, or branch arm was hit. See [#1310].
37
+
-`simplecov affected`, `simplecov tests`, and `simplecov status` say why a run that tracked tests recorded no test map, instead of telling you to enable `track_tests`, which was already on. A process whose tests ran concurrently in threads (Rails' threaded `parallelize`) drops its map, since per-test coverage cannot tell concurrent tests apart, and so does a merge of results only some of which recorded one. The reason is carried through the resultset into `coverage.json` as `contexts_dropped`. See [#1316].
37
38
-`track_tests` credits a test with a one-line method it called in a file it first loaded, such as `def odd? = (a || b) && c`. The loading test kept only method body lines, and a one-line method's body shares its `def` line, so the method was left to no test while a later test that called it claimed the line. A change to it then selected only that later test. The line is now the loading test's when it ran more often than loading the file accounts for. See [#1316].
38
39
- A later run under the same command name keeps the test map an earlier run recorded for the tests it did not run. Rerunning one test file, or running `simplecov affected --run`, replaced the whole map, so a later `simplecov affected` selected nothing for a change that only the other tests covered, and exited 0. A test recorded again replaces its earlier lines. An earlier test whose file is gone is dropped, and one that touched a source file changed since is credited with every line of that file, since its recorded line numbers no longer hold. See [#1316].
39
40
- The `strict` profile no longer makes JRuby warn that branch and method coverage are not supported. It enabled both on every engine, so `Coverage.start` was asked for criteria JRuby cannot measure. It now enables only the criteria the runtime supports and pins a 100% threshold for each of those.
0 commit comments