fix line-ends
This commit is contained in:
parent
4af0545d55
commit
befd324283
|
|
@ -0,0 +1,36 @@
|
||||||
|
*.bat eol=crlf
|
||||||
|
*.bz2 binary
|
||||||
|
*.cmd eol=crlf
|
||||||
|
*.css text
|
||||||
|
*.dtd text
|
||||||
|
*.g text
|
||||||
|
*.gif binary
|
||||||
|
*.gz binary
|
||||||
|
*.html text diff=html
|
||||||
|
*.ico binary
|
||||||
|
*.inc text
|
||||||
|
*.jar binary
|
||||||
|
*.jpg binary
|
||||||
|
*.jsp text
|
||||||
|
*.md text
|
||||||
|
*.md5 text
|
||||||
|
*.md5sum text
|
||||||
|
*.mf text
|
||||||
|
*.pl text diff=perl
|
||||||
|
*.properties text
|
||||||
|
*.py text diff=python
|
||||||
|
*.result text
|
||||||
|
*.sample text
|
||||||
|
*.sh eol=lf
|
||||||
|
*.tar binary
|
||||||
|
*.test text
|
||||||
|
*.txt text
|
||||||
|
*.wxs text
|
||||||
|
*.xml text
|
||||||
|
*.xsd text
|
||||||
|
*.xsl text
|
||||||
|
*.zip binary
|
||||||
|
.gitattributes text
|
||||||
|
.gitignore text
|
||||||
|
NOTICE text
|
||||||
|
README text
|
||||||
|
|
@ -1,56 +1,56 @@
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.ant.antunit.junit3;
|
package org.apache.ant.antunit.junit3;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A TestCase that will just report an error when running. This is pretty useful
|
* A TestCase that will just report an error when running. This is pretty useful
|
||||||
* when an error is detected during initialization.
|
* when an error is detected during initialization.
|
||||||
*/
|
*/
|
||||||
public class ErrorTestCase extends TestCase {
|
public class ErrorTestCase extends TestCase {
|
||||||
|
|
||||||
/** The name we use for the error test case ('warning') */
|
/** The name we use for the error test case ('warning') */
|
||||||
public static final String NAME = "warning";
|
public static final String NAME = "warning";
|
||||||
|
|
||||||
private final BuildException ex;
|
private final BuildException ex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a TestCase that will report the Ant BuildException when running.
|
* Creates a TestCase that will report the Ant BuildException when running.
|
||||||
* @param antScriptError The Ant BuildException that triggered the initialization
|
* @param antScriptError The Ant BuildException that triggered the initialization
|
||||||
* failure
|
* failure
|
||||||
*/
|
*/
|
||||||
public ErrorTestCase(BuildException antScriptError) {
|
public ErrorTestCase(BuildException antScriptError) {
|
||||||
super(NAME);
|
super(NAME);
|
||||||
this.ex = antScriptError;
|
this.ex = antScriptError;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void runTest() throws BuildException {
|
protected void runTest() throws BuildException {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuildException getAntScriptError() {
|
public BuildException getAntScriptError() {
|
||||||
return ex;
|
return ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,206 +1,206 @@
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.ant.antunit.listener;
|
package org.apache.ant.antunit.listener;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.apache.ant.antunit.AssertionFailedException;
|
import org.apache.ant.antunit.AssertionFailedException;
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
import org.apache.tools.ant.util.FileUtils;
|
import org.apache.tools.ant.util.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This AntUnitListener creates a new buildfile with a target for each
|
* This AntUnitListener creates a new buildfile with a target for each
|
||||||
* failed test target in the AntUnit run. The generated target calls
|
* failed test target in the AntUnit run. The generated target calls
|
||||||
* the failed target (with setUp and tearDown if present in the called
|
* the failed target (with setUp and tearDown if present in the called
|
||||||
* project).
|
* project).
|
||||||
* This is intended for rerunning just failed tests.
|
* This is intended for rerunning just failed tests.
|
||||||
*/
|
*/
|
||||||
public class FailureAntUnitListener extends BaseAntUnitListener {
|
public class FailureAntUnitListener extends BaseAntUnitListener {
|
||||||
|
|
||||||
/** LineSeparator just for beautifying the output. */
|
/** LineSeparator just for beautifying the output. */
|
||||||
private static final String BR = System.getProperty("line.separator");
|
private static final String BR = System.getProperty("line.separator");
|
||||||
|
|
||||||
/** A sorted list (without duplicates) of failed tests. */
|
/** A sorted list (without duplicates) of failed tests. */
|
||||||
private static SortedSet failedTests = new TreeSet();
|
private static SortedSet failedTests = new TreeSet();
|
||||||
|
|
||||||
/** Where to write the generated buildfile. */
|
/** Where to write the generated buildfile. */
|
||||||
private static File failureBuildfile;
|
private static File failureBuildfile;
|
||||||
|
|
||||||
/** The current running test project. Needed for addError()/addFailure(). */
|
/** The current running test project. Needed for addError()/addFailure(). */
|
||||||
private Project currentTestProject;
|
private Project currentTestProject;
|
||||||
|
|
||||||
/** The current running build file. Needed for addError()/addFailure(). */
|
/** The current running build file. Needed for addError()/addFailure(). */
|
||||||
private String currentBuildFile;
|
private String currentBuildFile;
|
||||||
|
|
||||||
|
|
||||||
/** No-arg constructor. */
|
/** No-arg constructor. */
|
||||||
public FailureAntUnitListener() {
|
public FailureAntUnitListener() {
|
||||||
super(new BaseAntUnitListener.SendLogTo(SendLogTo.ANT_LOG), "txt");
|
super(new BaseAntUnitListener.SendLogTo(SendLogTo.ANT_LOG), "txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFile(File file) {
|
public void setFile(File file) {
|
||||||
failureBuildfile = file;
|
failureBuildfile = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startTestSuite(Project testProject, String buildFile) {
|
public void startTestSuite(Project testProject, String buildFile) {
|
||||||
super.startTestSuite(testProject, buildFile);
|
super.startTestSuite(testProject, buildFile);
|
||||||
currentTestProject = testProject;
|
currentTestProject = testProject;
|
||||||
currentBuildFile = buildFile;
|
currentBuildFile = buildFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addError(String target, Throwable ae) {
|
public void addError(String target, Throwable ae) {
|
||||||
super.addError(target, ae);
|
super.addError(target, ae);
|
||||||
failedTests.add(new TestInfos(currentTestProject, currentBuildFile, target, ae.getMessage()));
|
failedTests.add(new TestInfos(currentTestProject, currentBuildFile, target, ae.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFailure(String target, AssertionFailedException ae) {
|
public void addFailure(String target, AssertionFailedException ae) {
|
||||||
super.addFailure(target, ae);
|
super.addFailure(target, ae);
|
||||||
failedTests.add(new TestInfos(currentTestProject, currentBuildFile, target, ae.getMessage()));
|
failedTests.add(new TestInfos(currentTestProject, currentBuildFile, target, ae.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** not in use */
|
/** not in use */
|
||||||
public void endTest(String target) {
|
public void endTest(String target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endTestSuite(Project testProject, String buildFile) {
|
public void endTestSuite(Project testProject, String buildFile) {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
// <project> and antunit-target for direct run
|
// <project> and antunit-target for direct run
|
||||||
sb.append("<project default=\"antunit\" xmlns:au=\"antlib:org.apache.ant.antunit\">");
|
sb.append("<project default=\"antunit\" xmlns:au=\"antlib:org.apache.ant.antunit\">");
|
||||||
sb.append(BR);
|
sb.append(BR);
|
||||||
sb.append(BR);
|
sb.append(BR);
|
||||||
sb.append(" <target name=\"antunit\">").append(BR);
|
sb.append(" <target name=\"antunit\">").append(BR);
|
||||||
sb.append(" <au:antunit>").append(BR);
|
sb.append(" <au:antunit>").append(BR);
|
||||||
sb.append(" <au:plainlistener/>").append(BR);
|
sb.append(" <au:plainlistener/>").append(BR);
|
||||||
sb.append(" <file file=\"${ant.file}\"/>").append(BR);
|
sb.append(" <file file=\"${ant.file}\"/>").append(BR);
|
||||||
sb.append(" </au:antunit>").append(BR);
|
sb.append(" </au:antunit>").append(BR);
|
||||||
sb.append(" </target>").append(BR);
|
sb.append(" </target>").append(BR);
|
||||||
sb.append(BR);
|
sb.append(BR);
|
||||||
sb.append(BR);
|
sb.append(BR);
|
||||||
|
|
||||||
// one target for each failed test
|
// one target for each failed test
|
||||||
int testNumber = 0;
|
int testNumber = 0;
|
||||||
NumberFormat f = NumberFormat.getIntegerInstance();
|
NumberFormat f = NumberFormat.getIntegerInstance();
|
||||||
for (Iterator it = failedTests.iterator(); it.hasNext();) {
|
for (Iterator it = failedTests.iterator(); it.hasNext();) {
|
||||||
sb.append(" <target name=\"test");
|
sb.append(" <target name=\"test");
|
||||||
sb.append(f.format(testNumber++));
|
sb.append(f.format(testNumber++));
|
||||||
sb.append("\">").append(BR);
|
sb.append("\">").append(BR);
|
||||||
TestInfos testInfos = (TestInfos) it.next();
|
TestInfos testInfos = (TestInfos) it.next();
|
||||||
sb.append(testInfos);
|
sb.append(testInfos);
|
||||||
sb.append(" </target>").append(BR);
|
sb.append(" </target>").append(BR);
|
||||||
sb.append(BR);
|
sb.append(BR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// close the <project>
|
// close the <project>
|
||||||
sb.append("</project>").append(BR);
|
sb.append("</project>").append(BR);
|
||||||
|
|
||||||
// write the whole file
|
// write the whole file
|
||||||
try {
|
try {
|
||||||
FileOutputStream fos = new FileOutputStream(failureBuildfile);
|
FileOutputStream fos = new FileOutputStream(failureBuildfile);
|
||||||
fos.write(sb.toString().getBytes());
|
fos.write(sb.toString().getBytes());
|
||||||
FileUtils.close(fos);
|
FileUtils.close(fos);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
throw new BuildException(e);
|
throw new BuildException(e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new BuildException(e);
|
throw new BuildException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for collecting needed information about failed tests.
|
* Class for collecting needed information about failed tests.
|
||||||
*/
|
*/
|
||||||
public class TestInfos implements Comparable {
|
public class TestInfos implements Comparable {
|
||||||
/** Does the project has a setUp target? */
|
/** Does the project has a setUp target? */
|
||||||
boolean projectHasSetup = false;
|
boolean projectHasSetup = false;
|
||||||
|
|
||||||
/** Does the project has a tearDown target? */
|
/** Does the project has a tearDown target? */
|
||||||
boolean projectHasTearDown = false;
|
boolean projectHasTearDown = false;
|
||||||
|
|
||||||
/** The called target. */
|
/** The called target. */
|
||||||
String target;
|
String target;
|
||||||
|
|
||||||
/** The buildfile of the project. */
|
/** The buildfile of the project. */
|
||||||
String buildfile;
|
String buildfile;
|
||||||
|
|
||||||
/** The error message which was shown. */
|
/** The error message which was shown. */
|
||||||
String errorMessage;
|
String errorMessage;
|
||||||
|
|
||||||
public TestInfos(Project project, String buildfile, String target, String errorMessage) {
|
public TestInfos(Project project, String buildfile, String target, String errorMessage) {
|
||||||
projectHasSetup = project.getTargets().containsKey("setUp");
|
projectHasSetup = project.getTargets().containsKey("setUp");
|
||||||
projectHasTearDown = project.getTargets().containsKey("tearDown");
|
projectHasTearDown = project.getTargets().containsKey("tearDown");
|
||||||
this.buildfile = buildfile;
|
this.buildfile = buildfile;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.errorMessage = errorMessage;
|
this.errorMessage = errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an <ant> call according to the stored information.
|
* Creates an <ant> call according to the stored information.
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
// make the reader of the buildfile happy
|
// make the reader of the buildfile happy
|
||||||
sb.append(" <!-- ");
|
sb.append(" <!-- ");
|
||||||
sb.append(errorMessage);
|
sb.append(errorMessage);
|
||||||
sb.append(" -->").append(BR);
|
sb.append(" -->").append(BR);
|
||||||
// <ant antfile="" inheritAll="false">
|
// <ant antfile="" inheritAll="false">
|
||||||
sb.append(" <ant ");
|
sb.append(" <ant ");
|
||||||
sb.append("antfile=\"");
|
sb.append("antfile=\"");
|
||||||
sb.append(buildfile.replace('\\', '/'));
|
sb.append(buildfile.replace('\\', '/'));
|
||||||
sb.append("\" ");
|
sb.append("\" ");
|
||||||
sb.append("inheritAll=\"false\">");
|
sb.append("inheritAll=\"false\">");
|
||||||
sb.append(BR);
|
sb.append(BR);
|
||||||
// <target name=""/>
|
// <target name=""/>
|
||||||
if (projectHasSetup) {
|
if (projectHasSetup) {
|
||||||
sb.append(" <target name=\"setUp\"/>").append(BR);
|
sb.append(" <target name=\"setUp\"/>").append(BR);
|
||||||
}
|
}
|
||||||
sb.append(" <target name=\"");
|
sb.append(" <target name=\"");
|
||||||
sb.append(target);
|
sb.append(target);
|
||||||
sb.append("\"/>");
|
sb.append("\"/>");
|
||||||
sb.append(BR);
|
sb.append(BR);
|
||||||
if (projectHasTearDown) {
|
if (projectHasTearDown) {
|
||||||
sb.append(" <target name=\"tearDown\"/>").append(BR);
|
sb.append(" <target name=\"tearDown\"/>").append(BR);
|
||||||
}
|
}
|
||||||
// </ant>
|
// </ant>
|
||||||
sb.append(" </ant>").append(BR);
|
sb.append(" </ant>").append(BR);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed, so that a SortedSet could sort this class into the list.
|
// Needed, so that a SortedSet could sort this class into the list.
|
||||||
public int compareTo(Object other) {
|
public int compareTo(Object other) {
|
||||||
if (!(other instanceof TestInfos)) {
|
if (!(other instanceof TestInfos)) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
TestInfos that = (TestInfos)other;
|
TestInfos that = (TestInfos)other;
|
||||||
return this.toString().compareTo(that.toString());
|
return this.toString().compareTo(that.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue