Skip to content

Commit

Permalink
CLDR-11585 fix pom.xml, add tests (#734)
Browse files Browse the repository at this point in the history
- fix pom.xml repository settings so that settings can be more minimal
- basic test runner shim for web / java
- build tests where they are
- currently test code is included in cldr-apps.war (TODO)
- currently, cldr-apps are tested against Derby (regression of CLDR-8383)

(cherry picked from commit 6adc82b)
  • Loading branch information
srl295 authored and pedberg committed Sep 24, 2020
1 parent 5259c30 commit d97db11
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ jobs:
run: mvn -s .github/workflows/mvn-settings.xml -B package --file tools/pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test with maven
run: mvn -s .github/workflows/mvn-settings.xml -B test --file tools/pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

5 changes: 0 additions & 5 deletions .github/workflows/mvn-settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ TODO: Remove this when ICU-21251 is completed.
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>githubicu</id>
<name>GitHub unicode-org/icu Apache Maven Packages</name>
<url>https://maven.pkg.github.com/unicode-org/icu</url>
</repository>
<repository>
<id>github</id>
<name>GitHub unicode-org/cldr Apache Maven Packages</name>
Expand Down
9 changes: 9 additions & 0 deletions tools/cldr-apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@
<build>
<finalName>cldr-apps</finalName>
<sourceDirectory>src</sourceDirectory> <!-- TODO: HACK! until we can pivot src dirs -->
<testResources>
<testResource>
<directory>src</directory>
<includes>
<include>org/unicode/cldr/unittest/web/data/**/*</include>
</includes>
</testResource>
</testResources>

<pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
<plugins>
Expand Down
14 changes: 13 additions & 1 deletion tools/cldr-apps/src/org/unicode/cldr/unittest/web/TestAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.io.BufferedReader;
import java.io.File;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.sql.DataSource;
Expand Down Expand Up @@ -86,9 +87,20 @@ private static void pleaseSet(String var, String err, String sugg) {
public static final String DERBY_PREFIX = "jdbc:derby:";

public static void main(String[] args) {
main(args, null);
/* NOTREACHED */
}

public static void main(String[] args, PrintWriter logs) {
CheckCLDR.setDisplayInformation(CLDRConfig.getInstance().getEnglish());
args = TestAll.doResetDb(args);
new TestAll().run(args);
TestAll test = new TestAll();
if(logs != null) {
test.run(args, logs);
} else {
test.run(args);
/* NOTREACHED */
}
}

public static String[] doResetDb(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.unicode.cldr.unittest.web;

import java.io.PrintWriter;

import org.junit.jupiter.api.Test;

/**
* a JUnit test that calls TestAll.
*/
class TestShim {
@Test
public void TestAll() {
String args[] = { "-q" };
// regular main() will System.exit() which is not too friendly.
// call this instead.
TestAll.main(args, new PrintWriter(System.out)); // TODO: parameterize
}
}
1 change: 1 addition & 0 deletions tools/cldr-unittest/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
<mkdir dir="${log.dir}" />
<javac srcdir="${src.dir}"
includes="org/unicode/cldr/**/*.java"
excludes="**/TestShim.java"
destdir="${build.dir}" classpathref="project.class.path" source="1.8"
target="1.8" debug="on" deprecation="off" includeantruntime="false"
encoding="UTF-8" />
Expand Down
14 changes: 11 additions & 3 deletions tools/cldr-unittest/src/org/unicode/cldr/unittest/TestAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ public String toString() {
}

public static void main(String[] args) {
int errCount = runTests(args);
if (errCount != 0) {
System.exit(1);
}
}

/**
* Run all tests, but do not System.exit at the end.
*/
public static int runTests(String[] args) {
final boolean doTimeStamps = false;
TimeStampingPrintWriter tspw = new TimeStampingPrintWriter(System.out);
if (!doTimeStamps) {
Expand All @@ -172,9 +182,7 @@ public static void main(String[] args) {
sb.append("Tests took ");
sb.append(dispBean.toString());
System.out.println(sb.toString());
if (errCount != 0) {
System.exit(1);
}
return errCount;
}

public TestAll() {
Expand Down
20 changes: 20 additions & 0 deletions tools/cldr-unittest/src/org/unicode/cldr/unittest/TestShim.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.unicode.cldr.unittest;

import java.io.PrintWriter;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* a JUnit test that calls TestAll.
*/
class TestShim {
@Test
public void TestAll() {
String args[] = { "-n", "-q" }; // TODO: parameterize
// regular main() will System.exit() which is not too friendly.
// call this instead.
int errCount = TestAll.runTests(args);
assertEquals(errCount, 0, "Test had errors");
}
}
28 changes: 18 additions & 10 deletions tools/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@
<artifactId>utilities-for-cldr</artifactId>
</dependency>

<!-- test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -71,6 +77,7 @@
</dependencies>

<build>
<testSourceDirectory>${project.basedir}/../cldr-unittest/src</testSourceDirectory>
<sourceDirectory>.</sourceDirectory> <!-- TODO: fix by refactoring source dirs, CLDR-11585 -->
<resources>
<resource>
Expand All @@ -87,6 +94,15 @@
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>${project.basedir}/../cldr-unittest/src</directory>
<includes>
<include>org/unicode/cldr/unittest/*.txt</include>
<include>org/unicode/cldr/unittest/data/**/*</include>
</includes>
</testResource>
</testResources>

<plugins>
<plugin>
Expand Down Expand Up @@ -135,12 +151,4 @@
</plugins>

</build>

<repositories>
<repository>
<id>githubicu</id>
<name>GitHub unicode-org/icu Apache Maven Packages</name>
<url>https://maven.pkg.github.com/unicode-org/icu</url>
</repository>
</repositories>
</project>
11 changes: 11 additions & 0 deletions tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@
</dependencies>
</dependencyManagement>

<repositories>
<repository>
<id>githubicu</id>
<name>GitHub unicode-org/icu Apache Maven Packages</name>
<url>https://maven.pkg.github.com/unicode-org/icu</url>
</repository>
</repositories>

<build>
<pluginManagement>
<plugins>
Expand All @@ -216,6 +224,9 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin-version}</version>
<configuration>
<argLine>-DCLDR_ENVIRONMENT=UNITTEST -Djava.awt.headless=true -DCLDR_DIR=../../ -Xmx6g -enableassertions</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
Expand Down

0 comments on commit d97db11

Please sign in to comment.