Skip to content

Commit cde3deb

Browse files
committed
LikelySubtags: update test generation and Node executor
1 parent f30c7fb commit cde3deb

File tree

4 files changed

+58
-36
lines changed

4 files changed

+58
-36
lines changed

executors/node/likely_subtags.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55

66
module.exports = {
77
testLikelySubtags: function (json) {
8+
const label = json['label'];
9+
const locale = json['locale'];
810
let test_option;
911
if (json['option']) {
1012
test_option = json['option'];
1113
}
1214

13-
const locale = json['locale'];
14-
15-
// TESTING
16-
const label = json['label'];
1715
let return_json = {"label": label};
1816
let intl_locale;
1917
try {
@@ -28,8 +26,11 @@ module.exports = {
2826
let result_locale;
2927
if (test_option === 'maximize') {
3028
result_locale = intl_locale.maximize().baseName;
31-
} else if (test_option === 'minimize') {
29+
} else if (test_option === 'minimizeFavorScript' ||
30+
test_option === 'minimize') {
3231
result_locale = intl_locale.minimize().baseName;
32+
} else if (test_option === 'minimizeFavorRegion') {
33+
result_locale = intl_locale.minimizeFavorRegion().baseName;
3334
} else {
3435
return_json['error'] = 'Unknown test option = ' + test_option;
3536
}

testdriver/testplan.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def process_batch_of_tests(self, tests_to_send):
411411
logging.info('#### DEBUG OUTPUT = %s', item)
412412

413413
# Process some types of errors
414-
if item[1:3] == "!!":
414+
if item[1:3] == "!!" and self.debug > 1:
415415
logging.warning(" !!!!!!!!!!!!!!!!! ERROR: %s", item)
416416
# Extract the message and check if we continue or not.
417417
json_start = item.index('{')
@@ -426,8 +426,9 @@ def process_batch_of_tests(self, tests_to_send):
426426
json_out = json.loads(item)
427427
batch_out.append(json_out)
428428
except BaseException as error:
429-
logging.warning(' && Item %s. Error in= %s. Received (%d): >%s<',
430-
index, error, len(item), item)
429+
if self.debug > 1:
430+
logging.warning(' && Item %s. Error in= %s. Received (%d): >%s<',
431+
index, error, len(item), item)
431432
index += 1
432433

433434
return batch_out

testgen/testdata_gen.py

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -202,43 +202,63 @@ def processLikelySubtagsData(self):
202202
# split at ";" and ignore whitespace
203203
tags = list(map(str.strip, line.split(';')))
204204
# This should give 3 items
205-
if len(tags) < 3:
206-
logging.warning('Likely subtags: count of tages != 3: %s',
207-
line)
208-
continue
209-
210-
# Create 3 minimize tests
211-
expected = tags[2]
212-
for index in range(0, 3):
213-
label = str(count).rjust(max_digits, '0')
214-
locale = tags[index]
215-
test_min = {'label': label,
216-
'locale': locale,
217-
'option': 'minimize'
218-
}
219-
verify = {'label': label,
220-
'verify': expected
221-
}
222-
test_list.append(test_min)
223-
verify_list.append(verify)
224-
count += 1
225-
226-
# And 3 maximize tests
227-
expected = tags[1]
228-
for index in range(0, 3):
205+
if line.find('FAIL') >= 0:
206+
# What do do with this?
207+
pass
208+
209+
# Create minimize tests - default is RemoveFavorScript
210+
if tags[2]:
211+
remove_favor_script = tags[2]
212+
for tag in tags:
213+
if tag == '':
214+
continue
215+
label = str(count).rjust(max_digits, '0')
216+
test_min = {'label': label,
217+
'locale': tag,
218+
'option': 'minimize'
219+
}
220+
verify = {'label': label,
221+
'verify': remove_favor_script
222+
}
223+
test_list.append(test_min)
224+
verify_list.append(verify)
225+
count += 1
226+
227+
# And maximize from each tag
228+
add_likely = tags[1]
229+
for tag in tags:
230+
if tag == '':
231+
continue
229232
label = str(count).rjust(max_digits, '0')
230-
locale = tags[index]
231233
test_max = {'label': label,
232-
'locale': locale,
234+
'locale': tag,
233235
'option': 'maximize'
234236
}
235237
verify = {'label': label,
236-
'verify': expected
238+
'verify': add_likely
237239
}
238240
test_list.append(test_max)
239241
verify_list.append(verify)
240242
count += 1
241243

244+
# And check for minimizing with favored script is supported
245+
if tags[3]:
246+
remove_favor_region = tags[3]
247+
for tag in tags:
248+
if tag == '':
249+
continue
250+
label = str(count).rjust(max_digits, '0')
251+
test_max = {'label': label,
252+
'locale': tag,
253+
'option': 'minimizeFavorRegion'
254+
}
255+
verify = {'label': label,
256+
'verify': remove_favor_region
257+
}
258+
test_list.append(test_max)
259+
verify_list.append(verify)
260+
count += 1
261+
242262
# Add to the test and verify json data
243263
json_test['tests'] = test_list
244264
json_verify['verifications'] = verify_list

verifier/verifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def verify_data_results(self):
245245

246246
# Save the results
247247
if not self.report.save_report():
248-
print('!!! Count not save report for (%s, %s)',
248+
print('!!! Could not save report for (%s, %s)',
249249
vplan.test_type, self.exec)
250250
else:
251251
self.report.create_html_report()

0 commit comments

Comments
 (0)