-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLDR-16393 assume cldr-archive is present for tests
- UNLESS -DNO_CLDR_ARCHIVE=true is set
- Loading branch information
Showing
3 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tools/cldr-code/src/test/java/org/unicode/cldr/util/TestCLDRPaths.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |