From 7fc5946efdb83397bfe4d332669998ab4a1deaa4 Mon Sep 17 00:00:00 2001 From: Helena Aytenfisu Date: Mon, 9 Sep 2024 09:31:29 -0700 Subject: [PATCH] CLDR-15817 Modify test to check only paths shown to users --- .../unicode/cldr/test/ExampleGenerator.java | 2 +- .../cldr/unittest/TestExampleGenerator.java | 44 ++++++++++++++----- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java index f3bfe294136..60ff3deea46 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java @@ -2463,7 +2463,7 @@ private void handleDateFormatItem( cldrFile.getWinningPath(xpath.replaceAll("dateTimeFormat", "timeFormat")); int tfLengthOffset = timeFormatXPathForPrefix.indexOf("timeFormatLength"); if (tfLengthOffset < 0) { - examples.add(""); + // examples.add(""); return; } String timeFormatXPathPrefix = timeFormatXPathForPrefix.substring(0, tfLengthOffset); diff --git a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestExampleGenerator.java b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestExampleGenerator.java index e018bfbc397..6361bf5aa54 100644 --- a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestExampleGenerator.java +++ b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestExampleGenerator.java @@ -2080,6 +2080,28 @@ public String sampleAttrAndValue(PathStarrer ps, final String separator, String return ps.getAttributesString(separator) + "➔«" + value + "»"; } + PathHeader.Factory phf = PathHeader.getFactory(null); + + private boolean isValidPath(String xpath, ULocale locale) { + PathHeader ph = phf.fromPath(xpath); + if (ph == null) { + return false; + } + if (ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.DEPRECATED) { + return false; + } + if (ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.HIDE + || ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.READ_ONLY) { + return false; + } + + if (SDI.getCoverageValue(xpath, locale.getBaseName()) + > org.unicode.cldr.util.Level.COMPREHENSIVE.getLevel()) { + return false; + } + return true; + } + public void TestRefactoring() { for (ULocale locale : ULocale.getAvailableLocales()) { String loc = locale.toString(); @@ -2089,16 +2111,18 @@ public void TestRefactoring() { ExampleGeneratorOld exampleGeneratorOld = new ExampleGeneratorOld(resolvedCldrFile, info.getEnglish()); for (String path : unresolvedCldrFile) { - String value = unresolvedCldrFile.getStringValue(path); - String oldExample = exampleGeneratorOld.getExampleHtml(path, value); - String newExample = exampleGenerator.getExampleHtml(path, value); - assertEquals( - "Ensure same example pre/post refactoring for locale: " - + loc - + "and path: " - + path, - oldExample, - newExample); + if (isValidPath(path, locale)) { + String value = unresolvedCldrFile.getStringValue(path); + String oldExample = exampleGeneratorOld.getExampleHtml(path, value); + String newExample = exampleGenerator.getExampleHtml(path, value); + assertEquals( + "Ensure same example pre/post refactoring for locale: " + + loc + + "and path: " + + path, + oldExample, + newExample); + } } } }