From nmaven-commits-return-660-apmail-incubator-nmaven-commits-archive=incubator.apache.org@incubator.apache.org Mon Dec 31 01:23:50 2007 Return-Path: Delivered-To: apmail-incubator-nmaven-commits-archive@locus.apache.org Received: (qmail 74029 invoked from network); 31 Dec 2007 01:23:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Dec 2007 01:23:50 -0000 Received: (qmail 35145 invoked by uid 500); 31 Dec 2007 01:23:38 -0000 Delivered-To: apmail-incubator-nmaven-commits-archive@incubator.apache.org Received: (qmail 35123 invoked by uid 500); 31 Dec 2007 01:23:38 -0000 Mailing-List: contact nmaven-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: nmaven-dev@incubator.apache.org Delivered-To: mailing list nmaven-commits@incubator.apache.org Received: (qmail 35113 invoked by uid 99); 31 Dec 2007 01:23:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Dec 2007 17:23:38 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 31 Dec 2007 01:23:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 45F4A1A984E; Sun, 30 Dec 2007 17:23:25 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r607643 - in /incubator/nmaven/trunk: core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/src/test/dotnet/ plugins/dotnet-test-plugin/ plugins/dotnet-test-plugin/src/main/java/org/ plugins/dotnet-test-plugin/s... Date: Mon, 31 Dec 2007 01:23:24 -0000 To: nmaven-commits@incubator.apache.org From: eworley@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071231012325.45F4A1A984E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: eworley Date: Sun Dec 30 17:23:20 2007 New Revision: 607643 URL: http://svn.apache.org/viewvc?rev=607643&view=rev Log: * Adding test lifecycle * Adding DotnetTestMojo * Added check for nunit-console not being on path * Adding basic nunit innvocation, with a few TODos left * Updating IT0007 to have a few tests in it for reporting Added: incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/ incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/ incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/ incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/ incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/ incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/ incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java Modified: incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/src/test/dotnet/It0007.cs incubator/nmaven/trunk/plugins/dotnet-test-plugin/pom.xml incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/resources/META-INF/plexus/components.xml Modified: incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/src/test/dotnet/It0007.cs URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/src/test/dotnet/It0007.cs?rev=607643&r1=607642&r2=607643&view=diff ============================================================================== --- incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/src/test/dotnet/It0007.cs (original) +++ incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/src/test/dotnet/It0007.cs Sun Dec 30 17:23:20 2007 @@ -6,8 +6,20 @@ [TestFixture] public class It0007 { [Test] - public void testSimple() { + public void testSimple1() { Assertion.AssertEquals(1, 1); + } + + [Test] + public void testSimple2() { + Assertion.AssertEquals(2, 2); + } + + [Test] + public void testTakesSomeTime() { + for (int i=0; i < 9999999; i++) { + Assertion.AssertEquals(i+1, i+1); + } } } } Modified: incubator/nmaven/trunk/plugins/dotnet-test-plugin/pom.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/dotnet-test-plugin/pom.xml?rev=607643&r1=607642&r2=607643&view=diff ============================================================================== --- incubator/nmaven/trunk/plugins/dotnet-test-plugin/pom.xml (original) +++ incubator/nmaven/trunk/plugins/dotnet-test-plugin/pom.xml Sun Dec 30 17:23:20 2007 @@ -25,18 +25,25 @@ 0.15-incubating-SNAPSHOT maven-dotnet-plugins + 4.0.0 org.apache.maven.dotnet.plugins dotnet-test-plugin maven-plugin dotnet-test-plugin Maven Plugin for .NET: Handles nunit test execution and reporting + org.codehaus.plexus plexus-utils + + org.apache.maven + maven-core + + nmaven-apache-site Added: incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java?rev=607643&view=auto ============================================================================== --- incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java (added) +++ incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java Sun Dec 30 17:23:20 2007 @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.dotnet.plugin.nunit; + + +import java.io.File; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.codehaus.plexus.util.cli.StreamConsumer; + +/** + * Maven Mojo for executing nunit tests + * + * @goal test + * @phase test + * @description Maven Mojo for executing nunit tests + */ +public class DotnetTestMojo + extends AbstractMojo +{ + // Used to determine if nunit-console is not on the path + // 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"; + + // Command, options, assembly + private static final String NUNIT_CALL_FMT = "%s %s %s"; + + private static final String NUNIT_EXECUTABLE = "nunit-console"; + private static final String NUNIT_OPTIONS = ""; +// private static final String NUNIT_OPTIONS = "/labels /nologo"; + + /** + * The maven project. + * + * @parameter expression="${project}" + * @required + */ + private MavenProject project; + + public void execute() + throws MojoExecutionException, MojoFailureException + { + // The directory where the test artifact exists + String outputDirectory = project.getBuild().getDirectory(); + + String innvocation = getNUnitInvocation(); + + Commandline commandline = new Commandline(); + + getLog().debug("NMaven-test: workingDirectory(" + outputDirectory + ")"); + + commandline.setWorkingDirectory(outputDirectory); + commandline.setExecutable(innvocation); + + NUnitStreamConsumer systemOut = new NUnitStreamConsumer(getLog()); + NUnitStreamConsumer systemErr = new NUnitStreamConsumer(getLog()); + + try + { + // Execute the commandline + CommandLineUtils.executeCommandLine(commandline, systemOut, systemErr); + + // Check if nunit-console is not in the path + if (systemErr.isCommandNotFound()) + { + throw new MojoExecutionException("Please add nunit-console to your path"); + } + } + catch (CommandLineException e) + { + throw new MojoExecutionException("Failure executing commandline, " + e.getMessage()); + } + + // TODO: Turn this into a debug + getLog().info("Executed command: " + commandline); + + getLog().info("Done executing tests.."); + } + + private String getNUnitInvocation() throws MojoExecutionException { + + File file = project.getArtifact().getFile(); + String pieces = file.getName().substring(0, file.getName().lastIndexOf('.')); + String testAssemblyName = pieces + "-test.dll"; + + return String.format(NUNIT_CALL_FMT, NUNIT_EXECUTABLE, NUNIT_OPTIONS, testAssemblyName); + } + + private static class NUnitStreamConsumer implements StreamConsumer { + + private boolean commandNotFound; + private StringBuilder consumedLines = new StringBuilder(); + + private Log log; + + private NUnitStreamConsumer(Log log) { + this.log = log; + } + + public void consumeLine(String line) { + consumedLines.append(line + "\n"); + + log.info(line); + + if (line.contains(COMMAND_NOT_FOUND_FRAGMENT)) { + commandNotFound = true; + } + } + + public boolean isCommandNotFound() { + return commandNotFound; + } + } +} Modified: incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/resources/META-INF/plexus/components.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/resources/META-INF/plexus/components.xml?rev=607643&r1=607642&r2=607643&view=diff ============================================================================== --- incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/resources/META-INF/plexus/components.xml (original) +++ incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/resources/META-INF/plexus/components.xml Sun Dec 30 17:23:20 2007 @@ -21,6 +21,9 @@ org.apache.maven.dotnet.plugins:maven-compiler-plugin:test-compile + + org.apache.maven.dotnet.plugins:dotnet-test-plugin:test + org.apache.maven.plugins:maven-install-plugin:install @@ -50,6 +53,9 @@ org.apache.maven.dotnet.plugins:maven-compiler-plugin:test-compile + + org.apache.maven.dotnet.plugins:dotnet-test-plugin:test + org.apache.maven.plugins:maven-install-plugin:install @@ -79,6 +85,9 @@ org.apache.maven.dotnet.plugins:maven-compiler-plugin:test-compile + + org.apache.maven.dotnet.plugins:dotnet-test-plugin:test + org.apache.maven.plugins:maven-install-plugin:install @@ -108,6 +117,9 @@ org.apache.maven.dotnet.plugins:maven-compiler-plugin:test-compile + + org.apache.maven.dotnet.plugins:dotnet-test-plugin:test + org.apache.maven.plugins:maven-install-plugin:install