Skip to content

Commit

Permalink
Add hash for test data (unicode-org#252)
Browse files Browse the repository at this point in the history
* Adding ICU4C running collation tests - first try

* Cache ICU4C binaries in GH and locally, only if they don't exist

* Install JSON-C dependency if not installed at beginning of CI or e2e script

* Fix bash if condition syntax

* Hash code for tests and updating schema

* Adding hex hash to all tests data

* updating hexhash generation for tests

* Add common hash function for JavaScript

* Clean up some unneeded warning/error messges

* Revise white space

* Update testgen/generators/generate_test_hash.js

Co-authored-by: Shane F. Carr <[email protected]>

---------

Co-authored-by: Elango Cheran <[email protected]>
Co-authored-by: Shane F. Carr <[email protected]>
  • Loading branch information
3 people authored Jul 15, 2024
1 parent 7567db8 commit b08229f
Show file tree
Hide file tree
Showing 19 changed files with 329 additions and 45 deletions.
7 changes: 5 additions & 2 deletions schema/check_generated_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,18 @@ def main(args):
# Create .json
summary_json = {
'validation_type': 'Generated test data files',
'description': 'Results of validating generated test data agains schema',
'description': 'Results of validating generated test data against schema',
'when_processed': datetime.now().strftime('%Y-%m-%d T%H%M%S.%f'),
'validations': {
'failed': failed_validations,
'passed': passed_validations
}
}

summary_data = json.dumps(summary_json)
try:
summary_data = json.dumps(summary_json)
except BaseException as error:
logging.error('json.dumps Summary data problem: %s, ')

try:
output_filename = os.path.join(test_data_path, 'test_data_validation_summary.json')
Expand Down
4 changes: 4 additions & 0 deletions schema/collation_short/test_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"description": "A numeric ID, unique for the set of tests",
"type": "string"
},
"hexhash": {
"description": "A hexadecimal hash code for the test without the label",
"type": "string"
},
"s1": {
"description": "First string for comparison",
"type": "string"
Expand Down
4 changes: 4 additions & 0 deletions schema/datetime_fmt/test_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"description": "A numeric ID, unique for the set of tests",
"type": "string"
},
"hexhash": {
"description": "A hexadecimal hash code for the test without the label",
"type": "string"
},
"locale": {
"description": "language tag for formatting the output",
"type": "string"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
"description": "A numeric ID, unique for the set of tests",
"type": "string"
},
"hexhash": {
"description": "A hexadecimal hash code for the test without the label",
"type": "string"
},
"language_label": {
"description": "locale tag of the source language ",
"type": "string"
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions schema/likely_subtags/test_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"description": "A numeric ID, unique for the set of tests",
"type": "string"
},
"hexhash": {
"description": "A hexadecimal hash code for the test without the label",
"type": "string"
},
"locale": {
"description": "locale tag source ",
"type": "string"
Expand Down
4 changes: 4 additions & 0 deletions schema/list_fmt/test_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
"description": "A numeric ID, unique for the set of tests",
"type": "string"
},
"hexhash": {
"description": "A hexadecimal hash code for the test without the label",
"type": "string"
},
"locale": {
"description": "locale tag source ",
"type": "string"
Expand Down
4 changes: 4 additions & 0 deletions schema/message_fmt2/test_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
"type": "string",
"description": "Identifier for the test."
},
"hexhash": {
"description": "A hexadecimal hash code for the test without the label",
"type": "string"
},
"test_description": {
"type": "string",
"description": "Information about the test."
Expand Down
4 changes: 4 additions & 0 deletions schema/number_format/test_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
"description": "A numeric ID, unique for the set of tests",
"type": "string"
},
"hexhash": {
"description": "A hexadecimal hash code for the test without the label",
"type": "string"
},
"locale": {
"description": "language tag for formatting the output",
"type": "string"
Expand Down
118 changes: 118 additions & 0 deletions schema/rdt_fmt/test_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/unicode/conformance/_test_schema.json'",
"title": "ICU Conformance test data description",
"description": "This documents the format of relative date time format test data for execution",
"type": "object",
"properties": {
"additionalProperties": false,
"test_type": {
"description": "The name of the test",
"type": "string",
"enum": ["rdt_fmt"]
},
"Test scenario": {
"type": "string",
"description":" Obsolete tag to be removed and replaced with test Type"
},
"source_file": {
"description": "origin of conformance data",
"type": "string"
},
"source_version": {
"description": "version of conformance data",
"type": "string"
},
"test_ environmment": {
"test_language": {
"description": "Programming language of execution",
"type": "string"
},
"executor": {
"description": "path to the executor for this output",
"type": "string"
},
"test_type": {
"description": "the kind of tests run",
"type": "string"
},
"date_time": {
"description": "timestamp of output",
"type": "string"
},
"input_file": {
"description": "path to test data",
"type": "string"
},
"icu_version": {
"description": "ICU data version used in testing",
"type": "string"
},
"cldr_version": {
"description": "CLDR version used in testing",
"type": "string"
},
"test_count": {
"description": "Number of tests run",
"type": "integer"
}
},
"error_info": {
"description": "count of detected errors",
"type": "integer"
},
"platform": {
"description": "the executor's platorm",
"type": "integer"
},
"tests": {
"description": "list of N tests for relative date time format testing",
"type": "array",
"items": {
"additionalProperties": false,
"type": "object",
"properties": {
"label": {
"description": "A numeric ID, unique for the set of tests",
"type": "string"
},
"hexhash": {
"description": "A hexadecimal hash code for the test without the label",
"type": "string"
},
"unit": {
"description": "time interval, e.g., year, month, day, hour, etc. ",
"type": "string"
},
"unit": {
"count": "how may of the units in past or future",
"type": "string"
},
"options": {
"type": "string",
"description": "Optional parameters for the output",
"type": "object",
"properties": {
"style": {
"type": "string",
"description": "size of formated output, e.g., long"
},
"numberingSystem": {
"type": "string",
"description": "4 letter script code of numbering system"
}
}

}
}
},
"required": [
"label",
"locale",
"count",
"unit"
]
}
},
"required": ["test_type"]
}

68 changes: 43 additions & 25 deletions schema/schema_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@

ALL_TEST_TYPES = ['collation_short',
'datetime_fmt',
'lang_names',
'likely_subtags',
'lang_names',
'list_fmt',
'message_fmt2',
'number_format',
'language_names',
'likely_subtags'
'plural_rules',
'rdt_fmt'
]

TEST_FILE_TO_TEST_TYPE_MAP = {
'collation_test': 'collation_short',
'datetime_fmt_test_file': 'datetime_fmt',
'lang_name_test_file': 'language_names',
'lang_names_test_file': 'lang_names',
'likely_subtags_test': 'likely_subtags',
'list_fmt_test_file': 'list_fmt',
'message_fmt2_test_file': 'message_fmt2',
'num_fmt_test_file': 'number_fmt',
'list_fmt_test_file': 'list_fmt'
'plural_rules_test_file': 'plural_rules',
'rdt_fmt_test_file': 'rdt'
}

SCHEMA_FILE_MAP = {
Expand Down Expand Up @@ -83,32 +88,17 @@
}
},

"language_names": {
"test_data": {
"schema_file": "language_names/test_schema.json",
'prod_file': 'lang_name_test_file.json'
},
"verify_data": {
"schema_file": "language_names/verify_schema.json",
'prod_file': 'pass.json'
},
"result_data": {
"schema_file": "language_names/result_schema.json",
"prod_file": "lang_name_test_file.json"
}
},

"lang_names": {
"test_data": {
"schema_file": "language_names/test_schema.json",
"schema_file": "lang_names/test_schema.json",
'prod_file': 'lang_name_test_file.json'
},
"verify_data": {
"schema_file": "language_names/verify_schema.json",
"schema_file": "lang_names/verify_schema.json",
'prod_file': 'pass.json'
},
"result_data": {
"schema_file": "language_names/result_schema.json",
"schema_file": "lang_names/result_schema.json",
"prod_file": "lang_name_test_file.json"
}
},
Expand Down Expand Up @@ -139,8 +129,20 @@
"schema_file": "list_fmt/result_schema.json",
"prod_file": "list_fmt_test.json"
}

# Additional tests
},
"plural_rules" : {
"test_data": {
"schema_file": "plural_rules/test_schema.json",
'prod_file': 'plural_rules.json'
},
"verify_data": {
"schema_file": "plural_rules/verify_schema.json",
'prod_file': 'plural_rules.json'
},
"result_data": {
"schema_file": "plural_rules/result_schema.json",
"prod_file": "plural_rules.json"
}
},
"message_fmt2": {
"test_data": {
Expand All @@ -155,5 +157,21 @@
"schema_file": "message_fmt2/result_schema.json",
'prod_file': 'message_fmt2_result.json'
}
}
},
"rdt_fmt": {
"test_data": {
"schema_file": "rdt_fmt/test_schema.json",
'prod_file': 'rdt_fmt.json'
},
"verify_data": {
"schema_file": "rdt_fmt/verify_schema.json",
'prod_file': 'rdt_fmt.json'
},
"result_data": {
"schema_file": "plural_rules/result_schema.json",
"prod_file": "rdt_fmt.json"
}
},
# Additional tests

}
5 changes: 4 additions & 1 deletion schema/schema_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ def validate_test_data_with_schema(self):
file_path_pair = self.get_schema_data_info(icu_version, test_type)
if file_path_pair:
schema_test_info.append(file_path_pair)

else:
# logging.info('No data test file %s for %s, %s', file_path_pair, test_type, icu_version)
pass
results = self.parallel_check_test_data_schema(schema_test_info)

for result_data in results:
Expand Down Expand Up @@ -176,6 +178,7 @@ def get_schema_data_info(self, icu_version, test_type):
'test_result_file': test_file_name
}
else:
# logging.warning('## get_schema_data_info. No file at test_file_name: %s', test_file_name);
return None

def check_test_data_against_schema(self, schema_info):
Expand Down
Loading

0 comments on commit b08229f

Please sign in to comment.