Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate path separator duplicates #10646

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

philderbeast
Copy link
Collaborator

@philderbeast philderbeast commented Dec 17, 2024

Fixes #10645, a small Windows gotcha missed with #10546.

I really had to get into the weeds with this one. The assertOutputContains function was modifying the output (a test actual value) before comparision with the unmodified actual value. This change was not visible. I've added an assertOn function (that assertOutputContains calls) that takes a NeedleHaystack configuration for how the search, expectation and display are made. I had wanted to add a pilcrow for line endings but the terminal output is restricted to ASCII so I've marked line beginnings with ^ and line endings with $. The needle (the expected output fragment) is shown annotated this way as can the haystack (the output). The haystack is not shown annotated with line delimiters but can be.

The concatOutput function, I've renamed to lineBreaksToSpaces. There's more detail on the cabal-testsuite changes in the changelog entry. One benefit of using an .md extension for changelog.d/pr-10646.md is that typos are caught by CI.


@philderbeast philderbeast changed the title Configuration from message path separator duplicates Deduplicate path separator duplicates Dec 17, 2024
@philderbeast philderbeast force-pushed the fix/path-sep-duplicates branch from 2d03f00 to 53fd7b0 Compare December 17, 2024 17:02
Copy link
Collaborator

@geekosaur geekosaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused: is the .md file a GitHub artifact, or did you really add two changelog.d entries?

@philderbeast philderbeast force-pushed the fix/path-sep-duplicates branch from 53fd7b0 to ca61a07 Compare December 17, 2024 17:13
@philderbeast
Copy link
Collaborator Author

I'm confused: is the .md file a GitHub artifact, or did you really add two changelog.d entries?

Thanks for catching that mistake of mine @geekosaur. I let the .md slip in. I rename locally to check the markdown preview. I've deleted that extra file now.

Can we use a .md extension for changelog.d entries?

@geekosaur
Copy link
Collaborator

geekosaur commented Dec 17, 2024

changelog-d doesn't care; the only special name is config, where its own configuration is stored, and you can't use subdirectories. It might even be better to use the extension, since that way GitHub will also render it (although it will probably be confused by the YAML frontmatter).

@philderbeast philderbeast marked this pull request as draft December 18, 2024 11:07
@philderbeast
Copy link
Collaborator Author

Reverting to draft while I settle some Windows versus POSIX file path issues.

@philderbeast philderbeast force-pushed the fix/path-sep-duplicates branch 19 times, most recently from bfda13a to 14850de Compare December 24, 2024 02:53
@philderbeast philderbeast marked this pull request as ready for review December 24, 2024 03:25
cabal-testsuite/src/Test/Cabal/NeedleHaystack.hs Outdated Show resolved Hide resolved
cabal-testsuite/src/Test/Cabal/NeedleHaystack.hs Outdated Show resolved Hide resolved
cabal-testsuite/src/Test/Cabal/Prelude.hs Outdated Show resolved Hide resolved
changelog.d/pr-10646.md Outdated Show resolved Hide resolved
@philderbeast philderbeast force-pushed the fix/path-sep-duplicates branch 2 times, most recently from 4a8c795 to ead2ec4 Compare December 30, 2024 18:00
Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a tricky one, but the tests make it easier for the reviewer to trust the solution without spending hours to get a deep understanding. The PR will be a good test of our tools and the process. I think it would be great to also include this great write-up from the changelog in a Note or maybe in a test linked to by name from the code?

@philderbeast philderbeast force-pushed the fix/path-sep-duplicates branch from b638eac to 8cfe16c Compare December 31, 2024 17:26
@philderbeast
Copy link
Collaborator Author

@Mikolaj I've added a note [Multiline Needles] and referenced this from assertOn and assertOutputContains with pretty much the content from the changelog but converted to haddock format and without the doctest output that can be found elsewhere in cabal-testsuite/src/Test/Cabal/NeedleHaystack.hs.

