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

Revert breaking change when packing files and using forward slashes #4270

Merged
merged 2 commits into from
Sep 17, 2021

Conversation

jeffkl
Copy link
Contributor

@jeffkl jeffkl commented Sep 16, 2021

Bug

Fixes: NuGet/Home#11125

Regression? Yes Last working version: 5.9.1

Description

Our code has different behavior if you use a back slash versus a forward slash during pack. The feature to pack a README "fixed" this bug but regressed another.

I've created NuGet/Home#11234 to track the fact that the behavior is different and this PR includes a unit test to catch if we regress it again.

PR Checklist

  • PR has a meaningful title

  • PR has a linked issue.

  • Described changes

  • Tests

    • Automated tests added
    • OR
    • Test exception
    • OR
    • N/A
  • Documentation

    • Documentation PR or issue filled
    • OR
    • N/A

Copy link
Contributor

@aortiz-msft aortiz-msft left a comment

Choose a reason for hiding this comment

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

Approved for merging into Dev.

erdembayar
erdembayar approved these changes Sep 17, 2021
@jeffkl jeffkl force-pushed the dev-jeffkl-fix-unflattened-files-in-packagebuilder branch from 4ad7c20 to 57d0235 Compare September 17, 2021 18:25
@@ -6318,7 +6318,7 @@ public void PackCommand_PackReadme_DirSeparatorForwardSlash1_Succeeds()
TestPackReadmeSuccess(testDir, @"docs/readme.md");
}

[Fact]
[Fact(Skip = "https://github.com/NuGet/Home/issues/11234")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests are "broken" by this revert

[PlatformTheory(Platform.Windows)]
[InlineData(@"dir1\dir2\**", true, "Content")]
[InlineData("dir1/dir2/**", false, "Content")]
public void PackageBuilder_AddFiles_HasDifferentBehaviorDependingOnSlash(string source, bool expectFlattened, string destination)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test ensures the breaking change will be caught next time

{
new
{
Path = expectFlattened ? $"Content{Path.DirectorySeparatorChar}file1.txt" : $"Content{Path.DirectorySeparatorChar}dir1{Path.DirectorySeparatorChar}dir2{Path.DirectorySeparatorChar}file1.txt",
Copy link
Contributor

@donnie-msft donnie-msft Sep 17, 2021

Choose a reason for hiding this comment

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

Isn't this else dependent on knowing the input to the test? That seems like not a "best practice".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah its how I designed the test, I pass in a path with / and expect the files to be flattened and then paths with \ and expect them to not be flattened. I could do two separate tests but I foresee us fixing this "bug" and making them return the same things so this test would be updated to remove these ternary operators. Do you think there's a better way to accomplish this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm not fully thinking about it, but I would think you'd pass in both the unflattened string and the flattened string to the test, that way you assert the 2 test inputs match after running through the method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to merge it as-is for now, but I will update it later. It used to need to run on all platforms which is why I tried to make it so dynamic. But it ended up only needing to be run on Windows so it could be made to have a constant value for expected. I'll just make that change when this whole feature is fixed.

@jeffkl jeffkl merged commit ad07362 into dev Sep 17, 2021
@jeffkl jeffkl deleted the dev-jeffkl-fix-unflattened-files-in-packagebuilder branch September 17, 2021 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants