Skip to content

Commit

Permalink
CLDR-16393 change the property to -DHAS_CLDR_ARCHIVE
Browse files Browse the repository at this point in the history
- also refactor in test code
  • Loading branch information
srl295 committed Nov 30, 2023
1 parent bb85440 commit 50bf437
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ public enum Special {
public static final String UPDATING_CURRENCY_CODES =
"https://cldr.unicode.org/development/updating-codes/update-currency-codes";

public static final String CLDR_ARCHIVE = "https://cldr.unicode.org/development/creating-the-archive";

/**
* Get the relative base URL for the SurveyTool. This may be "/cldr-apps", for example.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@
import org.junit.jupiter.api.Test;

public class TestCLDRPaths {
public static String HAS_CLDR_ARCHIVE = "HAS_CLDR_ARCHIVE";

@Test
void TestCanUseArchiveDirectory() {
if (!canUseArchiveDirectory()) {
// We print this warning as part of the unit tests.
// We print this warning once 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>");
String.format(
"WARNING: -D%s=false, so skipping tests which use cldr-archive\n" +
"See <%s>",
HAS_CLDR_ARCHIVE, CLDRURLS.CLDR_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.
if (!CLDRConfig.getInstance().getProperty("HAS_CLDR_ARCHIVE", true)) {
return false; // skip due to property
}

final File archiveDir = new File(CLDRPaths.ARCHIVE_DIRECTORY);
Expand All @@ -31,16 +35,18 @@ public static final boolean canUseArchiveDirectory() {
String.format(
"Could not read archive directory %s. "
+ "Please: "
+ "1) setup the archive, <https://cldr.unicode.org/development/creating-the-archive>, "
+ "1) setup the archive, <%s>, "
+ "2) set the -DARCHIVE= property to the correct archive location, or "
+ "3) inhibit reading of cldr-archive with -DNO_CLDR_ARCHIVE=true",
archiveDir.getAbsolutePath()));
+ "3) inhibit reading of cldr-archive with -D%s=false",
archiveDir.getAbsolutePath(), CLDRURLS.CLDR_ARCHIVE, HAS_CLDR_ARCHIVE));
}
return true; // OK to use
}

@Test
void TestReadPrevSDI() {
// This is also an example of a test that's skipped (by the next line) if
// cldr-archive isn't available.
assumeTrue(canUseArchiveDirectory());
SupplementalDataInfo SDI_LAST =
SupplementalDataInfo.getInstance(
Expand Down

0 comments on commit 50bf437

Please sign in to comment.