Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix placeholder name for addition comparison test #985

Merged
merged 11 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,19 @@ public static void main(String[] args) throws Exception {
isWhiteSpace = new UnicodeSet(up.getSet("whitespace=Yes"));

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "nameslist_index.html",
MakeNamesChart.class.getResource("nameslist_index.html").getPath(),
Utility.UTF8,
NAMESLIST_DIR + "index.html");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, NAMESLIST_DIR + "charts.css");
MakeNamesChart.class.getResource("charts.css").getPath(),
Utility.LATIN1,
NAMESLIST_DIR + "charts.css");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "nameslist_help.html",
MakeNamesChart.class.getResource("nameslist_help.html").getPath(),
Utility.UTF8,
NAMESLIST_DIR + "help.html");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "nameslist.css",
MakeNamesChart.class.getResource("nameslist.css").getPath(),
Utility.LATIN1,
NAMESLIST_DIR + "nameslist.css");

Expand Down
76 changes: 56 additions & 20 deletions unicodetools/src/main/java/org/unicode/text/UCA/WriteCharts.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,27 @@ public static void collationChart(UCA uca) throws IOException {
final String folder = GEN_CHARTS_DIR + "collation/";

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "index.html",
WriteCharts.class.getResource("index.html").getPath(),
Utility.UTF8,
folder + "index.html",
replacement);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css", null);
WriteCharts.class.getResource("charts.css").getPath(),
Utility.LATIN1,
folder + "charts.css",
null);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "help.html", Utility.UTF8, folder + "help.html", null);
WriteCharts.class.getResource("help.html").getPath(),
Utility.UTF8,
folder + "help.html",
null);

indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS);
Utility.appendFile(
Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement);
WriteCharts.class.getResource("index_header.html").getPath(),
Utility.UTF8,
indexFile,
replacement);

/*
indexFile.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
Expand Down Expand Up @@ -319,18 +328,25 @@ public static void normalizationChart() throws IOException {
// System.out.println("File: " + new File(".").getCanonicalPath());

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "index.html",
WriteCharts.class.getResource("index.html").getPath(),
Utility.UTF8,
folder + "index.html",
replacement);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css");
WriteCharts.class.getResource("charts.css").getPath(),
Utility.LATIN1,
folder + "charts.css");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "norm_help.html", Utility.UTF8, folder + "help.html");
WriteCharts.class.getResource("norm_help.html").getPath(),
Utility.UTF8,
folder + "help.html");

indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS);
Utility.appendFile(
Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement);
WriteCharts.class.getResource("index_header.html").getPath(),
Utility.UTF8,
indexFile,
replacement);

/*
indexFile.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
Expand Down Expand Up @@ -447,18 +463,27 @@ public static void caseChart() throws IOException {
final String folder = GEN_CHARTS_DIR + "case/";

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "index.html",
WriteCharts.class.getResource("index.html").getPath(),
Utility.UTF8,
folder + "index.html",
replacement);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css", null);
WriteCharts.class.getResource("charts.css").getPath(),
Utility.LATIN1,
folder + "charts.css",
null);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "case_help.html", Utility.UTF8, folder + "help.html", null);
WriteCharts.class.getResource("case_help.html").getPath(),
Utility.UTF8,
folder + "help.html",
null);

indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS);
Utility.appendFile(
Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement);
WriteCharts.class.getResource("index_header.html").getPath(),
Utility.UTF8,
indexFile,
replacement);

/*
indexFile.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
Expand Down Expand Up @@ -574,18 +599,22 @@ public static void scriptChart() throws IOException {
final String folder = GEN_CHARTS_DIR + "script/";

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "index.html",
WriteCharts.class.getResource("index.html").getPath(),
Utility.UTF8,
folder + "index.html",
replacement);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css");
WriteCharts.class.getResource("charts.css").getPath(),
Utility.LATIN1,
folder + "charts.css");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "script_help.html", Utility.UTF8, folder + "help.html");
WriteCharts.class.getResource("script_help.html").getPath(),
Utility.UTF8,
folder + "help.html");

indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS);
Utility.appendFile(
Settings.SRC_UCA_DIR + "script_index_header.html",
WriteCharts.class.getResource("script_index_header.html").getPath(),
Utility.UTF8,
indexFile,
replacement);
Expand Down Expand Up @@ -724,18 +753,25 @@ public static void indexChart() throws IOException {
final String folder = GEN_CHARTS_DIR + "name/";

Utility.copyTextFile(
Settings.SRC_UCA_DIR + "index.html",
WriteCharts.class.getResource("index.html").getPath(),
Utility.UTF8,
folder + "index.html",
replacement);
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css");
WriteCharts.class.getResource("charts.css").getPath(),
Utility.LATIN1,
folder + "charts.css");
Utility.copyTextFile(
Settings.SRC_UCA_DIR + "name_help.html", Utility.UTF8, folder + "help.html");
WriteCharts.class.getResource("name_help.html").getPath(),
Utility.UTF8,
folder + "help.html");

indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS);
Utility.appendFile(
Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement);
WriteCharts.class.getResource("index_header.html").getPath(),
Utility.UTF8,
indexFile,
replacement);

int columnCount = 0;
char lastInitial = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,11 @@ static void generateSpecialCasing(boolean normalize) throws IOException {
break;
case 6:
Utility.appendFile(
Settings.SRC_UCD_DIR + "SpecialCasingIota.txt", Utility.UTF8, out);
GenerateCaseFolding.class
.getResource("SpecialCasingIota.txt")
.getPath(),
Utility.UTF8,
out);
break;
case 7:
out.println(
Expand All @@ -888,7 +892,10 @@ static void generateSpecialCasing(boolean normalize) throws IOException {
}
out.println(line);
}
Utility.appendFile(Settings.SRC_UCD_DIR + "SpecialCasingFooter.txt", Utility.UTF8, out);
Utility.appendFile(
GenerateCaseFolding.class.getResource("SpecialCasingFooter.txt").getPath(),
Utility.UTF8,
out);
udf.close();
// Utility.renameIdentical(mostRecent, Utility.getOutputName(newFile), batName[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ public void writeSourceOrder(
if (appendFile) {
final String[] replacements = {"%date%", Default.getDate()};
Utility.appendFile(
Settings.SRC_UCD_DIR + "confusablesHeader.txt",
GenerateConfusables.class.getResource("confusablesHeader.txt").getPath(),
Utility.UTF8_WINDOWS,
out,
replacements);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,9 @@ public void writeSourceOrder(
if (appendFile) {
final String[] replacements = {"%date%", Default.getDate()};
Utility.appendFile(
Settings.SRC_UCD_DIR + "confusablesHeader.txt",
GenerateConfusablesCopy.class
.getResource("confusablesHeader.txt")
.getPath(),
Utility.UTF8_WINDOWS,
out,
replacements);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static void generate(String filename2) throws IOException {
};

Utility.appendFile(
Settings.SRC_UCD_DIR + "NamedSequences-Template.html",
GenerateNamedSequences.class.getResource("NamedSequences-Template.html").getPath(),
Utility.UTF8,
out,
replacementList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ public static void generate() throws IOException {
};

Utility.appendFile(
Settings.SRC_UCD_DIR + "StandardizedVariants-Template.html",
GenerateStandardizedVariants.class
.getResource("StandardizedVariants-Template.html")
.getPath(),
Utility.UTF8,
out,
replacementList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ private void build() {
try {
br =
Utility.openReadFile(
Settings.SRC_UCD_DIR + "MakeUnicodeFiles.txt", Utility.UTF8);
MakeUnicodeFiles.class
.getResource("MakeUnicodeFiles.txt")
.getPath(),
Utility.UTF8);
String file = null, property = null, value = "", comments = "";
while (true) {
String line = br.readLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.io.PrintWriter;
import org.unicode.cldr.draft.FileUtilities;
import org.unicode.cldr.util.TransliteratorUtilities;
import org.unicode.text.utility.Settings;

public class UseTransliterator {
public static void main(String[] args) throws IOException {
Expand All @@ -15,7 +14,7 @@ public static void main(String[] args) throws IOException {
final File f2 = new File("org/unicode/text/UCD/");
System.out.println(f2.getAbsolutePath());
TransliteratorUtilities.registerTransliteratorFromFile(
Settings.SRC_UCD_DIR, "any-temp");
UseTransliterator.class.getResource(".").getPath(), "any-temp");
final Transliterator t = Transliterator.getInstance("any-temp");
final File f = new File(filename);
final String fileContents =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,4 @@ public static void ensureOutputDir(String dir) {
}
}
}

public static final String SRC_DIR =
Utility.fixFileName(UnicodeTools.UNICODETOOLS_RSRC_DIR + "org/unicode/text") + "/";

/** Used for data files */
public static final String SRC_UCA_DIR = SRC_DIR + "UCA/";

/** Used for data files */
public static final String SRC_UCD_DIR = SRC_DIR + "UCD/";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.IOException;
import java.io.PrintWriter;
import org.unicode.text.UCD.Default;
import org.unicode.text.UCD.MakeUnicodeFiles;
import org.unicode.text.utility.Utility.RuntimeIOException;

public class UnicodeDataFile {
Expand Down Expand Up @@ -70,7 +71,12 @@ private UnicodeDataFile(String directory, String filename, boolean isHTML) throw
}
try {
Utility.appendFile(
Settings.SRC_UCD_DIR + filename + "Header" + fileType, Utility.UTF8_UNIX, out);
MakeUnicodeFiles.class.getResource(".").getPath()
+ filename
+ "Header"
+ fileType,
Utility.UTF8_UNIX,
out);
} catch (final RuntimeIOException e) {
if (!(e.getCause() instanceof FileNotFoundException)) {
throw e;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# [Template for property comparison tests of character encoding proposals]
# [RMG ISSUE TITLE]
# https://github.com/unicode-org/utc-release-management/issues/[RMG ISSUE NUMBER]
# Tangut: Two Tangut ideographs (18D1D..18D1E)
# https://github.com/unicode-org/utc-release-management/issues/154

# Names always differ.
# Age always differs since these tests are comparing additions to pre-existing characters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public class TestTestUnicodeInvariants {
void testSRC_UCD_DIR() {
assertAll(
"assert that no components of Settings.SRC_UCD_DIR are null",
() -> assertNotNull(Settings.SRC_UCD_DIR, "Settings.SRC_UCD_DIR"),
() -> assertNotNull(Settings.SRC_DIR, "Settings.SRC_DIR"),
() ->
assertNotNull(
Settings.UnicodeTools.UNICODETOOLS_RSRC_DIR,
Expand All @@ -42,7 +40,10 @@ void testUnicodeInvariants() throws IOException {

@Test
void testAdditionComparisons() throws IOException {
final var directory = new File(Settings.SRC_DIR + "UCD/AdditionComparisons/");
final var directory = new File(getClass().getResource("AdditionComparisons").getPath());
if (!directory.exists()) {
throw new IOException(directory.getAbsolutePath() + " does not exist");
}
int rc = 0;
for (var file : directory.listFiles()) {
final String filename = file.getName();
Expand Down
Loading