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

Change abbreviation characters #1

Merged
merged 1 commit into from
Oct 26, 2016

Conversation

mmitche
Copy link
Contributor

@mmitche mmitche commented Sep 23, 2016

While ... is valid in Windows, .NET does not recognize this as a valid path. As a result, tools like msbuild will fail. After abbreviation, change ... to --- to avoid issues

Also fix tests on Windows
Windows has \ as the path separator character, and a significantly shorter MAX_PATH. Set the cached path length long enough that a test that doesn't want the path to be shortened passes.
Also replace / with \ on Windows (and vice versa for non-Windows platforms) when comparing paths.

@olivergondza
Copy link
Member

While ... is valid in Windows, .NET does not recognize this as a valid path. As a result, tools like msbuild will fail. After abbreviation, change ... to --- to avoid issues

That is strange. Can you reference some tracked issue/description of the .NET limitation?

@@ -54,8 +63,11 @@ public void doNothingIfThereIsEnoughRoom() throws Exception {
FreeStyleProject p = f.createProject(FreeStyleProject.class, "and_a_project_in_it");
p.setAssignedNode(s);

// Not enough for anything.
setMaxPathLength(s, 4096);
Copy link
Member

Choose a reason for hiding this comment

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

In this test it should be set so it is enough - comment suggests the opposite. Are you suggesting it is not on Windows (and that is why we need this)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, comment should be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment needs to be updated

FreeStyleBuild b = p.scheduleBuild2(0).get();
assertThat(b.getWorkspace().getRemote(), equalTo(s.getRootPath() + "/workspace/" + p.getFullName()));
assertThat(b.getWorkspace().getRemote(), equalTo(formatPath(s.getRootPath() + "/workspace/" + p.getFullName())));
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed? If I am not mistaken, this is implemented as File.createTempFile("hudson", "test", base); that should be Windows friendly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests did not pass before on Windows because slash directions were getting mixed around.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AHh yeah I remember. it is plenty windows friendly either way. However it puts \ in the Windows paths and / in the unix paths. Which is why formatPath is needed (otherwise the string comparison fails)

Copy link
Member

Choose a reason for hiding this comment

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

I have fixed the / vs. \ issue differently on master.

return inputPath.replace("/", "\\");
}
else {
return inputPath.replace("\\", "/");
Copy link
Member

Choose a reason for hiding this comment

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

Backslash is a valid path character on unix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh okay. In that case we probably just want to replace the windows one. It is primarily just for consistency, otherwise you end up with lots of workspace paths like "foo\bar/baz/bop" which is harder to read

@mmitche
Copy link
Contributor Author

mmitche commented Oct 25, 2016

I work on the .NET team. I'll try to track down the source of this issue. I'm pretty sure it's fixed in .NET Core but has been a long standing issue in the standard .NET Framework.

@mmitche mmitche force-pushed the use-net-compat-path branch from 1920cb6 to 3fb964e Compare October 25, 2016 16:30
@mmitche
Copy link
Contributor Author

mmitche commented Oct 25, 2016

The issue with the formatPath are two things:

  1. We are comparing the path strings, so using / in the string doesn't work on Windows (it gets normalized)
  2. Somewhere in the test framework (or Jenkins), there are still places that / is being produced, so scoping formatPath to places where we are explicitly using / in the tests wasn't enough.

I'm tracking down the original issue of ... in .NET.

@mmitche
Copy link
Contributor Author

mmitche commented Oct 25, 2016

Alright, so I tracked it down. Appears it was an msbuild issue where they were using their own path normalization vs. the official ones (which work). However, the issue still stands in most versions of msbuild, and given that msbuild is a pretty common build tool invoked by Jenkins, I think the fix still stands.

It was fixed in the .NET Core version of msbuild here: dotnet/msbuild#632

@olivergondza
Copy link
Member

@mmitche, I do not mind putting it in, though please make the comment more specific so we know what tool is it, in what version it is fixed.

@mmitche mmitche force-pushed the use-net-compat-path branch from 3fb964e to 0c28784 Compare October 26, 2016 14:31
While ... is valid in Windows, MSbuild does not recognize this as a valid path.  After abbreviation, change ... to --- to avoid issues
@mmitche mmitche force-pushed the use-net-compat-path branch from 0c28784 to c0c3355 Compare October 26, 2016 14:39
@mmitche
Copy link
Contributor Author

mmitche commented Oct 26, 2016

Ahh didn't realize you had fixed the tests. Reverted that bit, updated the comment. Thanks!

@olivergondza olivergondza merged commit 936c369 into jenkinsci:master Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants