Skip to content

Commit

Permalink
Fail assumption when symlinks not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarg committed Aug 28, 2020
1 parent 2006d95 commit fbf7c32
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* under the License.
*/

import static org.junit.Assume.assumeTrue;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -155,6 +157,23 @@ public void assertFileExists( ArtifactItem item, boolean exist )
assertEquals( exist, file.exists() );
}

private static final boolean supportsSymbolicLinks = supportsSymbolicLinks();

private static boolean supportsSymbolicLinks( )
{
try {
Path target = Files.createTempFile(null, null);
Path link = Files.createTempFile(null, null);
Files.delete(link);
Files.createSymbolicLink(target, link);
Files.delete(link);
Files.delete(target);
return true;
} catch ( Exception e ) {
return false;
}
}

public void assertFilesAreLinks( Collection<ArtifactItem> items, boolean areLinks )
{
for ( ArtifactItem item : items )
Expand Down Expand Up @@ -268,6 +287,8 @@ public void testCopyToLocation()
public void testLink()
throws Exception
{
assumeTrue("supports symbolic links", supportsSymbolicLinks);

List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );

mojo.setArtifactItems( createArtifactItemArtifacts( list ) );
Expand Down

0 comments on commit fbf7c32

Please sign in to comment.