Repository navigation
Conversation
211681a to
b38a07a
Compare
|
The macOS That job does not pass Could you rerun that job? I only have pull permission. |
Sorry, a recent upgrade of Forge has caused some of the third-party tests to become flaky. I need to look into this problem more and determine how to handle it. In the meantime, please don't worry if one of the third-party tests fails. Thanks very much for this PR! It's clear that you've put a lot of thought into this. Also, having the example code makes your comments in #1834 much easier to intuit. I have a little bit of a reviewing backlog, so it may be a few weeks before I comment on it. Also, this PR is non-trivial, so it may require a few rounds of review. But please rest assured that I won't let it drop! |
|
@dzatona I would like to propose a design change and would like your thoughts. Rather than have a completely new option Note that there is already a Also, Is there some reason why this idea would not work or would be awkward? What do you think about this idea, generally? |
|
@smoelius Passing it alongside You asked whether it would be awkward. The one place I think it is: That is also why the comparison to On the name: If the shape is settled I will make the change; the word we can pick separately. |
You would prefer A reason I hesitate is that it suggests "the configuration file has changed" implies the output will be smaller. Currently, that is the case. But I worry that, in the future, Necessist might have a configuration that, when changed, could cause the output to grow. Here is a hypothetical (not something I really want to support). Currently, the database stores Mind you, if we added such a configuration in the future, we could change the flag name at the same time. Is there a I realize I said "filtered" in #1834, and I may be feature-creeping here a little bit. So if you would prefer |
|
@smoelius Agreed, let's use The direction worry does not attach to the word, I think:
I will rework the PR as |
b38a07a to
4396697
Compare
|
Reworked as discussed: the filtered view is now Plain
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
@dzatona I would like to request another architectural change.
So I would like to propose the following:
I think there is no way to set the current director of a To copy the fixtures, please use a Rust helper function rather than Please let me know if this idea is unclear or if you disagree with it. Also, if this is too large of an ask, please let me know. I could make these changes and push to your branch. |
|
@smoelius That makes sense, and it is not too large. I'll make the changes on this branch and rebase onto All the tests in Three points where I'll take the default below unless you prefer otherwise:
|
4396697 to
716100c
Compare
Thanks very much. I'll try to get back to this soon. |
| @@ -0,0 +1,472 @@ | |||
| //! Fixture copies for the cases in `tests/necessist_db_filtered`. | |||
There was a problem hiding this comment.
Nit: Please rename this directory to something that doesn't end in cases.
To me, *_cases sounds like the directory contains test cases.
|
|
||
| /// A project in which Necessist has already run | ||
| #[derive(Clone, Copy, Eq, PartialEq)] | ||
| enum Master { |
There was a problem hiding this comment.
I would prefer that this enum go away, and that string literals be used instead (e.g., "basic").
I think that will reduce cognitive load for future reviewers of this code. I think it will also make grepping for references to fixture directories easier.
| _ => {} | ||
| } | ||
|
|
||
| let stdout = cargo_bin_cmd!("necessist") |
There was a problem hiding this comment.
I probably didn't make my intentions clear, but I was imagining that the existing necessist invocation in the trycmd test would play the role of this one:
necessist/necessist/tests/trycmd.rs
Lines 33 to 36 in 2938263
In other words, for each test case that requires a necessist.db file (i.e., the present and filtered cases), the statement in the trycmd test would provide it.
Note that this may require:
- expanding that statement, e.g., to loop over multiple fixtures
- adding additional fixtures
To determine the fixtures in which to run necessist, you could use the CASES array.
If I understand correctly, the marker case does not fit this pattern cleanly. When looping over the fixtures, I think it would be fine to treat the marker case specially with an if statement.
Please tell me if this idea is not clear or if you think it would not work.
|
@smoelius Thanks, that is clear, and I think it will work. I'll have the existing invocation run Necessist in each fixture named in |
920fed6 to
1961bb2
Compare
|
@smoelius I've pushed the changes from your review, rebased onto |
I will. Thanks for your patience with this review, @dzatona. |
1961bb2 to
e2879fe
Compare
| text still matches what Necessist read at their span; the candidates are the ones \ | ||
| the framework finds in the paths given on the command line, or under the project \ | ||
| root when none is given, by the same file selection and ignore rules a normal run \ | ||
| uses, so naming fewer paths can hide more entries" |
There was a problem hiding this comment.
| uses, so naming fewer paths can hide more entries" | |
| help = "Restrict --dump to entries that are still removal candidates according to the current configuration file" |
There was a problem hiding this comment.
Oops. This was meant to be part of a larger review. I did plan to request this change, though.
For #1834. The filtered view is a modifier passed alongside
--dump.What it does
--filterednarrows what--dumpprints. It leaves out two kinds of entry: those whose span isno longer a removal candidate, and those whose recorded text no longer reads the same at that
span.
The candidate set comes from parsing, along the
--dump-candidatespath. That is what makes theconfiguration file apply: a stored row holds only a span, its text, an outcome, and a URL. It
carries no framework and no enclosing test, so the existing ignore and selection rules cannot be
replayed against it directly. Parsing produces them
already, and this intersects the result with the stored rows.
How an entry is decided
is_current_candidaterequires both halves:The candidate check is first for three reasons. It is the cheaper of the two. It keeps
source_textoff spans this parse did not produce. And computing a span's offsets asserts that ifthe text up to its end is all ASCII then so is the text up to its start -- automatic when the end
follows the start, but a span read back from the database can hold one where it does not.
The text comparison is not redundant with
Ok. An overlong column is clamped rather than rejected,so
source_textcan return anOkholding the wrong text; the comparison decides either way.What it prints
One note always, stating what the filter means and that the outcome shown is the recorded one, not
one re-established against the current source. A second note when entries were hidden, with the
count -- only entries that would otherwise have been printed are counted, so
--verbosechangesthe number. The existing
--verbosesuggestion appears only when it would actually add something.Why a modifier works here
The filtered view needs the parse, so it cannot return as early as
--dumpdoes.--dumpreturnsfrom
preparebeforebackend_for_framework, which is why it keeps working on a tree that doesnot parse and on one where no backend resolves. So there are two branches rather than one, and
they are spelled out rather than left to fall through:
The only change on the plain
--dumppath is the added&& !context.opts.filtered, which istrivially true when
--filteredis absent.Checking that plain
--dumpdid not changeSince that is the thing worth being sure about, I checked it by running rather than by reading. I
compared a
necessistbinary frommainat29382632, which has no--filteredat all, againstthis branch over eighteen
--dumpscenarios. Each pair used the same project and database; exit code and stderr matched exactly, and captured stdout matched inevery scenario. All eighteen agree.
They include the two cases the early return exists for -- a source file that no longer parses, and
a project with no resolvable backend -- as well as a missing database, deleted sources,
--verbose,--no-lines-or-columns, and each option--dumprefuses to be combined with.Options it cannot be combined with
--filteredrequires--dump; on its own it is rejected withwhich follows the shape of the existing
--writecheck. It appears in noincompatible!group,because as a modifier it inherits every restriction
--dumphas and repeating them would let thetwo drift apart. A test passes
--dump --filteredwith each option--dumpis incompatible withand asserts the existing message, so the inheritance is pinned rather than assumed.
After backend resolution and parsing succeed, a missing database uses the same message
--dumpalready prints:
sqlite::initis untouched --core/src/sqlite.rsis byte-identical tomain.The help text states the scope limitation: the view is limited to the files this invocation
parses, so naming fewer paths hides more entries.
What it does not do
It does not re-establish outcomes. A matching location and matching text do not make an old
outcome current -- the test may pass now for a different reason. The note says so; the flag cannot
check it without running the tests, which is the thing being avoided.
It relies on
source_textreturning an error rather than panicking on an out-of-range span, whichis in
mainas of 6fae088.Tests
40 trycmd cases in
necessist/tests/necessist_db_filtered, run after thenecessist_db_presentcases, plus three in
necessist_db_absentand two innecessist_db_present. Cases that need a modified fixture run in a copy attarget/necessist_db_filtered/<test-case>, made bynecessist/tests/fixture_copiesfrom a fixturein which the
trycmdtest has just run Necessist. Theycover rewritten spans and method calls, configured-out candidates, whitespace and case changes,
deleted and unparsable files, the hidden count with and without
--verbose,--no-lines-or-columns, the scope limitation, the inherited--dumprestrictions,--filteredwithout
--dump, and that no tests are run.check_toml_filescovers the new directory, andfixture_copies_match_tomlschecks that every copy has a case and every case a copy.Since this changes
necessist/tests/trycmd.rs, the snapshot of thenecessistend-to-end test,necessist/tests/end_to_end_tests/1/necessist.with_config.stdout, is regenerated withBLESS=1.