[Unicode]   Common Locale Data Repository : Bug Tracking Home | Site Map | Search
 

Changeset 13597


Ignore:
Timestamp:
09/01/17 05:49:24 (15 months ago)
Author:
mdavis
Message:

cldrbug 10590: Small cleanups to check for errors better

Location:
trunk/tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/cldr-unittest/src/org/unicode/cldr/unittest/TestCoverage.java

    r13521 r13597  
    88import java.util.Set; 
    99 
     10import org.unicode.cldr.test.CoverageLevel2; 
    1011import org.unicode.cldr.util.CLDRConfig; 
    1112import org.unicode.cldr.util.CLDRFile; 
     13import org.unicode.cldr.util.CLDRLocale; 
    1214import org.unicode.cldr.util.CoreCoverageInfo; 
    1315import org.unicode.cldr.util.CoreCoverageInfo.CoreItems; 
    1416import org.unicode.cldr.util.LanguageTagParser; 
    1517import org.unicode.cldr.util.Level; 
     18import org.unicode.cldr.util.PathHeader; 
    1619import org.unicode.cldr.util.StandardCodes; 
    1720import org.unicode.cldr.util.SupplementalDataInfo; 
     
    4043            showDiff("Missing", all, coreCoverage); 
    4144        } 
    42         CLDRFile skimpyLocale = testInfo.getCldrFactory().make("aa", false); 
     45        CLDRFile skimpyLocale = testInfo.getCldrFactory().make("asa", false); 
    4346        errors.clear(); 
    4447        coreCoverage = CoreCoverageInfo.getCoreCoverageInfo(skimpyLocale, 
     
    4851            showDiff("Missing", all, coreCoverage); 
    4952            showDiff("Extra", coreCoverage, none); 
     53        } 
     54    } 
     55     
     56    public void TestSelected() { 
     57        Object[][] tests = { 
     58            {"en", "//ldml/numbers/minimalPairs/ordinalMinimalPairs[@ordinal=\"other\"]", Level.MODERN, 20}, 
     59            {"en", "//ldml/numbers/minimalPairs/pluralMinimalPairs[@count=\"other\"]", Level.MODERN, 20} 
     60        }; 
     61        PathHeader.Factory phf = PathHeader.getFactory(testInfo.getEnglish()); 
     62        for (Object[] test : tests) { 
     63            String localeId = (String) test[0]; 
     64            String path = (String) test[1]; 
     65            Level expectedLevel = (Level) test[2]; 
     66            CoverageLevel2 coverageLevel = CoverageLevel2.getInstance(sdi, localeId); 
     67            Level level = coverageLevel.getLevel(path); 
     68            PathHeader ph = phf.fromPath(path); 
     69            CLDRLocale loc = CLDRLocale.getInstance(localeId); 
     70            int expectedVotes = sdi.getRequiredVotes(loc , ph); 
     71             
    5072        } 
    5173    } 
  • trunk/tools/java/org/unicode/cldr/test/CheckForExemplars.java

    r13588 r13597  
    187187        boolean[] ok = new boolean[1]; 
    188188        exemplars = safeGetExemplars("", possibleErrors, resolvedFile, ok); 
    189         if (!ok[0]) exemplars = new UnicodeSet(); 
    190189 
    191190        if (exemplars == null) { 
     
    195194            possibleErrors.add(item); 
    196195            return this; 
    197         } 
     196        } else if (!ok[0]) { 
     197            exemplars = new UnicodeSet(); 
     198        } else { 
     199            exemplars = new UnicodeSet(exemplars); // modifiable copy 
     200        } 
     201 
    198202         
    199203        boolean isRTL = RTL.containsSome(exemplars); 
     
    431435                } 
    432436            } 
     437        } else if (path.contains("/annotations") && !path.contains("[@type"))  { 
     438            if (null != (disallowed = containsAllCountingParens(exemplars, exemplarsPlusAscii, value))) { 
     439                addMissingMessage(disallowed, CheckStatus.warningType, Subtype.charactersNotInMainOrAuxiliaryExemplars, 
     440                    Subtype.asciiCharactersNotInMainOrAuxiliaryExemplars, "are not in the exemplar characters", result); 
     441            } 
    433442        } else { 
    434443            if (null != (disallowed = containsAllCountingParens(exemplars, exemplarsPlusAscii, value))) { 
  • trunk/tools/java/org/unicode/cldr/test/ConsoleCheckCLDR.java

    r13588 r13597  
    123123 
    124124    enum MyOptions { 
    125         coverage(new Params().setHelp("Set the coverage: eg -c comprehensive or -c modern or -c moderate or -c basic") 
     125        coverage(new Params().setHelp("Set the coverage: eg -c comprehensive") 
    126126            .setMatch("comprehensive|modern|moderate|basic")), // UOption.REQUIRES_ARG 
    127127        examples(new Params().setHelp("Turn on examples (actually a summary of the demo)") 
     
    132132            .setDefault(".*").setMatch(".*")), //, 't', UOption.REQUIRES_ARG).setDefault(".*"), 
    133133        date_formats(new Params().setHelp("Turn on special date format checks")), //, 'd', UOption.NO_ARG), 
    134         organization(new Params().setHelp("Organization: ibm, google, ....; filters locales and uses Locales.txt for coverage tests") 
     134        organization(new Params().setHelp("Organization: ibm, google, ....; Uses Locales.txt for to filter locales and set coverage levels") 
    135135            .setDefault(".*").setMatch(".*")), //, 'o', UOption.REQUIRES_ARG), 
    136136        showall(new Params().setHelp("Show all paths, including aliased").setFlag('a')), //, 'a', UOption.NO_ARG), 
     
    141141            .setFlag('k')), //, 'k', UOption.NO_ARG), 
    142142        noaliases(new Params().setHelp("No aliases")), //, 'n', UOption.NO_ARG), 
    143         source_directory(new Params() 
     143        source_directory(new Params().setHelp("Fully qualified source directories. (Conflicts with -S.)") 
    144144            .setDefault(SOURCE_DIRS).setMatch(".*")), //, 's', UOption.REQUIRES_ARG).setDefault(SOURCE_DIRS), 
    145145        user(new Params().setHelp("User, eg -uu148") 
     
    153153        subtype_filter(new Params().setHelp("error/warning subtype filter, eg unexpectedOrderOfEraYear") 
    154154            .setDefault(".*").setMatch(".*").setFlag('y')), //, 'y', UOption.REQUIRES_ARG), 
    155         source_all(new Params().setHelp("Use multiple directories. (Don't use this with -s.)") 
    156             .setMatch(".*").setFlag('S').setDefault("common,seed")), //, 'S', <changed>), 
     155        source_all(new Params().setHelp("Partially qualified directories. Standard subdirectories added if not specified (/main, /annotations, /subdivisions). (Conflicts with -s.)") 
     156            .setMatch(".*").setFlag('S').setDefault("common,seed,exemplars")), //, 'S', <changed>), 
    157157        bailey(new Params().setHelp("check bailey values (↑↑↑)")), //, 'b', UOption.NO_ARG) 
    158158        exemplarError(new Params().setFlag('E').setHelp("include to force strict Exemplar check")) 
     
    196196        UOption.create("id view", 'i', UOption.NO_ARG), 
    197197        UOption.create("subtype_filter", 'y', UOption.REQUIRES_ARG), 
    198         UOption.create("source_all", 'S', UOption.OPTIONAL_ARG).setDefault("common,seed"), 
     198        UOption.create("source_all", 'S', UOption.OPTIONAL_ARG).setDefault("common,seed,exemplars"), 
    199199        UOption.create("bailey", 'b', UOption.NO_ARG), 
    200200        UOption.create("exemplarError", 'E', UOption.NO_ARG) 
     
    254254        //CldrUtility.showOptions(args); 
    255255        UOption.parseArgs(args, options); 
    256         if (options[HELP1].doesOccur || options[HELP2].doesOccur) { 
    257             for (int i = 0; i < HelpMessage.length; ++i) { 
    258                 System.out.println(HelpMessage[i]); 
    259             } 
    260             return; 
    261         } 
     256//        if (options[HELP1].doesOccur || options[HELP2].doesOccur) { 
     257//            for (int i = 0; i < HelpMessage.length; ++i) { 
     258//                System.out.println(HelpMessage[i]); 
     259//            } 
     260//            return; 
     261//        } 
    262262        String factoryFilter = options[FILE_FILTER].value;  
    263263        if (factoryFilter.equals("key")) { 
     
    358358        File sourceDirectories[] = null; 
    359359 
    360         if (options[SOURCE_ALL].doesOccur) { 
    361             if (options[SOURCE_DIRECTORY].doesOccur) { 
     360        if (MyOptions.source_all.option.doesOccur()) { 
     361            if (MyOptions.source_directory.option.doesOccur()) { 
    362362                throw new IllegalArgumentException("Don't use -s and -S together."); 
    363363            } 
    364             sourceDirectories = cldrConf.getMainDataDirectories(cldrConf.getCLDRDataDirectories(options[SOURCE_ALL].value)); 
     364            sourceDirectories = cldrConf.getMainDataDirectories(cldrConf.getCLDRDataDirectories(MyOptions.source_all.option.getValue())); 
    365365        } else { 
    366366            String[] sdirs = options[SOURCE_DIRECTORY].value.split(",\\s*"); 
     
    433433        } 
    434434        System.out.println("filtered tests: " + checkCldr.getFilteredTests()); 
    435         try { 
    436             english = cldrFactory.make("en", true); 
    437         } catch (Exception e1) { 
    438             Factory backCldrFactory = Factory.make(CLDRPaths.MAIN_DIRECTORY, factoryFilter) 
    439                 .setSupplementalDirectory(new File(CLDRPaths.SUPPLEMENTAL_DIRECTORY)); 
    440             english = backCldrFactory.make("en", true); 
    441         } 
     435        Factory backCldrFactory = Factory.make(CLDRPaths.MAIN_DIRECTORY, factoryFilter) 
     436            .setSupplementalDirectory(new File(CLDRPaths.SUPPLEMENTAL_DIRECTORY)); 
     437        english = backCldrFactory.make("en", true); 
     438         
    442439        checkCldr.setDisplayInformation(english); 
    443440        checkCldr.setEnglishFile(english); 
  • trunk/tools/java/org/unicode/cldr/tool/Option.java

    r13588 r13597  
    171171    } 
    172172 
     173    static final String PAD = "                    "; 
     174 
    173175    public String toString() { 
    174         return "-" + flag + " (" + tag + ") \t" 
    175             + (match == null ? "no-arg" : match.pattern()) + " \t" + helpString; 
     176        return "-" + flag  
     177            + " (" + tag + ")"  
     178            + PAD.substring(Math.min(tag.length(), PAD.length())) 
     179            + (match == null ? "no-arg" : "match: " + match.pattern())  
     180            + (defaultArgument == null ? "" : " \tdefault=" + defaultArgument) 
     181            + " \t" + helpString 
     182            ; 
    176183    } 
    177184 
  • trunk/tools/java/org/unicode/cldr/util/CLDRConfig.java

    r13588 r13597  
    1919import com.google.common.cache.CacheLoader; 
    2020import com.google.common.cache.LoadingCache; 
     21import com.google.common.collect.ImmutableSet; 
    2122import com.ibm.icu.dev.test.TestFmwk; 
    2223import com.ibm.icu.dev.test.TestLog; 
     
    537538    private static final String MAIN_DIR = "main"; 
    538539    private static final String ANNOTATIONS_DIR = "annotations"; 
    539      
     540    private static final String SUBDIVISIONS_DIR = "subdivisions"; 
     541 
    540542    /** 
    541543     * TODO: better place for these constants? 
     
    552554 
    553555    /** 
    554      * given comma separated list "common" or "common,main" return a list of actual files 
     556     * Given comma separated list "common" or "common,main" return a list of actual files. 
     557     * Adds subdirectories in STANDARD_SUBDIRS as necessary. 
    555558     */ 
    556559    public File[] getCLDRDataDirectories(String list) { 
     
    564567    } 
    565568 
    566     /** 
    567      * map "common","seed" -> "common/main", "seed/main" 
     569    static final ImmutableSet<String> STANDARD_SUBDIRS = ImmutableSet.of(MAIN_DIR, ANNOTATIONS_DIR, SUBDIVISIONS_DIR); 
     570     
     571    /** 
     572     * Add subdirectories to file list as needed, from STANDARD_SUBDIRS. 
     573     * <ul><li>map "common","seed" -> "common/main", "seed/main" 
     574     * <li>but common/main -> common/main 
     575     * </ul> 
    568576     */ 
    569577    public File[] getMainDataDirectories(File base[]) { 
     
    571579        //File[] ret = new File[base.length * 2]; 
    572580        for (int i = 0; i < base.length; i++) { 
    573             ret.add(new File(base[i], MAIN_DIR)); 
    574             ret.add(new File(base[i], ANNOTATIONS_DIR)); 
     581            File baseFile = base[i]; 
     582            String name = baseFile.getName(); 
     583            if (STANDARD_SUBDIRS.contains(name)) { 
     584                ret.add(baseFile); 
     585            } else { 
     586                for (String sub : STANDARD_SUBDIRS) { 
     587                    File file = new File(baseFile, sub); 
     588                    if (file.exists()) { 
     589                        ret.add(file); 
     590                    } 
     591                } 
     592            } 
    575593        } 
    576594        return ret.toArray(new File[ret.size()]); 
     
    677695    private CLDRURLS urls = null; 
    678696    private CLDRURLS absoluteUrls = null; 
    679      
     697 
    680698    public boolean isCldrVersionBefore(int... version) { 
    681699        return getEnglish().getDtdVersionInfo() 
Note: See TracChangeset for help on using the changeset viewer.