Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Step 1 for enabling AutomatedIntegrationSuite regression testing


This patch adds some missing source folders to the ui.tests library.
Please extract the attached zip file to create resource directory under /plugins directory

Vmir

Attachment: cmodel.resources.zip
Description: Zip archive

Index: .classpath
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/.classpath,v
retrieving revision 1.7
diff -u -r1.7 .classpath
--- .classpath	26 May 2003 16:59:50 -0000	1.7
+++ .classpath	16 Jun 2003 15:52:31 -0000
@@ -4,11 +4,11 @@
     <classpathentry kind="src" path="ui/"/>
     <classpathentry kind="src" path="core/"/>
     <classpathentry kind="src" path="model/"/>
-    <classpathentry kind="src" path="build"/>
-    <classpathentry kind="src" path="parser"/>
-    <classpathentry kind="src" path="failures"/>
+    <classpathentry kind="src" path="build/"/>
+    <classpathentry kind="src" path="parser/"/>
+    <classpathentry kind="src" path="failures/"/>
+    <classpathentry kind="src" path="suite/"/>
     <classpathentry kind="src" path="/org.apache.xerces"/>
-    <classpathentry kind="src" path="/org.eclipse.core.boot"/>
     <classpathentry kind="src" path="/org.eclipse.core.resources"/>
     <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
     <classpathentry kind="src" path="/org.eclipse.cdt.core"/>
@@ -20,8 +20,7 @@
     <classpathentry kind="src" path="/org.eclipse.swt"/>
     <classpathentry kind="src" path="/org.eclipse.ui"/>
     <classpathentry kind="src" path="/org.junit"/>
-    <classpathentry kind="src" path="/org.eclipse.update.core"/>
+    <classpathentry kind="src" path="/org.eclipse.core.boot"/>
     <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-    <classpathentry kind="src" path="suite"/>
     <classpathentry kind="output" path="bin"/>
 </classpath>
Index: .project
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/.project,v
retrieving revision 1.2
diff -u -r1.2 .project
--- .project	7 Apr 2003 02:46:58 -0000	1.2
+++ .project	16 Jun 2003 15:52:31 -0000
@@ -15,7 +15,6 @@
 		<project>org.eclipse.core.runtime</project>
 		<project>org.eclipse.swt</project>
 		<project>org.eclipse.ui</project>
-		<project>org.eclipse.update.core</project>
 		<project>org.junit</project>
 	</projects>
 	<buildSpec>
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/ChangeLog,v
retrieving revision 1.63
diff -u -r1.63 ChangeLog
--- ChangeLog	13 Jun 2003 19:59:47 -0000	1.63
+++ ChangeLog	16 Jun 2003 15:52:31 -0000
@@ -1,3 +1,10 @@
+2003-06-16 Vladimir Hirsl
+	Added /build, /parser, /failures and /suite directories to the library. 
+	Copied resources from /model/org.eclipse.cdt.core.model.tests.resources
+	                 to /model/org/clipse/cdt/core/model/tests/resources/cmodel.
+	Added class AISResultPrinter to format test results.  
+	Class AutomatedIntegrationSuite now implements IPlatformRunnable.
+
 2003-06-13 John Camelon
 	Added Class/Base infrastructure to public interfaces & requestor callback. 
 	Moved many internal interfaces to external packages. 
Index: build.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/build.properties,v
retrieving revision 1.5
diff -u -r1.5 build.properties
--- build.properties	29 Jan 2003 17:56:30 -0000	1.5
+++ build.properties	16 Jun 2003 15:52:31 -0000
@@ -1,14 +1,17 @@
 source.cdtuitests.jar = src/,\
-                      ui/,\
-                      core/,\
-                      model/
+                        ui/,\
+                        core/,\
+                        model/,\
+                        build/,\
+                        parser/,\
+                        failures/,\
+                        suite/
 bin.includes = plugin.xml,\
                about.html,\
                plugin.properties,\
                test.xml
-               about.html
 src.includes = plugin.xml,\
                about.html,\
                plugin.properties,\
                test.xml
