Skip to content

Commit

Permalink
LikelySubtags: update test generation and Node executor
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-oly committed Aug 21, 2023
1 parent f30c7fb commit cde3deb
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 36 deletions.
11 changes: 6 additions & 5 deletions executors/node/likely_subtags.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@

module.exports = {
testLikelySubtags: function (json) {
const label = json['label'];
const locale = json['locale'];
let test_option;
if (json['option']) {
test_option = json['option'];
}

const locale = json['locale'];

// TESTING
const label = json['label'];
let return_json = {"label": label};
let intl_locale;
try {
Expand All @@ -28,8 +26,11 @@ module.exports = {
let result_locale;
if (test_option === 'maximize') {
result_locale = intl_locale.maximize().baseName;
} else if (test_option === 'minimize') {
} else if (test_option === 'minimizeFavorScript' ||
test_option === 'minimize') {
result_locale = intl_locale.minimize().baseName;
} else if (test_option === 'minimizeFavorRegion') {
result_locale = intl_locale.minimizeFavorRegion().baseName;
} else {
return_json['error'] = 'Unknown test option = ' + test_option;
}
Expand Down
7 changes: 4 additions & 3 deletions testdriver/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def process_batch_of_tests(self, tests_to_send):
logging.info('#### DEBUG OUTPUT = %s', item)

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

return batch_out
Expand Down
74 changes: 47 additions & 27 deletions testgen/testdata_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,43 +202,63 @@ def processLikelySubtagsData(self):
# split at ";" and ignore whitespace
tags = list(map(str.strip, line.split(';')))
# This should give 3 items
if len(tags) < 3:
logging.warning('Likely subtags: count of tages != 3: %s',
line)
continue

# Create 3 minimize tests
expected = tags[2]
for index in range(0, 3):
label = str(count).rjust(max_digits, '0')
locale = tags[index]
test_min = {'label': label,
'locale': locale,
'option': 'minimize'
}
verify = {'label': label,
'verify': expected
}
test_list.append(test_min)
verify_list.append(verify)
count += 1

# And 3 maximize tests
expected = tags[1]
for index in range(0, 3):
if line.find('FAIL') >= 0:
# What do do with this?
pass

# Create minimize tests - default is RemoveFavorScript
if tags[2]:
remove_favor_script = tags[2]
for tag in tags:
if tag == '':
continue
label = str(count).rjust(max_digits, '0')
test_min = {'label': label,
'locale': tag,
'option': 'minimize'
}
verify = {'label': label,
'verify': remove_favor_script
}
test_list.append(test_min)
verify_list.append(verify)
count += 1

# And maximize from each tag
add_likely = tags[1]
for tag in tags:
if tag == '':
continue
label = str(count).rjust(max_digits, '0')
locale = tags[index]
test_max = {'label': label,
'locale': locale,
'locale': tag,
'option': 'maximize'
}
verify = {'label': label,
'verify': expected
'verify': add_likely
}
test_list.append(test_max)
verify_list.append(verify)
count += 1

# And check for minimizing with favored script is supported
if tags[3]:
remove_favor_region = tags[3]
for tag in tags:
if tag == '':
continue
label = str(count).rjust(max_digits, '0')
test_max = {'label': label,
'locale': tag,
'option': 'minimizeFavorRegion'
}
verify = {'label': label,
'verify': remove_favor_region
}
test_list.append(test_max)
verify_list.append(verify)
count += 1

# Add to the test and verify json data
json_test['tests'] = test_list
json_verify['verifications'] = verify_list
Expand Down
2 changes: 1 addition & 1 deletion verifier/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def verify_data_results(self):

# Save the results
if not self.report.save_report():
print('!!! Count not save report for (%s, %s)',
print('!!! Could not save report for (%s, %s)',
vplan.test_type, self.exec)
else:
self.report.create_html_report()
Expand Down

0 comments on commit cde3deb

Please sign in to comment.