-
-
Notifications
You must be signed in to change notification settings - Fork 732
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
Path segment bug (or test bug, choose your own adventure!) #718
Comments
@daveaglick Oh, interesting. I have to dig into the source code to answer this properly. |
@daveaglick The test is theoretically correct. The reason for prepending the slash is to be able to differentiate between an absolute path from a relative one when working only with the segments. There are no side effects from having the slash there, but it's not pretty and theoretically incorrect. I removed the part that appends the slash to see what was affected and 1500 tests failed 😄 Most of the tests fail because the Did you encounter a bug in Wyam because of this? [Theory]
[InlineData("Hello/World")]
[InlineData("./Hello/World/")]
public void Should_Return_Segments_Of_Path(string pathName)
{
// Given
var path = new TestingPath(pathName);
// When, Then
Assert.Equal(2, path.Segments.Length);
Assert.Equal("Hello", path.Segments[0]);
Assert.Equal("World", path.Segments[1]);
}
[Theory]
[InlineData("/Hello/World")]
[InlineData("/Hello/World/")]
public void Should_Return_Segments_Of_Path_And_Leave_Absolute_Directory_Separator_Intact(string pathName)
{
// Given
var path = new TestingPath(pathName);
// When, Then
Assert.Equal(2, path.Segments.Length);
Assert.Equal("/Hello", path.Segments[0]);
Assert.Equal("World", path.Segments[1]);
} |
Doh! It's never easy, is it.
Not at all - I was just copying over some tests and converting to NUnit when I noticed this one wasn't using the theory data. Figured it was an easy fix, but then the two tests failed and down the rabbit hole. PR incoming... |
BTW, for what it's worth I agree with the leading slash in the segments being theoretically incorrect. I had actually already removed it in my port. Given there's already a |
@daveaglick Yes, I agree. The IsRelative part should be enough and we will remove it as well eventually. Just want to be really sure we don't break anything first 😄 |
…path name, resolves cake-build#718
Found a bug in either the
Cake.Core.IO.Path
segments calculation or thePathTests.TheSegmentsProperty.Should_Return_Segments_Of_Path()
test.The test is a theory, but the data isn't used in the test - instead it uses a hardcoded path:
So that's obviously wrong. When you change the test to use
pathName
, "/Hello/World" and "/Hello/World/" fail because the segment logic looks like this:I.e., if the path starts with "/", then "/" is prepended to the first segment.
So either the test is wrong or the logic is wrong and it just wasn't showing up because the test was wrong. I can take care of it - just need guidance on what the intent is here. Which is correct, the test or the logic?
The text was updated successfully, but these errors were encountered: