You are viewing a plain text version of this content. The canonical link for it is here.
Posted to nmaven-commits@incubator.apache.org by si...@apache.org on 2008/02/07 19:41:21 UTC
svn commit: r619597 -
/incubator/nmaven/trunk/plugins/maven-dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java
Author: sisbell
Date: Thu Feb 7 11:41:19 2008
New Revision: 619597
URL: http://svn.apache.org/viewvc?rev=619597&view=rev
Log:
Test mojo can now accept vendor tag.
Modified:
incubator/nmaven/trunk/plugins/maven-dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java
Modified: incubator/nmaven/trunk/plugins/maven-dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java?rev=619597&r1=619596&r2=619597&view=diff
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java (original)
+++ incubator/nmaven/trunk/plugins/maven-dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java Thu Feb 7 11:41:19 2008
@@ -28,6 +28,7 @@
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.dotnet.BuildDirectories;
+import org.apache.maven.dotnet.Vendor;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
@@ -35,7 +36,7 @@
/**
* Maven Mojo for executing nunit tests
- *
+ *
* @goal test
* @phase test
* @description Maven Mojo for executing nunit tests
@@ -47,22 +48,28 @@
// TODO: This probably only works on Windows machines
private static final String COMMAND_NOT_FOUND_FRAGMENT = "is not recognized as an internal or external command";
- private static final String NUNIT_EXECUTABLE = "nunit-console";
-
/**
* The maven project.
- *
+ *
* @parameter expression="${project}"
* @required
*/
private MavenProject project;
-
+
/**
* The arguments to pass to nunit
+ *
* @parameter
*/
private List<String> arguments;
+ /**
+ * The Vendor.
+ *
+ * @parameter expression="${vendor}"
+ */
+ private String vendorName;
+
public void execute()
throws MojoExecutionException, MojoFailureException
{
@@ -72,14 +79,24 @@
getLog().info( "Skipping Test Execution" );
return;
}
-
+
// Verify that we have tests to run
File testAssembly = new File( project.getBuild().getDirectory(), getTestAssemblyName() );
if ( !testAssembly.exists() )
{
return;
}
-
+
+ Vendor vendor;
+ if ( vendorName != null )
+ {
+ vendor = Vendor.valueOf( vendorName.toUpperCase() );
+ }
+ else
+ {
+ vendor = Vendor.getDefaultVendorForOS();
+ }
+
// The directory where the test artifact exists
File testAssemblies =
new File( project.getBuild().getDirectory(), BuildDirectories.TEST_ASSEMBLIES.getBuildDirectoryName() );
@@ -89,21 +106,31 @@
getLog().debug( "NMaven-test: workingDirectory(" + testAssemblies.getAbsolutePath() + ")" );
commandline.setWorkingDirectory( testAssemblies.getAbsolutePath() );
- commandline.setExecutable( NUNIT_EXECUTABLE );
+ if ( vendor.equals( Vendor.MICROSOFT ) )
+ {
+ commandline.setExecutable( "nunit-console" );
+ }
+ else if ( vendor.equals( Vendor.NOVELL ) )
+ {
+ commandline.setExecutable( "nunit-console2" );
+ }
+ else
+ {
+ throw new MojoExecutionException("Vendor not found.");
+ }
commandline.addArguments( getNUnitArguments() );
NUnitStreamConsumer systemOut = new NUnitStreamConsumer( getLog() );
NUnitStreamConsumer systemErr = new NUnitStreamConsumer( getLog() );
- int commandLineResult = -999;
-
+ int commandLineResult;
+
try
{
// Execute the commandline
- commandLineResult =
- CommandLineUtils.executeCommandLine( commandline, systemOut, systemErr );
-
- getLog().debug( "Executed command: " + commandline + ", Result = " + commandLineResult);
+ commandLineResult = CommandLineUtils.executeCommandLine( commandline, systemOut, systemErr );
+
+ getLog().debug( "Executed command: " + commandline + ", Result = " + commandLineResult );
// Check if nunit-console is not in the path
if ( systemErr.isCommandNotFound() )
@@ -120,7 +147,6 @@
throw new MojoExecutionException( "Failure executing commandline, " + e.getMessage() );
}
-
getLog().info( "Done executing tests.." );
}
@@ -132,15 +158,17 @@
return testAssemblyName;
}
-
- private String[] getNUnitArguments() {
+
+ private String[] getNUnitArguments()
+ {
List<String> nunitArgs = new ArrayList<String>();
-
+
nunitArgs.add( getTestAssemblyName() );
- if (arguments != null) {
+ if ( arguments != null )
+ {
nunitArgs.addAll( arguments );
}
-
+
return nunitArgs.toArray( new String[0] );
}