Skip to content

Commit

Permalink
CLDR-16393 assume cldr-archive is present for tests
Browse files Browse the repository at this point in the history
- UNLESS -DNO_CLDR_ARCHIVE=true is set
  • Loading branch information
srl295 committed Aug 23, 2023
1 parent a29d843 commit 4203997
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.unicode.cldr.util.Pair;
import org.unicode.cldr.util.PathUtilities;
import org.unicode.cldr.util.StandardCodes;
import org.unicode.cldr.util.TestCLDRPaths;
import org.unicode.cldr.util.UnicodeRelation;
import org.unicode.cldr.util.XMLFileReader;
import org.unicode.cldr.util.XPathParts;
Expand Down Expand Up @@ -398,9 +399,8 @@ public void TestTransformIDs() {
checkTransformID(entry.getKey(), entry.getValue());
}

// Only run the rest in exhaustive mode since it requires CLDR_ARCHIVE_DIRECTORY.
if (getInclusion() <= 5) {
return;
if (!TestCLDRPaths.canUseArchiveDirectory()) {
return; // skipped
}

Set<String> removedTransforms = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.unicode.cldr.util.StandardCodes;
import org.unicode.cldr.util.StandardCodes.LstrField;
import org.unicode.cldr.util.StandardCodes.LstrType;
import org.unicode.cldr.util.TestCLDRPaths;
import org.unicode.cldr.util.TransliteratorUtilities;
import org.unicode.cldr.util.Units;
import org.unicode.cldr.util.Validity;
Expand Down Expand Up @@ -143,10 +144,10 @@ public void TestBasicValidity() {
static final Set<String> ALLOWED_REGULAR_TO_SPECIAL = ImmutableSet.of("Zanb", "Zinh", "Zyyy");

public void TestCompatibility() {
// Only run the rest in exhaustive mode, since it requires CLDR_ARCHIVE_DIRECTORY
if (getInclusion() <= 5) {
return;
if (!TestCLDRPaths.canUseArchiveDirectory()) {
return; // skipped
}

Set<String> messages = new HashSet<>();
File archive = new File(CLDRPaths.ARCHIVE_DIRECTORY);
for (File cldrArchive : archive.listFiles()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.unicode.cldr.util;

import java.io.File;
import org.junit.jupiter.api.Test;

public class TestCLDRPaths {

@Test
void TestCanUseArchiveDirectory() {
if (!canUseArchiveDirectory()) {
// We print this warning as part of the unit tests.
System.err.println(
"WARNING: skipping using cldr-archive. Ideally, -DNO_CLDR_ARCHIVE=false and see <https://cldr.unicode.org/development/creating-the-archive>");
}
}

/**
* @return true if it's OK to read CLDRPaths.ARCHIVE_DIRECTORY, false to skip.
*/
public static final boolean canUseArchiveDirectory() {
if (CLDRConfig.getInstance().getProperty("NO_CLDR_ARCHIVE", false)) {
return false; // skip, NO_CLDR_ARCHIVE is set.
}

final File archiveDir = new File(CLDRPaths.ARCHIVE_DIRECTORY);
if (!archiveDir.isDirectory()) {
throw new IllegalArgumentException(
String.format(
"Could not read archive directory %s. "
+ "Please: "
+ "1) setup the archive, <https://cldr.unicode.org/development/creating-the-archive>, "
+ "2) set the -DARCHIVE= property to the correct archive location, or "
+ "3) inhibit reading of cldr-archive with -DNO_CLDR_ARCHIVE=true",
archiveDir.getAbsolutePath()));
}
return true; // OK to use
}
}

0 comments on commit 4203997

Please sign in to comment.