From fad6f679b8f0971d660adab3d99d7f9c8cd42aac Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 19 Feb 2010 14:25:44 -0500 Subject: Modifications to support unit testing for native projects --- .../org/apache/maven/plugin/nar/NarTestMojo.java | 26 +++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java') diff --git a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java index bf5fc1b..e2cca51 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java @@ -74,22 +74,23 @@ public class NarTestMojo if ( test.shouldRun() ) { // NOTE should we use layout here ? - String extension = getOS().equals( OS.WINDOWS ) ? ".exe" : ""; - String name = - getTestTargetDirectory().getPath() + File.separator + "bin" + File.separator + getAOL() - + File.separator + test.getName() + extension; - if ( !new File( name ).exists() ) + String name = test.getName() + (getOS().equals( OS.WINDOWS ) ? ".exe" : ""); + File path = new File( getTestTargetDirectory(), "bin" ); + path = new File( path, getAOL().toString() ); + path = new File( path, name ); + if ( !path.exists() ) { - getLog().warn( "Skipping non-existing test " + name ); + getLog().warn( "Skipping non-existing test " + path ); return; } - getLog().info( "Running test " + name ); + + File workingDir = new File( getTestTargetDirectory(), "test-reports" ); + workingDir.mkdirs(); + getLog().info( "Running test " + name + " in " + workingDir ); - File workingDir = getMavenProject().getBasedir(); - getLog().info( " in " + workingDir ); List args = test.getArgs(); int result = - NarUtil.runCommand( name, (String[]) args.toArray( new String[args.size()] ), workingDir, + NarUtil.runCommand( path.toString(), (String[]) args.toArray( new String[args.size()] ), workingDir, generateEnvironment(), getLog() ); if ( result != 0 ) { @@ -129,11 +130,6 @@ public class NarTestMojo } } - protected final File getTestTargetDirectory() - { - return new File( getMavenProject().getBuild().getDirectory(), "test-nar" ); - } - private String[] generateEnvironment() throws MojoExecutionException, MojoFailureException { -- cgit v1.2.3