[Aceunit-commit] SF.net SVN: aceunit:[507] trunk/src
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2009-01-31 12:55:21
|
Revision: 507
http://aceunit.svn.sourceforge.net/aceunit/?rev=507&view=rev
Author: christianhujer
Date: 2009-01-31 12:37:07 +0000 (Sat, 31 Jan 2009)
Log Message:
-----------
Implemented globally unique test ids.
Modified Paths:
--------------
trunk/src/java/src/prj/net/sf/aceunit/Fixture.java
trunk/src/java/src/prj/net/sf/aceunit/GenTest.java
trunk/src/java/src/prj/net/sf/aceunit/MethodList.java
trunk/src/java/src/prj/net/sf/aceunit/TestCase.java
trunk/src/native/test/common.mak
Modified: trunk/src/java/src/prj/net/sf/aceunit/Fixture.java
===================================================================
--- trunk/src/java/src/prj/net/sf/aceunit/Fixture.java 2009-01-11 21:08:12 UTC (rev 506)
+++ trunk/src/java/src/prj/net/sf/aceunit/Fixture.java 2009-01-31 12:37:07 UTC (rev 507)
@@ -27,9 +27,7 @@
package net.sf.aceunit;
-import java.util.Arrays;
-import java.util.Formatter;
-import java.util.List;
+import java.util.*;
import java.io.File;
import java.io.IOException;
@@ -45,6 +43,11 @@
*/
public class Fixture extends Suite {
+ /** The list of TestCases.
+ * Initially empty, filled by {@link #createTestCases(IdGenerator)}.
+ */
+ private final List<TestCase> testCases = new ArrayList<TestCase>();
+
/** The list of {@code @Test} methods. */
private final MethodList testMethods = MethodList.createTestMethodList();
@@ -162,10 +165,9 @@
out.format("/** The test case ids of this fixture. */%n");
out.format("static const TestCaseId_t testIds[] = {%n");
- int methodCount = 0;
final String formatString = String.format(" %%%dd, /* %%s */%%n", (int) (Math.log10(testMethods.size()) + 1));
- for (final String method : testMethods) {
- out.format(formatString, ++methodCount, method);
+ for (final TestCase testCase : testCases) {
+ out.format(formatString, testCase.getId(), testCase.getName());
}
out.format("};%n");
out.format("%n");
@@ -249,4 +251,20 @@
return fixtureName + "Fixture";
}
+ /** Creates a TestCase for each contained test method.
+ * @param idGenerator IdGenerator for generating unique ids for the test cases.
+ */
+ public void createTestCases(@NotNull final IdGenerator idGenerator) {
+ for (final String method : testMethods) {
+ testCases.add(new TestCase(idGenerator.getNextId(), method));
+ }
+ }
+
+ /** Returns an unmodifiable list of test cases.
+ * @return An unmodifiable list of test cases.
+ */
+ public List<TestCase> getTestCases() {
+ return Collections.unmodifiableList(testCases);
+ }
+
} // class MethodLists
Modified: trunk/src/java/src/prj/net/sf/aceunit/GenTest.java
===================================================================
--- trunk/src/java/src/prj/net/sf/aceunit/GenTest.java 2009-01-11 21:08:12 UTC (rev 506)
+++ trunk/src/java/src/prj/net/sf/aceunit/GenTest.java 2009-01-31 12:37:07 UTC (rev 507)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007 - 2008, Christian Hujer
+/* Copyright (c) 2007 - 2009, Christian Hujer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import java.io.IOException;
import java.util.List;
import java.util.EnumSet;
+import java.util.Map;
+import java.util.HashMap;
import net.sf.japi.io.args.ArgParser;
import net.sf.japi.io.args.BasicCommand;
@@ -72,6 +74,9 @@
@NotNull
private final IdGenerator idGenerator = new IdGenerator();
+ /** The table of all tests. */
+ private final Map<Integer, String> allTests = new HashMap<Integer, String>();
+
/**
* Creates a GenTest instance.
*
@@ -176,6 +181,7 @@
}
final String hSource = pckg.getCode("foo");
SourceFiles.writeIfChanged(cFile, hSource, force);
+ allTests.put(pckg.getId(), pckgDir.toString().replaceAll("[^\\/]", "."));
}
if (containedFixture && parent != null) {
parent.addSuite(pckg);
@@ -200,6 +206,12 @@
final Fixture fixture = new Fixture(idGenerator.getNextId(), fixtureFile);
final boolean containedFixture = fixture.containsTests();
if (containedFixture) {
+ fixture.createTestCases(idGenerator);
+ for (final TestCase testCase : fixture.getTestCases()) {
+ final Integer id = testCase.getId();
+ assert !allTests.containsKey(id) : "IDs must be unique, especially within allTests.";
+ allTests.put(testCase.getId(), testCase.getName());
+ }
final File hFile = new File(fixtureFile.getParent(), fixtureName + ".h");
if (printSet.contains(Print.sources) || printSet.contains(Print.fixtures)) {
System.out.println(fixtureFile);
@@ -210,6 +222,7 @@
final String hSource = fixture.getCode(fixtureName);
SourceFiles.writeIfChanged(hFile, hSource, force);
pckg.addSuite(fixture);
+ allTests.put(fixture.getId(), fixtureFile.toString().replaceAll("[^\\/]", "."));
}
return containedFixture;
}
Modified: trunk/src/java/src/prj/net/sf/aceunit/MethodList.java
===================================================================
--- trunk/src/java/src/prj/net/sf/aceunit/MethodList.java 2009-01-11 21:08:12 UTC (rev 506)
+++ trunk/src/java/src/prj/net/sf/aceunit/MethodList.java 2009-01-31 12:37:07 UTC (rev 507)
@@ -32,7 +32,6 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import java.util.Formatter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -65,9 +64,6 @@
@NotNull
protected final List<String> methodNames = new ArrayList<String>();
- /** The arguments of the annotations. */
- @NotNull private final List<String> annotParams = new ArrayList<String>();
-
/** The unmodifiable view of {@link #methodNames}. */
@NotNull
private final Collection<String> unmodifiableMethodNames = Collections.unmodifiableCollection(methodNames);
Modified: trunk/src/java/src/prj/net/sf/aceunit/TestCase.java
===================================================================
--- trunk/src/java/src/prj/net/sf/aceunit/TestCase.java 2009-01-11 21:08:12 UTC (rev 506)
+++ trunk/src/java/src/prj/net/sf/aceunit/TestCase.java 2009-01-31 12:37:07 UTC (rev 507)
@@ -26,18 +26,33 @@
*/
package net.sf.aceunit;
+import org.jetbrains.annotations.NotNull;
+
/** A TestCase.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class TestCase extends Test {
+ /** The name of this TestCase. */
+ @NotNull private final String name;
+
/**
* Creates a TestCase.
*
* @param id Id for this TestCase.
+ * @param name Name for this TestCase.
*/
- protected TestCase(final int id) {
+ protected TestCase(final int id, @NotNull final String name) {
super(id);
+ this.name = name;
}
+ /** Returns the name of this TestCase.
+ * @return The name of this TestCase.
+ */
+ @NotNull
+ public String getName() {
+ return name;
+ }
+
}
Modified: trunk/src/native/test/common.mak
===================================================================
--- trunk/src/native/test/common.mak 2009-01-11 21:08:12 UTC (rev 506)
+++ trunk/src/native/test/common.mak 2009-01-31 12:37:07 UTC (rev 507)
@@ -9,7 +9,7 @@
VPATH=$(ACEUNIT_NATIVE_PATH)
-GENERATED:=$(shell java -jar $(ACEUNIT_JAVA_PATH)/AceUnit.jar --print=generated .)
+GENERATED:=$(shell java -ea -jar $(ACEUNIT_JAVA_PATH)/AceUnit.jar --print=generated .)
SUITES:=$(filter *.c,$(GENERATED))
CSOURCES:=$(sort $(shell find . -name "*.c")) $(SUITES)
CXXSOURCES:=$(sort $(shell find . -name "*.cpp"))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|