@philderbeast philderbeast force-pushed the fix/path-sep-duplicates branch from 8cfe16c to c1122ef Compare December 31, 2024 17:30
@philderbeast
Copy link
Collaborator Author

That was a tricky one

Yes it was and I'll have to squash those ~70 commits before applying a merge label.

@philderbeast philderbeast force-pushed the fix/path-sep-duplicates branch 4 times, most recently from 24af359 to ed55098 Compare January 1, 2025 13:27
@philderbeast
Copy link
Collaborator Author

Label merge+no rebase is necessary when the pull request is from an organisation.

@mergify mergify bot added the ready and waiting Mergify is waiting out the cooldown period label Jan 1, 2025
- Manually replace path separators before anything else
- Use pathSeparator instead of literal char
- Use isPathSeparator predicate
@philderbeast philderbeast force-pushed the fix/path-sep-duplicates branch from ed55098 to 5d3c1a0 Compare January 3, 2025 10:53
- Add else.project test
- Use normalizeWindowsOutput
- Add a changelog entry
- Update expectation
- Use concatOutput on needle
- Include output
- Align lines
- Show modified output
- Apply concatOutput to the needle
- Show start and end of lines with ASCII ^ and $h
- Can't print pilcrow so use grep char for marking end of line
- Marking the start of line distinguishes "expected" intro from its content too, same for "output"
- Use \n in multiline string expectation
- Add NeedleHaystack
- Add expectNeedleInHaystack field to NeedleHaystack
- Remove 3 assert*Contains functions
- Add TxContains record
- Apply the txBwd transformations before display
- Add displayHaystack field
- Switch to using <EOL> as the marker
- Sort language pragmas
- Use ++ rather than cons with reversals
- Rerun ParseErrorProvenance test
- Add doctests for single line strings
- Read exected multiline string from file
- Use lineBreaksToSpaces
- Add module Test.Cabal.NeedleHaystack
- Redo ConditionalAndImport with multiline expectations
- Add test of string expectation start and end marking
- Rename encodeLf and decodeLfMarkLines
- Rename original concatOutput to lineBreaksToSpaces
- Add assertOutputContainsWrapped
- Use multiline and wrapped assertions
- DedupUsingConfigFromComplex multiline assertion
- Remove redundant tests that fail on Windows
- Use normalizeWindowsOutput in ConditionalAndImport
- Forward conversion applied twice by mistake
- Easier diff when assertOn follows assertOutputContains
- Add readVerbatimFile
- Have readVerbatimFile read contents strictly
- Add normalizePathSeparator
- Don't modify path separator for URIs
- Don't normalize path with anything URI-like
- Normalize expected output
- Rename to normalizePathSeparators
- Add an explicit export list to NeedleHaystack
- Drop unlines . lines added trailing newline
- Show example of normalizePathSeparators
- Use local unsnoc definition to avoid CPP
- Define local unlines
- Satisfy fix-whitespace
- Don't use <EOL>
- Rename to delimitLines
- Rename the changelog with *.md extension
- Add a section on cabal-testsuite changes
- Rename the function to readFileVerbatim
- Add to contributing and cabal-testsuite's readme
- Use setup for the noun
- Typo s/displaying/display
- Typo "can easier"
- Use unsnoc from Cabal-syntax Utils.Generic
- Add a note [Multiline Needles]
- Remove doctests available elsewhere
- Substitute encodeLf for concatOutput for assertOutputMatches
- Add oops.expect.txt
- Add cabal-missing-package.expect.txt
- Add hops.expect.txt
- Add DedupUsingConfigFromComplex/errors.expect.txt
- Add using configuration from to errors.expect.txt
@philderbeast philderbeast force-pushed the fix/path-sep-duplicates branch from 5539c23 to 32b820b Compare January 3, 2025 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-testsuite merge+no rebase ready and waiting Mergify is waiting out the cooldown period
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When using configuration from show duplicate paths
3 participants