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

Surefire 1593 #199

Closed
wants to merge 5 commits into from
Closed

Surefire 1593 #199

wants to merge 5 commits into from

Conversation

Tibor17
Copy link
Contributor

@Tibor17 Tibor17 commented Nov 10, 2018

No description provided.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Well done.
I left a comment

String uri = toClasspathElementUri( parent, classPathElement, dumpLogDirectory );
cp.append( uri );
if ( classPathElement.isDirectory() && !uri.endsWith( "/" ) )
if ( new File( classPathElement ).isDirectory() && !uri.endsWith( "/" ) )
Copy link
Contributor

Choose a reason for hiding this comment

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

Files.isDirectory will be more consistent with the new use of Paths.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eolivelli
yes, and moreover we should change the method signature from this:
toClasspathElementUri( String parent, String classPathElement, File dumpLogDirectory )
to this:
toClasspathElementUri( Path parent, Path classPathElement, Path dumpLogDirectory )
Which requires calling dumpLogDir.toPath() in ForkStarter (Line 580) but pls do not go deeper changing File to Path in all project since it is not a matter of this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be nice to have Path parent created once before the loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the scope of this change which is about using Paths it seemed to me strange to add a line which is using the legacy API.
Btw the result will be correct

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 am totally with you. Let's wait for @jglick until he makes all changes.
off-topic: We have one JUnit5 issue and some easy issues to fix. I guess we can release a new release candidate next week,

Copy link

Choose a reason for hiding this comment

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

we should change the method signature

No, I deliberately used String parameters so as to make it possible to write unit tests. Paths can (as far as I know) only be constructed using platform-specific methods, making the tests behave differently according to the machine running them.

Copy link

Choose a reason for hiding this comment

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

Files.isDirectory will be more consistent with the new use of Paths.

I chose to make a more minimal change to solve the immediate regression, rather than rewriting the whole class to use NIO methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thst's correct. The Strings are already platform specific.

.isEqualTo( "file" );

assertThat( testDirUri.getRawPath() )
.isEqualTo( testDir.toURI().getRawPath() );
Copy link

Choose a reason for hiding this comment

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

This will likely fail when run on Windows using a project directory that is a UNC path rather than a drive letter: just as File.toURL had numerous problems corrected only by File.toUri, so File.toUri has some problems corrected by Path.toUri.

I would suggest dropping shouldRelativizeOnRealPlatform and shouldMakeAbsoluteUriOnRealPlatform. If you want unit tests, that is what I originally wrote. If you want something more realistic, demonstrating that the result is what was intended, shouldMakeRelativeUriOnRealPlatform is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will use Path.toUri then, but I am wondering who wants to run Jenkins build on Surefire project that is located on shared network folder.

Copy link

Choose a reason for hiding this comment

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

I am wondering who wants to run Jenkins build on Surefire project that is located on shared network folder

\\vboxsvr\linux perhaps?

@PrepareForTest( { JarManifestForkConfiguration.class, InPluginProcessDumpSingleton.class } )
public class JarManifestForkConfigurationTest
{
private static final String BASE_DIR = System.getProperty( "user.dir" );
Copy link

Choose a reason for hiding this comment

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

This will pollute the CWD when mvn is run using -f rather than defaulting the basedir.

If you want a temporary directory, I would suggest using the TemporaryFolder rule.

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 are files for testing purposes in target folder. Here we run the build mvn install in the root and not in a child. Even if you run this particular test in IntelliJIDEA, the user.dir is maven-surefire-common/pom.xml, so I think it is fine for this test but we can create the temporal folders in TEMP if you like, this does not harm the goal of the test.

@jglick
Copy link

jglick commented Nov 13, 2018

Since I cannot edit the description or title, a note to viewers: this is an amendment of #198.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 14, 2018

@jglick
Now the tests use TMP and the code is as before, this means Path object is created once and the unit test stay as before, just only adopted to Path instead of String. All the test pass and your fix is used as intended.

Copy link

@jglick jglick left a comment

Choose a reason for hiding this comment

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

👍 assuming it indeed still passes on Windows.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 15, 2018

@jglick
Can we finalize this? Should I proceed or you want to take it to your PR?

Copy link

@jglick jglick left a comment

Choose a reason for hiding this comment

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

You are the maintainer, right? Go ahead.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 16, 2018

@jglick
Yes I am but we are here for you users, and the fix would not be possible without your efforts.
Thank you for your work. I will continue with squashing the commits and pushing to master.

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.

3 participants