1# Copyright (C) 2018 and later: Unicode, Inc. and others. 2# License & terms of use: http://www.unicode.org/copyright.html 3 4from icutools.databuilder import * 5from icutools.databuilder.request_types import * 6 7 8def generate(config, io, common_vars): 9 requests = [] 10 requests += generate_rb(config, io, common_vars) 11 requests += generate_sprep(config, io, common_vars) 12 requests += generate_conv(config, io, common_vars) 13 requests += generate_other(config, io, common_vars) 14 requests += generate_copy(config, io, common_vars) 15 16 requests += [ 17 ListRequest( 18 name = "testdata_list", 19 variable_name = "testdata_all_output_files", 20 output_file = TmpFile("testdata.lst"), 21 include_tmp = True 22 ) 23 ] 24 25 return requests 26 27 28def generate_rb(config, io, common_vars): 29 basenames = [ 30 "calendar", 31 "casing", 32 "conversion", 33 "format", 34 "icuio", 35 "idna_rules", 36 "mc", 37 "root", 38 "sh_YU", 39 "sh", 40 "structLocale", 41 "te_IN_REVISED", 42 "te_IN", 43 "te", 44 "testaliases", 45 "testempty", 46 "testtypes", 47 # "metaZones", 48 # "timezoneTypes", 49 # "windowsZones", 50 ] 51 return [ 52 # Inference rule for creating resource bundles 53 # Some test data resource bundles are known to have warnings and bad data. 54 # The -q option is there on purpose, so we don't see it normally. 55 # TODO: Use option -k? 56 RepeatedExecutionRequest( 57 name = "testrb", 58 category = "tests", 59 input_files = [InFile("%s.txt" % bn) for bn in basenames], 60 output_files = [OutFile("%s.res" % bn) for bn in basenames], 61 tool = IcuTool("genrb"), 62 args = "-q -s {IN_DIR} -d {OUT_DIR} {INPUT_FILE}", 63 format_with = {}, 64 repeat_with = {} 65 ), 66 # Other standalone res files 67 SingleExecutionRequest( 68 name = "encoded", 69 category = "tests", 70 input_files = [InFile("encoded.utf16be")], 71 output_files = [OutFile("encoded.res")], 72 tool = IcuTool("genrb"), 73 args = "-s {IN_DIR} -eUTF-16BE -d {OUT_DIR} {INPUT_FILES[0]}", 74 format_with = {} 75 ), 76 SingleExecutionRequest( 77 name = "zoneinfo64", 78 category = "tests", 79 input_files = [InFile("zoneinfo64.txt")], 80 output_files = [TmpFile("zoneinfo64.res")], 81 tool = IcuTool("genrb"), 82 args = "-s {IN_DIR} -d {TMP_DIR} {INPUT_FILES[0]}", 83 format_with = {} 84 ), 85 SingleExecutionRequest( 86 name = "filtertest", 87 category = "tests", 88 input_files = [InFile("filtertest.txt")], 89 output_files = [OutFile("filtertest.res")], 90 tool = IcuTool("genrb"), 91 args = "-s {IN_DIR} -d {OUT_DIR} -i {OUT_DIR} " 92 "--filterDir {IN_DIR}/filters filtertest.txt", 93 format_with = {} 94 ) 95 ] 96 97 98def generate_sprep(config, io, common_vars): 99 return [ 100 SingleExecutionRequest( 101 name = "nfscsi", 102 category = "tests", 103 input_files = [InFile("nfs4_cs_prep_ci.txt")], 104 output_files = [OutFile("nfscsi.spp")], 105 tool = IcuTool("gensprep"), 106 args = "-s {IN_DIR} -d {OUT_DIR} -b nfscsi -u 3.2.0 {INPUT_FILES[0]}", 107 format_with = {} 108 ), 109 SingleExecutionRequest( 110 name = "nfscss", 111 category = "tests", 112 input_files = [InFile("nfs4_cs_prep_cs.txt")], 113 output_files = [OutFile("nfscss.spp")], 114 tool = IcuTool("gensprep"), 115 args = "-s {IN_DIR} -d {OUT_DIR} -b nfscss -u 3.2.0 {INPUT_FILES[0]}", 116 format_with = {} 117 ), 118 SingleExecutionRequest( 119 name = "nfscis", 120 category = "tests", 121 input_files = [InFile("nfs4_cis_prep.txt")], 122 output_files = [OutFile("nfscis.spp")], 123 tool = IcuTool("gensprep"), 124 args = "-s {IN_DIR} -d {OUT_DIR} -b nfscis -u 3.2.0 -k -n {IN_DIR}/../../data/unidata {INPUT_FILES[0]}", 125 format_with = {} 126 ), 127 SingleExecutionRequest( 128 name = "nfsmxs", 129 category = "tests", 130 input_files = [InFile("nfs4_mixed_prep_s.txt")], 131 output_files = [OutFile("nfsmxs.spp")], 132 tool = IcuTool("gensprep"), 133 args = "-s {IN_DIR} -d {OUT_DIR} -b nfsmxs -u 3.2.0 -k -n {IN_DIR}/../../data/unidata {INPUT_FILES[0]}", 134 format_with = {} 135 ), 136 SingleExecutionRequest( 137 name = "nfsmxp", 138 category = "tests", 139 input_files = [InFile("nfs4_mixed_prep_p.txt")], 140 output_files = [OutFile("nfsmxp.spp")], 141 tool = IcuTool("gensprep"), 142 args = "-s {IN_DIR} -d {OUT_DIR} -b nfsmxp -u 3.2.0 -k -n {IN_DIR}/../../data/unidata {INPUT_FILES[0]}", 143 format_with = {} 144 ) 145 ] 146 147 148def generate_conv(config, io, common_vars): 149 basenames = [ 150 "test1", 151 "test1bmp", 152 "test2", 153 "test3", 154 "test4", 155 "test4x", 156 "test5", 157 "ibm9027" 158 ] 159 return [ 160 RepeatedExecutionRequest( 161 name = "test_conv", 162 category = "tests", 163 input_files = [InFile("%s.ucm" % bn) for bn in basenames], 164 output_files = [OutFile("%s.cnv" % bn) for bn in basenames], 165 tool = IcuTool("makeconv"), 166 args = "--small -d {OUT_DIR} {IN_DIR}/{INPUT_FILE}", 167 format_with = {}, 168 repeat_with = {} 169 ) 170 ] 171 172 173def generate_copy(config, io, common_vars): 174 return [ 175 CopyRequest( 176 name = "nam_typ", 177 input_file = OutFile("te.res"), 178 output_file = TmpFile("nam.typ") 179 ), 180 CopyRequest( 181 name = "old_l_testtypes", 182 input_file = InFile("old_l_testtypes.res"), 183 output_file = OutFile("old_l_testtypes.res") 184 ), 185 CopyRequest( 186 name = "old_e_testtypes", 187 input_file = InFile("old_e_testtypes.res"), 188 output_file = OutFile("old_e_testtypes.res") 189 ), 190 ] 191 192 193def generate_other(config, io, common_vars): 194 return [ 195 SingleExecutionRequest( 196 name = "testnorm", 197 category = "tests", 198 input_files = [InFile("testnorm.txt")], 199 output_files = [OutFile("testnorm.nrm")], 200 tool = IcuTool("gennorm2"), 201 args = "-s {IN_DIR} {INPUT_FILES[0]} -o {OUT_DIR}/{OUTPUT_FILES[0]}", 202 format_with = {} 203 ), 204 SingleExecutionRequest( 205 name = "test_icu", 206 category = "tests", 207 input_files = [], 208 output_files = [OutFile("test.icu")], 209 tool = IcuTool("gentest"), 210 args = "-d {OUT_DIR}", 211 format_with = {} 212 ), 213 SingleExecutionRequest( 214 name = "testtable32_txt", 215 category = "tests", 216 input_files = [], 217 output_files = [TmpFile("testtable32.txt")], 218 tool = IcuTool("gentest"), 219 args = "-r -d {TMP_DIR}", 220 format_with = {} 221 ), 222 SingleExecutionRequest( 223 name = "testtable32_res", 224 category = "tests", 225 input_files = [TmpFile("testtable32.txt")], 226 output_files = [OutFile("testtable32.res")], 227 tool = IcuTool("genrb"), 228 args = "-s {TMP_DIR} -d {OUT_DIR} {INPUT_FILES[0]}", 229 format_with = {} 230 ) 231 ] 232