-               
+about.html = 
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/plugin.xml,v
retrieving revision 1.13
diff -u -r1.13 plugin.xml
--- plugin.xml	9 Jun 2003 19:22:21 -0000	1.13
+++ plugin.xml	16 Jun 2003 15:52:31 -0000
@@ -2,7 +2,7 @@
 <plugin
    id="org.eclipse.cdt.ui.tests"
    name="org.eclipse.cdt.ui.tests"
-   version="1.1.0"
+   version="1.2.0.5"
    class="org.eclipse.cdt.testplugin.CTestPlugin">
 
    <runtime>
@@ -12,7 +12,6 @@
    </runtime>
    <requires>
       <import plugin="org.apache.xerces"/>
-      <import plugin="org.eclipse.core.boot"/>
       <import plugin="org.eclipse.core.resources"/>
       <import plugin="org.eclipse.core.runtime"/>
       <import plugin="org.eclipse.cdt.core"/>
@@ -20,7 +19,6 @@
       <import plugin="org.eclipse.swt"/>
       <import plugin="org.eclipse.ui"/>
       <import plugin="org.junit"/>
-      <import plugin="org.eclipse.update.core"/>
    </requires>
 
 
Index: model/org/eclipse/cdt/core/model/tests/IIncludeTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java,v
retrieving revision 1.1
diff -u -r1.1 IIncludeTests.java
--- model/org/eclipse/cdt/core/model/tests/IIncludeTests.java	10 Jun 2003 22:57:05 -0000	1.1
+++ model/org/eclipse/cdt/core/model/tests/IIncludeTests.java	16 Jun 2003 15:52:31 -0000
@@ -29,7 +29,7 @@
 	 * @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
 	 */
 	public String getSourcefileSubdir() {
-		return "model/org.eclipse.cdt.core.model.tests.resources/";
+		return "model/org/eclipse/cdt/core/model/tests/resources/cmodel/";
 	}
 
 	/**
Index: model/org/eclipse/cdt/core/model/tests/IMacroTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/model/org/eclipse/cdt/core/model/tests/IMacroTests.java,v
retrieving revision 1.1
diff -u -r1.1 IMacroTests.java
--- model/org/eclipse/cdt/core/model/tests/IMacroTests.java	10 Jun 2003 22:57:05 -0000	1.1
+++ model/org/eclipse/cdt/core/model/tests/IMacroTests.java	16 Jun 2003 15:52:31 -0000
@@ -43,7 +43,7 @@
 	 * @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
 	 */
 	public String getSourcefileSubdir() {
-		return "model/org.eclipse.cdt.core.model.tests.resources/";
+		return "model/org/eclipse/cdt/core/model/tests/resources/cmodel/";
 	}
 
 	/**
Index: model/org/eclipse/cdt/core/model/tests/IStructureTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java,v
retrieving revision 1.1
diff -u -r1.1 IStructureTests.java
--- model/org/eclipse/cdt/core/model/tests/IStructureTests.java	10 Jun 2003 22:57:05 -0000	1.1
+++ model/org/eclipse/cdt/core/model/tests/IStructureTests.java	16 Jun 2003 15:52:31 -0000
@@ -28,7 +28,7 @@
 	 * @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
 	 */
 	public String getSourcefileSubdir() {
-		return "model/org.eclipse.cdt.core.model.tests.resources/";
+		return "model/org/eclipse/cdt/core/model/tests/resources/cmodel/";
 	}
 
 	/**
Index: suite/org/eclipse/cdt/core/suite/AISResultPrinter.java
===================================================================
RCS file: suite/org/eclipse/cdt/core/suite/AISResultPrinter.java
diff -N suite/org/eclipse/cdt/core/suite/AISResultPrinter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ suite/org/eclipse/cdt/core/suite/AISResultPrinter.java	16 Jun 2003 15:52:31 -0000
@@ -0,0 +1,53 @@
+/*
+ * Created on Jun 5, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.eclipse.cdt.core.suite;
+
+import java.io.PrintStream;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.textui.ResultPrinter;
+
+/**
+ * @author vhirsl
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class AISResultPrinter extends ResultPrinter {
+
+	/**
+	 * @param writer
+	 */
+	public AISResultPrinter(PrintStream writer) {
+		super(writer);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestListener#addFailure(junit.framework.Test, junit.framework.AssertionFailedError)
+	 */
+	public void addFailure(Test test, AssertionFailedError t) {
+		super.addFailure(test, t);
+		getWriter().print("---> ");
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestListener#addError(junit.framework.Test, java.lang.Throwable)
+	 */
+	public void addError(Test test, Throwable t) {
+		super.addError(test, t);
+		getWriter().print("---> ");
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestListener#startTest(junit.framework.Test)
+	 */
+	public void startTest(Test test) {
+		getWriter().print(".");
+	}
+
+}
Index: suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java,v
retrieving revision 1.5
diff -u -r1.5 AutomatedIntegrationSuite.java
--- suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java	11 Jun 2003 18:09:23 -0000	1.5
+++ suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java	16 Jun 2003 15:52:31 -0000
@@ -12,8 +12,12 @@
 import junit.framework.TestResult;
 import junit.framework.TestListener;
 import junit.framework.AssertionFailedError;
+import junit.textui.TestRunner;
 
 import java.text.DecimalFormat;
+import java.util.ArrayList;
+
+import org.eclipse.core.boot.IPlatformRunnable;
 
 import org.eclipse.cdt.core.build.managed.tests.AllBuildTests;
 import org.eclipse.cdt.core.model.tests.AllCoreTests;
@@ -30,13 +34,11 @@
  * To change the template for this generated type comment go to
  * Window>Preferences>Java>Code Generation>Code and Comments
  */
-public class AutomatedIntegrationSuite extends TestSuite implements TestListener {
+public class AutomatedIntegrationSuite extends TestSuite 
+									   implements TestListener, IPlatformRunnable {
 
+	private TestResult testResult = null;
 	private String currentTestName;
-	// Statistical information
-	private int numberOfRuns = 0;
-	private int numberOfFailures = 0;
-	private int numberOfErrors = 0;
 	// success tests
 	private int numberOfSuccessTests = 0;
 	private int numberOfFailedSuccessTests = 0;
@@ -65,6 +67,9 @@
 	public static Test suite() {
 		final AutomatedIntegrationSuite suite = new AutomatedIntegrationSuite();
 		
+		// First test to trigger report generation
+		suite.addTest(suite.new GenerateReport("startSuccessTests"));
+
 		// Add all success tests
 		suite.addTest(AllBuildTests.suite());
 		suite.addTest(ParserTestSuite.suite());
@@ -93,6 +98,8 @@
 	 * Overloaded method
 	 */
 	public void run(TestResult result) {
+		// To get counts from the result
+		testResult = result;
 		// Add oneself as a listener
 		result.addListener(this);
 		// Call a base class method
@@ -106,27 +113,25 @@
 	 * An error occurred.
 	 */
 	public void addError(Test test, Throwable t) {
-		++numberOfErrors;
-		System.out.println("Error : " + test);
-		System.out.println("\tReason : " + t);
-		System.out.println("\tStack trace : ");
-		t.printStackTrace(System.out);
+//		System.out.println("Error : " + test);
+//		System.out.println("\tReason : " + t);
+//		System.out.println("\tStack trace : ");
+//		t.printStackTrace(System.out);
 	}
 	/**
 	 * A failure occurred.
 	 */
 	public void addFailure(Test test, AssertionFailedError t) {
-		++numberOfFailures;
 		if (failedTests) {
 			++numberOfFailedFailedTests;  
 		}
 		else {
 			++numberOfFailedSuccessTests;
 		}
-		System.out.println("Failure : " + test);
-		System.out.println("\tReason : " + t);
-		System.out.println("\tStackTrace : ");
-		t.printStackTrace(System.out);
+//		System.out.println("Failure : " + test);
+//		System.out.println("\tReason : " + t);
+//		System.out.println("\tStackTrace : ");
+//		t.printStackTrace(System.out);
 	}
 	/**
 	 * A test ended.
@@ -140,15 +145,14 @@
 				skipTest = false;
 			}
 			else {
-				++numberOfRuns;
 				if (failedTests) {
 					++numberOfFailedTests;
-					System.out.println(test);
+					// System.out.println(test);
 				}
 				else {
 					++numberOfSuccessTests;
 				}
-				// System.out.println(test);
+				System.out.println(test);
 			}
 			currentTestName = null;
 		}
@@ -174,11 +178,17 @@
 	 * Window>Preferences>Java>Code Generation>Code and Comments
 	 */
 	protected void generateReport() {
-	 	System.out.println("\n*** Generating report: ***\n");
+		int numberOfRuns = testResult.runCount();
+		int numberOfFailures = testResult.failureCount();
+		int numberOfErrors = testResult.errorCount();
+
+		System.out.println();
+	 	System.out.println("*** Generating report: ***");
+		System.out.println();
 	 	System.out.println("\tNumber of runs: " + numberOfRuns);
 		System.out.println("\tNumber of failures: " + numberOfFailures);
 		System.out.println("\tNumber of errors: " + numberOfErrors);
-		float successRate = (numberOfRuns-numberOfFailures)/(float)numberOfRuns;
+		float successRate = (numberOfRuns-numberOfFailures-numberOfErrors)/(float)numberOfRuns;
 		DecimalFormat df = new DecimalFormat("##.##%");
 		System.out.println("Sanity success rate : " + df.format(successRate));
 		System.out.println("\tNumber of success tests: " + numberOfSuccessTests);
@@ -189,12 +199,23 @@
 					  (float)(numberOfSuccessTests+numberOfFailedTests-numberOfFailedFailedTests);
 		System.out.print("Observed success test rate : " + df.format(successRate)); 
 		System.out.println(" (failed success tests = " + numberOfFailedSuccessTests + ", failed failed tests = " + numberOfFailedFailedTests + ")");
+		System.out.println();
 	}
 	
-	private void startFailedTests() {
-		failedTests = true;
-		System.out.println("\n*** Starting failed tests ***\n");
-	}
+		private void startSuccessTests() {
+			failedTests = false;
+			System.out.println();
+			System.out.println("*** Starting success tests ***");
+			System.out.println();
+		}
+	
+		private void startFailedTests() {
+			failedTests = true;
+			System.out.println();
+			System.out.println("*** Starting failed tests ***");
+			System.out.println();
+		}
+		
 	/*
 	 * Public inner class to invoke generateReport
 	 * 
@@ -217,6 +238,14 @@
 			AutomatedIntegrationSuite.this.generateReport();
 		}
 		
+		public void startSuccessTests() {
+			// skip this one
+			AutomatedIntegrationSuite.this.skipTest = true;
+			
+			// Calls a method of the outer class
+			AutomatedIntegrationSuite.this.startSuccessTests();
+		}
+
 		public void startFailedTests() {
 			// skip this one
 			AutomatedIntegrationSuite.this.skipTest = true;
@@ -224,5 +253,54 @@
 			// Calls a method of the outer class
 			AutomatedIntegrationSuite.this.startFailedTests();
 		}
+
+		/* (non-Javadoc)
+		 * @see junit.framework.Test#countTestCases()
+		 * We don't want these test cases to be counted
+		 */
+		public int countTestCases() {
+			return 0;
+		}
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.boot.IPlatformRunnable#run(java.lang.Object)
+	 */
+	public Object run(Object args) throws Exception {
+		// Used when started from as a regression test suite after the build
+		TestRunner testRunner = new TestRunner(new AISResultPrinter(System.out));
+		TestResult testResult = testRunner.doRun(suite());
+		
+		return prepareReport(testResult);
+	}
+
+	protected ArrayList prepareReport(TestResult testResult) {	
+		// TestRunner.run(suite());
+		ArrayList efMessages = new ArrayList();
+		int errorCount = testResult.errorCount();
+		int failureCount = testResult.failureCount();
+		if (errorCount > 0) {
+			String em = new String("There ");
+			em += (errorCount == 1)?"is ":"are ";
+			em += Integer.toString(errorCount);
+			em += " error";
+			em += (errorCount == 1)?"!":"s!";
+			efMessages.add(em);
+		}
+		if (failureCount > 0) {
+			String fm = new String("There ");
+			fm += (failureCount == 1)?"is ":"are ";
+			fm += Integer.toString(failureCount);
+			fm += " failure";
+			fm += (failureCount == 1)?"!":"s!";
+			efMessages.add(fm);
+		}
+		if (efMessages.isEmpty()) {
+			efMessages.add(new String("Regression test run SUCCESSFUL!"));
+		}
+		else {
+			efMessages.add(new String("Please see raw test suite output for details."));
+		}
+		return efMessages;
 	}
 }

Back to the top