From f635e54626b95a3391df1dd7f0afd6a800947877 Mon Sep 17 00:00:00 2001 From: Viktoria Shirunova Date: Thu, 29 May 2025 14:49:48 +0300 Subject: [PATCH] [URunner2]: fix ets tests 1. fix filtering to filter by test-id, not by file path 2. move execution plan to short verbose mode. 3. remove --ets-module option from only-es2panda.yaml 4. markup negative, compile-only dependent files. 5. ets-func-tests: restored generating tests by ets-func-tests-templates. Added a couple of tests for FuncTestsCodeGenerator. 6. ets-cts: remove absent tests from excluded and ignore test lists 7. fix exclude test processing both in UR1 and UR2 Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICBS2R Testing: All required pre-merge tests passed. Results are available in the ggwatcher. Signed-off-by: Viktoria Shirunova --- static_core/codecheck_ignore.json | 2 + .../cyclic_dependency/module.ets | 2 +- .../type_binding_class_neg.ets | 2 +- .../export_type_class_same_name.ets | 1 + .../export_type_class_same_name_2.ets | 1 + .../namespace_storage2.ets | 2 +- .../simple_spec4_3.ets | 1 + .../simple_spec_pos4.ets | 4 +- .../export_as_same_name.ets | 2 +- .../to_export_n.ets | 2 +- .../ambient_annotations.d.ets | 1 - .../ambient_annotations.ets | 1 + .../ambient_annotations_n.d.ets | 1 - .../ambient_annotations_n.ets | 1 + .../issue15371/issue15371_03.ets | 2 +- .../ets-func-tests-excluded.txt | 6 - .../ets-func-tests/ets-func-tests-ignored.txt | 41 +++--- .../cfg/test-suites/ets-func-tests.yaml | 4 +- .../cfg/workflows/only-es2panda.yaml | 1 - .../runner/code_coverage/coverage_dir.py | 2 +- .../sts_stdlib/func_templates_generator.py | 118 ++++++++++++++++++ .../tests-u-runner-2/runner/runner_base.py | 2 +- .../runner/sts_utils/constants.py | 4 +- .../runner/suites/preparation_step.py | 32 ++--- .../runner/suites/runner_standard_flow.py | 8 +- .../runner/suites/test_lists.py | 10 +- .../runner/suites/test_suite.py | 13 +- .../runner/test/generators_test/__init__.py | 15 +++ .../generators_test/data/config-func.yaml | 21 ++++ .../generators_test/data/data_test_suite0.py | 104 +++++++++++++++ .../test/generators_test/data/func.ets.j2 | 37 ++++++ .../func_templates_generator_test.py | 75 +++++++++++ .../runner/plugins/ets/test_ets.py | 3 - .../tests-u-runner/runner/runner_base.py | 17 ++- 34 files changed, 458 insertions(+), 80 deletions(-) create mode 100644 static_core/tests/tests-u-runner-2/runner/extensions/generators/sts_stdlib/func_templates_generator.py create mode 100644 static_core/tests/tests-u-runner-2/runner/test/generators_test/__init__.py create mode 100644 static_core/tests/tests-u-runner-2/runner/test/generators_test/data/config-func.yaml create mode 100644 static_core/tests/tests-u-runner-2/runner/test/generators_test/data/data_test_suite0.py create mode 100644 static_core/tests/tests-u-runner-2/runner/test/generators_test/data/func.ets.j2 create mode 100644 static_core/tests/tests-u-runner-2/runner/test/generators_test/func_templates_generator_test.py diff --git a/static_core/codecheck_ignore.json b/static_core/codecheck_ignore.json index a1c558d728..187bdbe231 100644 --- a/static_core/codecheck_ignore.json +++ b/static_core/codecheck_ignore.json @@ -202,6 +202,8 @@ "tests/tests-u-runner/runner_test.py": "*", "tests/tests-u-runner-2/runner/suites/__init__.py": "*", "tests/tests-u-runner-2/runner/test/config_test/__init__.py": "*", + "tests/tests-u-runner-2/runner/test/generators_test/__init__.py": "*", + "tests/tests-u-runner-2/runner/test/generators_test/data/data_test_suite0.py": "*", "tests/tests-u-runner-2/runner/test/launches_test/__init__.py": "*", "tests/tests-u-runner-2/runner/test/launches_test/data/data_test_suite0.py": "*", "tests/tests-u-runner-2/runner/test/metadata_test/__init__.py": "*", diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/01.separate_modules/cyclic_dependency/module.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/01.separate_modules/cyclic_dependency/module.ets index 5afacee6e0..f033324db8 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/01.separate_modules/cyclic_dependency/module.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/01.separate_modules/cyclic_dependency/module.ets @@ -14,7 +14,7 @@ */ /*--- -tags: [compile-only, not-a-test] +tags: [compile-only, negative, not-a-test] ---*/ import {a} from "./test.ets" diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/04.import_type_directive/type_binding_class_neg.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/04.import_type_directive/type_binding_class_neg.ets index 281f294be9..bbd5d9b703 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/04.import_type_directive/type_binding_class_neg.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/04.import_type_directive/type_binding_class_neg.ets @@ -17,7 +17,7 @@ limitations under the License. desc: Import class type without 'type' key specified in the module. files: - ../../05.top-level_declarations/01.exported_declarations/type_exported_declarations/export_type_class_2.ets -tags: [compile-only, negative] +tags: [compile-only] ---*/ import type {C} from "../../05.top-level_declarations/01.exported_declarations/type_exported_declarations/export_type_class_2" diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/05.top-level_declarations/01.exported_declarations/type_exported_declarations/export_type_class_same_name.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/05.top-level_declarations/01.exported_declarations/type_exported_declarations/export_type_class_same_name.ets index e42a4f724a..e8712a1142 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/05.top-level_declarations/01.exported_declarations/type_exported_declarations/export_type_class_same_name.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/05.top-level_declarations/01.exported_declarations/type_exported_declarations/export_type_class_same_name.ets @@ -17,6 +17,7 @@ limitations under the License. desc: Type export class type. Type is having the same name as non-exported class. tags: - compile-only +- negative - not-a-test ---*/ diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/05.top-level_declarations/01.exported_declarations/type_exported_declarations/export_type_class_same_name_2.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/05.top-level_declarations/01.exported_declarations/type_exported_declarations/export_type_class_same_name_2.ets index 0ba98ca9e0..6aa1d8386b 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/05.top-level_declarations/01.exported_declarations/type_exported_declarations/export_type_class_same_name_2.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/05.top-level_declarations/01.exported_declarations/type_exported_declarations/export_type_class_same_name_2.ets @@ -17,6 +17,7 @@ limitations under the License. desc: Type export class type. Type is having the same name as non-exported class. tags: - compile-only +- negative - not-a-test ---*/ diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/namespace_storage2.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/namespace_storage2.ets index de532cbe54..162e34303b 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/namespace_storage2.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/namespace_storage2.ets @@ -15,7 +15,7 @@ limitations under the License. /*--- desc: First simple sample from spec -tags: [not-a-test, compile-only] +tags: [not-a-test, compile-only, negative] ---*/ export namespace A { diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/simple_spec4_3.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/simple_spec4_3.ets index b2772f0e12..0cda9ec7e7 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/simple_spec4_3.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/simple_spec4_3.ets @@ -15,6 +15,7 @@ limitations under the License. /*--- desc: First simple sample from spec +tags: [not-a-test, compile-only] files: - ./namespace_storage.ets ---*/ diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/simple_spec_pos4.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/simple_spec_pos4.ets index 3278b3c6ab..37e815dad1 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/simple_spec_pos4.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/06.namespace_declarations/simple_spec_pos4.ets @@ -15,14 +15,12 @@ limitations under the License. /*--- desc: First simple sample from spec -tags: [compile-only] files: - ./simple_spec4_3.ets -- ./namespace_storage.ets ---*/ import {Space1 as mySpace} from "./simple_spec4_3.ets"; function main() { - arktest.assertEQ("Space1", "Space1") + arktest.assertEQ(mySpace.foo(), "Local Space1") } diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/01.selective_export_directive/export_as_same_name.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/01.selective_export_directive/export_as_same_name.ets index 19460e7ebc..9662c0911d 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/01.selective_export_directive/export_as_same_name.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/01.selective_export_directive/export_as_same_name.ets @@ -14,7 +14,7 @@ limitations under the License. ---*/ /*--- -tags: [not-a-test, compile-only] +tags: [not-a-test, compile-only, negative] ---*/ function foo(): void {} diff --git a/static_core/plugins/ets/tests/ets-templates/18.annotations/03.exporting_and_importing_annotations/to_export_n.ets b/static_core/plugins/ets/tests/ets-templates/18.annotations/03.exporting_and_importing_annotations/to_export_n.ets index c7e0362ebe..bb9df5d4a9 100644 --- a/static_core/plugins/ets/tests/ets-templates/18.annotations/03.exporting_and_importing_annotations/to_export_n.ets +++ b/static_core/plugins/ets/tests/ets-templates/18.annotations/03.exporting_and_importing_annotations/to_export_n.ets @@ -15,7 +15,7 @@ /*--- desc: 18.01.declaring_annotations export - tags: [not-a-test] + tags: [not-a-test, compile-only, negative] files: ['./to_export.ets'] ---*/ diff --git a/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations/ambient_annotations.d.ets b/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations/ambient_annotations.d.ets index 128cf58eeb..a778424cac 100644 --- a/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations/ambient_annotations.d.ets +++ b/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations/ambient_annotations.d.ets @@ -17,7 +17,6 @@ desc: Ambient declaration does not introduce a new annotation but provides type information to use an annotation that must be defined elsewhere tags: [not-a-test, compile-only] -files: ['./ambient_annotations.ets'] ---*/ export enum MyEnum { EnumField1, EnumField2 } diff --git a/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations/ambient_annotations.ets b/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations/ambient_annotations.ets index e6f3268854..beca95aa60 100644 --- a/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations/ambient_annotations.ets +++ b/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations/ambient_annotations.ets @@ -16,6 +16,7 @@ /*--- desc: Ambient declaration does not introduce a new annotation but provides type information to use an annotation that must be defined elsewhere +tags: [not-a-test] ---*/ enum MyEnum { EnumField1, EnumField2 } diff --git a/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations_n/ambient_annotations_n.d.ets b/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations_n/ambient_annotations_n.d.ets index 6a9768b34c..eb90f2914b 100644 --- a/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations_n/ambient_annotations_n.d.ets +++ b/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations_n/ambient_annotations_n.d.ets @@ -17,7 +17,6 @@ desc: An ambient annotation and the annotation that implements it must be exactly identical, including field initialization tags: [not-a-test, compile-only] -files: ['./ambient_annotations_n.ets'] ---*/ export enum MyEnum { EnumField1, EnumField2 } diff --git a/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations_n/ambient_annotations_n.ets b/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations_n/ambient_annotations_n.ets index 7dc0d6b1e7..d1ed42aec5 100644 --- a/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations_n/ambient_annotations_n.ets +++ b/static_core/plugins/ets/tests/ets-templates/18.annotations/04.ambient_annotations/ambient_annotations_n/ambient_annotations_n.ets @@ -16,6 +16,7 @@ /*--- desc: An ambient annotation and the annotation that implements it must be exactly identical, including field initialization +tags: [not-a-test, compile-only] ---*/ export enum MyEnum { EnumField1, EnumField2 } diff --git a/static_core/plugins/ets/tests/ets_func_tests/spec/13.Compilation_Units_Packages_and_Modules/06.Export_Directives/13.6.3.Re-Export_Directives/issue15371/issue15371_03.ets b/static_core/plugins/ets/tests/ets_func_tests/spec/13.Compilation_Units_Packages_and_Modules/06.Export_Directives/13.6.3.Re-Export_Directives/issue15371/issue15371_03.ets index 2b9ce01a57..14557fc4d0 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/spec/13.Compilation_Units_Packages_and_Modules/06.Export_Directives/13.6.3.Re-Export_Directives/issue15371/issue15371_03.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/spec/13.Compilation_Units_Packages_and_Modules/06.Export_Directives/13.6.3.Re-Export_Directives/issue15371/issue15371_03.ets @@ -16,7 +16,7 @@ /*--- desc: 13.compilation_units\13.06.export_directives\13.06.03.re-export_directives\issue15371 name: issue15371_03.ets -tags: [not-a-test, compile-only] +tags: [not-a-test, compile-only, negative] files: ['./issue15371_01.ets', './issue15371_02.ets'] ---*/ diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt index 2156e09657..169ecfabfd 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt @@ -1,9 +1,3 @@ -spec/nullables/nullable-lambda-default-param_0.ets -spec/nullables/nullable-lambda-default-param_1.ets -spec/nullables/nullable-lambda-default-param_3.ets -spec/nullables/nullable-lambda-default-param_4.ets -spec/nullables/nullable-lambda-default-param_5.ets -spec/nullables/nullable-lambda-default-param_6.ets #24986 (17 tests) std/core/Object.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored.txt index 977fa9143a..536d0557c7 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored.txt @@ -26,7 +26,6 @@ regression/23659_1.ets #19666 (Feature: Null safety tests) spec/03.types/References_Types/3.8.12.Nullish_Types/nullable-function-result_2.ets spec/03.types/References_Types/3.8.12.Nullish_Types/nullable-method-result_2.ets -spec/nullables/nullable-member_2.ets #19663 (Feature: Null safety tests) spec/03.types/References_Types/3.8.12.Nullish_Types/nullable-lambda-default-param_0.ets @@ -166,6 +165,12 @@ spec/09.classes/constructor-inheritance/issue14720_6.ets spec/09.classes/constructor-inheritance/issue14720_4.ets spec/09.classes/constructor-inheritance/issue14720_5.ets +#21176 +spec/09.classes/9.5.Field_Declaration/class_with_optional_attributes_0006.ets + +#19725 +spec/09.classes/9.6.Method_Declarations/Issue-14273_3.ets + ### Negative tests (Interfaces overriding issues) spec/09.classes/9.6.Method_Declarations/10.Overriding_by_Instance_Methods/interface_overriding_02.ets spec/09.classes/9.6.Method_Declarations/10.Overriding_by_Instance_Methods/interface_overriding_03.ets @@ -247,7 +252,6 @@ spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/n #19953 spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/expr/numeric-double-object-zero-expression.ets -spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/expr/numeric-short-nonzero-expres #14040 Annotations not yet implemented spec/16.Support_for_GUI_Programming/annotations/annotation_@Builder.ets @@ -300,9 +304,6 @@ spec/17.Experimental_Features/17.3.Indexable_Types/idx-s01-0080.ets #19716 spec/17.Experimental_Features/17.3.Indexable_Types/idx-s03-0000.ets -#17149 -spec/17.Experimental_Features/17.9.Default_and_Static_Interface_Methods/17.9.2.Static_Method_Declarations/static_method_0003.ets - ### for of is not implemented spec/17.Experimental_Features/Iterable_Types/for_of_08.ets spec/17.Experimental_Features/Iterable_Types/for_of_09.ets @@ -349,27 +350,23 @@ std/core/std_core_typedarrays_bignum__BigUint64Array.ets #22948 TypeApi produces invalid bytecode std/core/TypeCreatePrimitiveNameTest.ets -### Negative tests (Import-export) -spec/import_export/07.export_directives/02.export_type_directives/to_export_negative.ets - -### Not-a-test (Import-export) -spec/import_export/03.import_directives/to_export.ets -spec/import_export/03.import_directives/05.default_import_binding_additional/default_to_export.ets -spec/import_export/03.import_directives/06.import_path/to_export.ets -spec/import_export/06.top-level_declarations/01.exported_declarations/to_export.ets -spec/import_export/07.export_directives/01.selective_export_directive/to_export.ets -spec/import_export/07.export_directives/03.re-export_directives/re-export_all.ets -spec/import_export/07.export_directives/03.re-export_directives/re-export_not_all.ets -spec/import_export/07.export_directives/03.re-export_directives/to_export.ets -spec/import_export/07.export_directives/03.re-export_directives/to_export_2.ets -spec/import_export/07.export_directives/02.export_type_directives/to_export_for_import_type_alias_with_qualified_access.ets +#11544 +std/math/std_math_asin_double.ets +std/math/std_math_atan2_double_double.ets +std/math/std_math_cbrt_double.ets +std/math/std_math_hypot_double_double.ets +std/math/std_math_imul_float_float.ets +std/math/std_math_log10_int.ets +std/math/std_math_mod_double_double.ets +std/math/std_math_power2_double.ets +std/math/std_math_power_double_double.ets +std/math/std_math_rem_double_double.ets +std/math/std_math_sinh_double.ets +std/math/std_math_tan_double.ets #10874 std/math/std_math_clz64_long.ets -#18766 -spec/partial_type/partialType_main.ets - #25752 float32array_newFloat32Array_newArrayBuffer_2_Float32Array_BYTES_PER_ELEMENT___1_0_pars_0.ets #25740 diff --git a/static_core/tests/tests-u-runner-2/cfg/test-suites/ets-func-tests.yaml b/static_core/tests/tests-u-runner-2/cfg/test-suites/ets-func-tests.yaml index 6b98a1bcc1..1046c147ae 100644 --- a/static_core/tests/tests-u-runner-2/cfg/test-suites/ets-func-tests.yaml +++ b/static_core/tests/tests-u-runner-2/cfg/test-suites/ets-func-tests.yaml @@ -13,7 +13,7 @@ version: 0.0.0.1 type: test-suite -suite-name: sts-func +suite-name: ets-func list-root: ${ARKCOMPILER_RUNTIME_CORE_PATH}/static_core/plugins/ets/tests/test-lists/ets-func-tests test-root: ${ARKCOMPILER_RUNTIME_CORE_PATH}/static_core/plugins/ets/tests @@ -26,3 +26,5 @@ collections: ets_func_tests: stdlib-templates: generator-class: runner.extensions.generators.sts_stdlib.stdlib_templates_generator.StdlibTemplatesGenerator + ets-func-tests-templates: + generator-class: runner.extensions.generators.sts_stdlib.func_templates_generator.FuncTestsCodeGenerator diff --git a/static_core/tests/tests-u-runner-2/cfg/workflows/only-es2panda.yaml b/static_core/tests/tests-u-runner-2/cfg/workflows/only-es2panda.yaml index 33bc3954d9..ac3a48cf2d 100644 --- a/static_core/tests/tests-u-runner-2/cfg/workflows/only-es2panda.yaml +++ b/static_core/tests/tests-u-runner-2/cfg/workflows/only-es2panda.yaml @@ -23,7 +23,6 @@ parameters: es2panda-full-args: - "--arktsconfig=${parameters.arktsconfig}" - "--gen-stdlib=false" - - "--ets-module" - "--extension=${parameters.extension}" - "--opt-level=${parameters.opt-level}" - "--output=${parameters.output-file}" diff --git a/static_core/tests/tests-u-runner-2/runner/code_coverage/coverage_dir.py b/static_core/tests/tests-u-runner-2/runner/code_coverage/coverage_dir.py index 433ab5f0d7..cd1c4b45b7 100644 --- a/static_core/tests/tests-u-runner-2/runner/code_coverage/coverage_dir.py +++ b/static_core/tests/tests-u-runner-2/runner/code_coverage/coverage_dir.py @@ -131,7 +131,7 @@ class CoverageDir: Returns: Path: The full path to the coverage working directory. - """ + """ work_dir = self.root / "work_dir" work_dir.mkdir(parents=True, exist_ok=True) return work_dir diff --git a/static_core/tests/tests-u-runner-2/runner/extensions/generators/sts_stdlib/func_templates_generator.py b/static_core/tests/tests-u-runner-2/runner/extensions/generators/sts_stdlib/func_templates_generator.py new file mode 100644 index 0000000000..fb42888760 --- /dev/null +++ b/static_core/tests/tests-u-runner-2/runner/extensions/generators/sts_stdlib/func_templates_generator.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2024-2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from collections.abc import Generator +from pathlib import Path +from typing import Any + +import jinja2 +import yaml + +from runner.common_exceptions import YamlException +from runner.extensions.generators.igenerator import IGenerator +from runner.logger import Log +from runner.options.config import Config +from runner.sts_utils.constants import VARIABLE_START_STRING +from runner.utils import write_2_file + +TemplatePropertyType = Any # type: ignore[explicit-any] +_LOGGER = Log.get_logger(__file__) + + +class FuncTestsCodeGenerator(IGenerator): + _TEST_SEPARATOR = "---" + _TEMPLATE_PATTERN = '*.ets.j2' + + def __init__(self, source: Path, target: Path, config: Config) -> None: + super().__init__(source, target, config) + self._jinja_env = jinja2.Environment( + loader=jinja2.FileSystemLoader(str(source)), + autoescape=jinja2.select_autoescape(), + variable_start_string=VARIABLE_START_STRING + ) + + @staticmethod + def _get_file_basename(path: Path) -> str: + name = path.name + for suffix in path.suffixes: + name = name.replace(suffix, "") + return name + + @staticmethod + def _add_generator_artefact(test: str, template: Path, template_config: Path) -> str: + test = f"/* Template name : {template}*/\n" + test + test = f"/* Config name : {template_config}*/\n\n" + test + return test + + @staticmethod + def _load_parameters(config_file_path: Path) -> dict[str, TemplatePropertyType]: + try: + text = config_file_path.read_text(encoding='utf-8') + params: dict[str, TemplatePropertyType] = yaml.safe_load(text) + _LOGGER.all("; ".join(f"{key} = {value}" for key, value in params.items())) + except yaml.YAMLError as common_exp: + raise YamlException(f"Could not load YAML: {common_exp} filepath={config_file_path}") from common_exp + return params + + def generate(self) -> list[str]: + """ + Renders all templates and saves them. + """ + self._target.mkdir(parents=True, exist_ok=True) + generated_test_list: list[str] = [] + templates_fname_list: list[Path] = list(self._find_all_templates(self._source)) + for template_fname in templates_fname_list: + generated_test_list += self._render_template(template_fname, self._source, self._target) + return generated_test_list + + def _find_all_templates(self, current_dir: Path) -> Generator[Path, None, None]: + _LOGGER.all(f"Start searching in : {current_dir}") + _LOGGER.all(f"{str(current_dir) + self._TEMPLATE_PATTERN}") + return current_dir.rglob(self._TEMPLATE_PATTERN) + + def _get_template_config(self, template_path: Path) -> Path: + template_basename = self._get_file_basename(template_path) + config_name = "config-" + template_basename + ".yaml" + _LOGGER.all(f"Config path {config_name}") + return template_path.with_name(config_name) + + def _render_template(self, + template_path: Path, + template_root_path: Path, + outpath: Path) -> Generator[str, None, None]: + template_config_path = self._get_template_config(template_path) + template_relative_path = template_path.relative_to(template_root_path) + _LOGGER.all(f"Load template from {template_relative_path}") + template = self._jinja_env.get_template(str(template_relative_path)) + params = self._load_parameters(template_config_path) + content = template.render(**params).strip() + content_list = self._split_tests(content) + test_idx = 1 + template_name = self._get_file_basename(template_path) + + for test in content_list: + test = self._add_generator_artefact(test, template_path, template_config_path) + output_fname = "test-" + template_name + "-" + str(test_idx).zfill(4) + ".ets" + outpath_final = outpath / template_relative_path.with_name(output_fname) + write_2_file(outpath_final, test) + test_idx += 1 + yield outpath_final.as_posix() + + def _split_tests(self, content: str) -> list[str]: + content = content.rstrip(self._TEST_SEPARATOR) + content_list = content.split("---") + _LOGGER.summary(f"size : {len(content_list)}") + return content_list diff --git a/static_core/tests/tests-u-runner-2/runner/runner_base.py b/static_core/tests/tests-u-runner-2/runner/runner_base.py index 1fc58badc1..74a1a611f8 100644 --- a/static_core/tests/tests-u-runner-2/runner/runner_base.py +++ b/static_core/tests/tests-u-runner-2/runner/runner_base.py @@ -58,7 +58,7 @@ class Runner(ABC): # excluded test is a test what should not be loaded and should be tried to run # excluded_list: either absolute path or path relative from list_root to the file with the list of such tests self.excluded_lists: list[str] = [] - self.excluded_tests: set[str] = set([]) + self.excluded_tests: set[Path] = set([]) # ignored test is a test what should be loaded and executed, but its failure should be ignored # ignored_list: either absolute path or path relative from list_root to the file with the list of such tests # aka: kfl stands for `known failures list` diff --git a/static_core/tests/tests-u-runner-2/runner/sts_utils/constants.py b/static_core/tests/tests-u-runner-2/runner/sts_utils/constants.py index 02a4659d9e..113df8229d 100644 --- a/static_core/tests/tests-u-runner-2/runner/sts_utils/constants.py +++ b/static_core/tests/tests-u-runner-2/runner/sts_utils/constants.py @@ -28,8 +28,8 @@ META_COPYRIGHT = "Copyright (c)" # Extensions YAML_EXTENSIONS = [".yaml", ".yml"] -TEMPLATE_EXTENSION = ".sts" -OUT_EXTENSION = ".sts" +TEMPLATE_EXTENSION = ".ets" +OUT_EXTENSION = ".ets" JAR_EXTENSION = ".jar" # Prefixes diff --git a/static_core/tests/tests-u-runner-2/runner/suites/preparation_step.py b/static_core/tests/tests-u-runner-2/runner/suites/preparation_step.py index 0c6b14c153..3cfd39fa7c 100644 --- a/static_core/tests/tests-u-runner-2/runner/suites/preparation_step.py +++ b/static_core/tests/tests-u-runner-2/runner/suites/preparation_step.py @@ -15,13 +15,12 @@ # limitations under the License. import multiprocessing -import os import re import shutil import subprocess from abc import ABC, abstractmethod +from collections.abc import Generator from concurrent.futures import ThreadPoolExecutor -from glob import glob from pathlib import Path from runner.common_exceptions import InvalidConfiguration, TimeoutException, UnknownException @@ -53,7 +52,7 @@ class TestPreparationStep(ABC): return self.__test_gen_path @abstractmethod - def transform(self, force_generated: bool) -> list[Path]: + def transform(self, force_generated: bool) -> Generator[Path, None, None]: pass @@ -79,22 +78,18 @@ class CustomGeneratorTestPreparationStep(TestPreparationStep): f"Check value of 'generator-class' option") return class_obj - def transform(self, force_generated: bool) -> list[Path]: + def transform(self, force_generated: bool) -> Generator[Path, None, None]: # call of the custom generator if self.test_gen_path.exists() and force_generated: shutil.rmtree(self.test_gen_path) - os.makedirs(self.test_gen_path, exist_ok=True) - result: list[str] = [] + self.test_gen_path.mkdir(exist_ok=True, parents=True) try: if self.collection.generator_class is not None: self.__generate_by_class(self.collection.generator_class) elif self.collection.generator_script is not None: self.__generate_by_script(self.collection.generator_script) finally: - glob_expression = os.path.join(self.test_gen_path, f"**/*.{self.extension}") - result.extend(glob(glob_expression, recursive=True)) - - return [Path(res) for res in result] + yield from self.test_gen_path.rglob(f"**/*.{self.extension}") def __generate_by_class(self, clazz: str) -> None: generator_class: type[IGenerator] = self.__get_generator_class(clazz) @@ -133,14 +128,13 @@ class CopyStep(TestPreparationStep): return (f"Test preparation step: copying *.{self.extension} files " f"from {self.test_source_path} to {self.test_gen_path}") - def transform(self, force_generated: bool) -> list[Path]: + def transform(self, force_generated: bool) -> Generator[Path, None, None]: try: if self.test_source_path != self.test_gen_path: copy(self.test_source_path, self.test_gen_path, remove_if_exist=False) - glob_expression = os.path.join(self.test_gen_path, f"**/*.{self.extension}") - return [Path(test) for test in glob(glob_expression, recursive=True)] + yield from self.test_gen_path.rglob(f"**/*.{self.extension}") except FileNotFoundError: - return [] + yield from [] class JitStep(TestPreparationStep): @@ -168,18 +162,16 @@ class JitStep(TestPreparationStep): def __str__(self) -> str: return "Test preparation step for any ets test suite: transforming for JIT testing" - def transform(self, force_generated: bool) -> list[Path]: - glob_expression = os.path.join(self.test_gen_path, f"**/*.{self.extension}") - tests = list(glob(glob_expression, recursive=True)) + def transform(self, force_generated: bool) -> Generator[Path, None, None]: + tests = self.test_gen_path.rglob(f"**/*.{self.extension}") with multiprocessing.Pool(processes=self.config.general.processes) as pool: run_tests = pool.imap_unordered(self.jit_transform_one_test, tests, chunksize=self.config.general.chunksize) pool.close() pool.join() - return list(run_tests) + yield from run_tests - def jit_transform_one_test(self, test_path_str: str) -> Path: - test_path = Path(test_path_str) + def jit_transform_one_test(self, test_path: Path) -> Path: metadata = TestMetadata.get_metadata(test_path) is_convert = not metadata.tags.not_a_test and \ not metadata.tags.compile_only and \ diff --git a/static_core/tests/tests-u-runner-2/runner/suites/runner_standard_flow.py b/static_core/tests/tests-u-runner-2/runner/suites/runner_standard_flow.py index 9ed1d37ba6..bca1e71083 100644 --- a/static_core/tests/tests-u-runner-2/runner/suites/runner_standard_flow.py +++ b/static_core/tests/tests-u-runner-2/runner/suites/runner_standard_flow.py @@ -59,6 +59,8 @@ class RunnerStandardFlow(RunnerFileBased): test_suite: TestSuite = TestSuite(self.test_env) self.tests = set(test_suite.process(self.config.test_suite.ets.force_generate)) + self.excluded = test_suite.excluded + self.excluded_tests.update(test_suite.excluded_tests) self.list_root = test_suite.list_root self.test_root = self.test_env.work_dir.gen @@ -71,9 +73,9 @@ class RunnerStandardFlow(RunnerFileBased): return Path("/tmp") / self.suite_name def create_execution_plan(self) -> None: - _LOGGER.default(f"\n{utils.pretty_divider()}") - _LOGGER.default(f"Execution plan for the test suite '{self.name}'") - _LOGGER.default(self.config.workflow.pretty_str()) + _LOGGER.short(f"\n{utils.pretty_divider()}") + _LOGGER.short(f"Execution plan for the test suite '{self.name}'") + _LOGGER.short(self.config.workflow.pretty_str()) def create_coverage_html(self) -> None: """ diff --git a/static_core/tests/tests-u-runner-2/runner/suites/test_lists.py b/static_core/tests/tests-u-runner-2/runner/suites/test_lists.py index 300f1e835f..355088f469 100644 --- a/static_core/tests/tests-u-runner-2/runner/suites/test_lists.py +++ b/static_core/tests/tests-u-runner-2/runner/suites/test_lists.py @@ -183,12 +183,18 @@ class TestLists: return int(level) if level is not None else None def debug_info(self) -> bool: + debug_info_opt = "--debug-info" args = self.config.workflow.get_parameter("es2panda-extra-args") - return len(self.__search_option_in_list("--es2panda-debug-info", args)) > 0 + if isinstance(args, str): + return args == debug_info_opt + return len(self.__search_option_in_list(debug_info_opt, args)) > 0 def is_full_ast_verifier(self) -> bool: + option = "--verifier-all-checks" args = self.config.workflow.get_parameter("es2panda-extra-args") - return len(self.__search_option_in_list("--verifier-all-checks", args)) > 0 + if isinstance(args, str): + return args == option + return len(self.__search_option_in_list(option, args)) > 0 def __cmake_cache(self) -> list[str]: cmake_cache_txt = "CMakeCache.txt" diff --git a/static_core/tests/tests-u-runner-2/runner/suites/test_suite.py b/static_core/tests/tests-u-runner-2/runner/suites/test_suite.py index 416735264d..6bcd7c24d5 100644 --- a/static_core/tests/tests-u-runner-2/runner/suites/test_suite.py +++ b/static_core/tests/tests-u-runner-2/runner/suites/test_suite.py @@ -156,6 +156,8 @@ class TestSuite: self.__search_both_excluded_and_ignored_tests() executed_set = self.__get_by_groups(executed_set) tests = self.__create_tests(executed_set) + Log.default(_LOGGER, f"Loaded {len(tests)} valid tests from the folder '{self.test_root}'. " + f"Excluded {len(self.excluded_tests)} tests are not loaded.") return tests def set_preparation_steps(self) -> list[TestPreparationStep]: @@ -199,7 +201,7 @@ class TestSuite: collection=collection, extension=extension )) - else: + elif copy_source_path != self.test_root / collection.name: steps.append(CopyStep( test_source_path=copy_source_path, test_gen_path=self.test_root / collection.name, @@ -329,7 +331,10 @@ class TestSuite: excluded: list[Path] = list(self.excluded_tests)[:] if self.config.test_suite.groups.chapters: test_files = self.__filter_by_chapters(self.test_root, test_files) - pattern = re.compile(self.config.test_suite.filter.replace(".", r"\.").replace("*", ".*")) + mask = self.config.test_suite.filter.replace(".", r"\.").replace("*", ".*") + coll_names = "|".join(self.__collections_parameters.keys()) + mask = f"({coll_names})?/{mask}" if coll_names else mask + pattern = re.compile(f"{self.test_root / mask}") return [test for test in test_files if test not in excluded and pattern.search(str(test))] def __filter_by_chapters(self, base_folder: Path, files: list[Path]) -> list[Path]: @@ -392,9 +397,9 @@ class TestSuite: """ Read excluded_lists and load list of excluded tests """ - excluded_tests = self.__load_tests_from_lists(self._test_lists.excluded_lists) - self.excluded = len(excluded_tests) + excluded_tests = self.__get_by_groups(self.__load_tests_from_lists(self._test_lists.excluded_lists)) self.__search_duplicates(excluded_tests, "excluded") + self.excluded = len(excluded_tests) return excluded_tests def __load_ignored_tests(self) -> list[Path]: diff --git a/static_core/tests/tests-u-runner-2/runner/test/generators_test/__init__.py b/static_core/tests/tests-u-runner-2/runner/test/generators_test/__init__.py new file mode 100644 index 0000000000..0d70e66c87 --- /dev/null +++ b/static_core/tests/tests-u-runner-2/runner/test/generators_test/__init__.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +# -- coding: utf-8 -- +# +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/static_core/tests/tests-u-runner-2/runner/test/generators_test/data/config-func.yaml b/static_core/tests/tests-u-runner-2/runner/test/generators_test/data/config-func.yaml new file mode 100644 index 0000000000..ddd6d39f87 --- /dev/null +++ b/static_core/tests/tests-u-runner-2/runner/test/generators_test/data/config-func.yaml @@ -0,0 +1,21 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +operations: + - "&&" + - "||" +expression_list: + - 'string:"Hello World":Colors:Colors.Yellow' + - 'string:"Hello World":Object:new Object()' +sep: "---" +enum_type_def: "enum Colors {Red, Yellow, Green}" \ No newline at end of file diff --git a/static_core/tests/tests-u-runner-2/runner/test/generators_test/data/data_test_suite0.py b/static_core/tests/tests-u-runner-2/runner/test/generators_test/data/data_test_suite0.py new file mode 100644 index 0000000000..57d1578fd6 --- /dev/null +++ b/static_core/tests/tests-u-runner-2/runner/test/generators_test/data/data_test_suite0.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +# -- coding: utf-8 -- +# +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from pathlib import Path + +from runner.enum_types.configuration_kind import ArchitectureKind, BuildTypeKind, OSKind, SanitizerKind +from runner.enum_types.qemu import QemuKind +from runner.enum_types.verbose_format import VerboseFilter, VerboseKind + +args = { + 'workflow': 'config-1', + 'config-1.path': Path(__file__).parent.parent.parent.parent.joinpath('cfg/workflows/config-1.yaml').resolve(), + 'config-1.data': { + 'runner-api-level': '0.0.0.1', + 'type': 'workflow', + 'workflow-name': 'echo', + 'parameters': { + 'string-param': 'hello', + 'int-param': 20, + 'bool-param': True, + 'list-param': ['--gen-stdlib=false', '--thread=0'] + }, + 'steps': { + 'echo': { + 'executable-path': '/usr/bin/echo', + 'args': [ + '--arktsconfig=${parameters.string-param}', + '${parameters.list-param}', + '--extension=ets', + '${test-id}' + ], + 'timeout': '${parameters.int-param}', + 'can-be-instrumented': '${parameters.bool-param}' + } + } + }, + 'config-1.parameters.string-param': 'hello', + 'config-1.parameters.int-param': 20, + 'config-1.parameters.bool-param': True, + 'config-1.parameters.list-param': ['--gen-stdlib=false', '--thread=0'], + 'test-suite': 'test_suite', + 'test_suite.path': (Path(__file__).parent.parent.parent.parent. + joinpath('cfg/test-suites/test_suite1.yaml').resolve()), + 'test_suite.data': { + 'version': '0.0.0.1', + 'type': 'test-suite', + 'suite-name': 'test_suite', + 'test-root': '.', + 'list-root': '.', + 'parameters': { + 'extension': 'sts', + 'load-runtimes': 'ets', + 'work-dir': '.' + } + }, + 'test_suite.parameters.filter': '*', + 'test_suite.parameters.repeats': 1, + 'test_suite.parameters.repeats-by-time': None, + 'test_suite.parameters.with-js': 'with-js', + 'test_suite.parameters.test-list': None, + 'test_suite.parameters.test-file': None, + 'test_suite.parameters.skip-test-lists': False, + 'test_suite.parameters.update-excluded': False, + 'test_suite.parameters.update-expected': False, + 'test_suite.parameters.test-list-arch': ArchitectureKind.AMD64, + 'test_suite.parameters.test-list-san': SanitizerKind.NONE, + 'test_suite.parameters.test-list-os': OSKind.LIN, + 'test_suite.parameters.test-list-build': BuildTypeKind.FAST_VERIFY, + 'test_suite.parameters.force-generate': False, + 'test_suite.parameters.compare-files': False, + 'test_suite.parameters.compare-files-iterations': 2, + 'test_suite.parameters.groups': 1, + 'test_suite.parameters.group-number': 1, + 'test_suite.parameters.chapters': None, + 'test_suite.parameters.chapters-file': 'chapters.yaml', + 'test_suite.parameters.extension': 'sts', + 'test_suite.parameters.load-runtimes': 'ets', + 'test_suite.parameters.work-dir': '.', + 'runner.processes': 12, + 'runner.detailed_report': True, + 'runner.detailed_report_file': 'my-report', + 'runner.show_progress': True, + 'runner.verbose': VerboseKind.SHORT, + 'runner.verbose_filter': VerboseFilter.IGNORED, + 'runner.qemu': QemuKind.ARM64, + 'runner.enable_time_report': True, + 'runner.time_edges': [1, 10, 100, 500], + 'runner.use_llvm_cov': True, + 'runner.llvm_cov_profdata_out_path': Path.cwd().resolve().resolve(), + 'runner.coverage_html_report_dir': Path.cwd().resolve().resolve() +} diff --git a/static_core/tests/tests-u-runner-2/runner/test/generators_test/data/func.ets.j2 b/static_core/tests/tests-u-runner-2/runner/test/generators_test/data/func.ets.j2 new file mode 100644 index 0000000000..0135531820 --- /dev/null +++ b/static_core/tests/tests-u-runner-2/runner/test/generators_test/data/func.ets.j2 @@ -0,0 +1,37 @@ +{# + Copyright (c) 2024-2025 Huawei Device Co., Ltd. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} + +{%- for op in operations -%} +{%- for expr in expression_list -%} + +{%- set expr_token = expr.split(":")%} +{{.enum_type_def}} + +function test() { + let left : {{.expr_token[0]}} = {{.expr_token[1]}} + let right : {{.expr_token[2]}} = {{.expr_token[3]}} + if (left {{.op}} right) { + return 0; + } else { + return 1; + } +} + +function main() { + return test() +} +{{.sep}} +{%- endfor -%} +{%- endfor -%} diff --git a/static_core/tests/tests-u-runner-2/runner/test/generators_test/func_templates_generator_test.py b/static_core/tests/tests-u-runner-2/runner/test/generators_test/func_templates_generator_test.py new file mode 100644 index 0000000000..b01288d536 --- /dev/null +++ b/static_core/tests/tests-u-runner-2/runner/test/generators_test/func_templates_generator_test.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +# -- coding: utf-8 -- +# +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import shutil +from pathlib import Path +from unittest import TestCase + +from runner.extensions.generators.sts_stdlib.func_templates_generator import FuncTestsCodeGenerator +from runner.options.config import Config +from runner.test.generators_test.data import data_test_suite0 +from runner.test.test_utils import random_suffix + + +class FuncTemplatesGeneratorTest(TestCase): + args = data_test_suite0.args + + def setUp(self) -> None: + os.environ["ARKCOMPILER_RUNTIME_CORE_PATH"] = "." + os.environ["ARKCOMPILER_ETS_FRONTEND_PATH"] = "." + os.environ["WORK_DIR"] = "." + os.environ["PANDA_BUILD"] = "." + self.config = Config(self.args) + + def test_generate(self) -> None: + # preparation + test_source_path: Path = Path(__file__).with_name("data") + test_gen_path: Path = Path(__file__).with_name("gen") + shutil.rmtree(test_gen_path, ignore_errors=True) + # test + ets_templates_generator = FuncTestsCodeGenerator(test_source_path, test_gen_path, self.config) + ets_templates_generator.generate() + self.assertTrue(test_gen_path.exists()) + generated_tests = sorted(test.stem for test in test_gen_path.glob("*")) + expected_tests = [ + "test-func-0001", + "test-func-0002", + "test-func-0003", + "test-func-0004" + ] + self.assertEqual(len(generated_tests), 4) + self.assertListEqual(generated_tests, expected_tests) + # clear up + shutil.rmtree(test_gen_path, ignore_errors=True) + + def test_generate_empty(self) -> None: + # preparation + test_source_path: Path = Path(__file__).with_name("data" + random_suffix()) + test_gen_path: Path = Path(__file__).with_name("gen" + random_suffix()) + test_source_path.mkdir(parents=True, exist_ok=True) + shutil.rmtree(test_gen_path, ignore_errors=True) + # test + ets_templates_generator = FuncTestsCodeGenerator(test_source_path, test_gen_path, self.config) + ets_templates_generator.generate() + self.assertTrue(test_gen_path.exists()) + generated_tests = sorted(test.stem for test in test_gen_path.glob("*")) + expected_tests: list[str] = [] + self.assertEqual(len(generated_tests), 0) + self.assertListEqual(generated_tests, expected_tests) + # clear up + shutil.rmtree(test_source_path, ignore_errors=True) + shutil.rmtree(test_gen_path, ignore_errors=True) diff --git a/static_core/tests/tests-u-runner/runner/plugins/ets/test_ets.py b/static_core/tests/tests-u-runner/runner/plugins/ets/test_ets.py index cdb4d26881..041d59f78b 100644 --- a/static_core/tests/tests-u-runner/runner/plugins/ets/test_ets.py +++ b/static_core/tests/tests-u-runner/runner/plugins/ets/test_ets.py @@ -186,9 +186,6 @@ class TestETS(TestFileBased): if not self.continue_after_process_dependent_files(): return self - if not self.is_valid_test and not self.is_compile_only: - return self - if not self.is_valid_test and self.is_compile_only: self.passed, self.report, self.fail_kind = self._run_compiler(self.test_abc) return self diff --git a/static_core/tests/tests-u-runner/runner/runner_base.py b/static_core/tests/tests-u-runner/runner/runner_base.py index 5e0aa5fda2..cbd55aa155 100644 --- a/static_core/tests/tests-u-runner/runner/runner_base.py +++ b/static_core/tests/tests-u-runner/runner/runner_base.py @@ -257,9 +257,20 @@ class Runner(ABC): # Read excluded_lists and load list of excluded tests def load_excluded_tests(self) -> None: excluded_tests = self.load_tests_from_lists(self.excluded_lists) - self.excluded_tests.update(excluded_tests) + + if self.config.test_lists.groups.quantity > 1: + groups = self.config.test_lists.groups.quantity + n_group = self.config.test_lists.groups.number + n_group = n_group if n_group <= groups else groups + excluded_tests_in_group = { + test for test in excluded_tests + if get_group_number(Path(test).relative_to(self.test_root).as_posix(), groups) == n_group} + self.excluded_tests.update(excluded_tests_in_group) + else: + self._search_duplicates(excluded_tests, "excluded") + self.excluded_tests.update(excluded_tests) + self.excluded = len(self.excluded_tests) - self._search_duplicates(excluded_tests, "excluded") # Read ignored_lists and load list of ignored tests def load_ignored_tests(self) -> None: @@ -314,7 +325,7 @@ class Runner(ABC): valid_tests = {test for test in valid_tests if get_group_number(test.test_id, groups) == n_group} self.tests.update(valid_tests) - Log.default(_LOGGER, f"Loaded {len(valid_tests)} tests from directory '{directory}'. " + Log.default(_LOGGER, f"Loaded {len(valid_tests)} valid tests from the folder '{directory}'. " f"Excluded {len(self.excluded_tests)} tests are not loaded.") def _search_both_excluded_and_ignored_tests(self) -> None: -- Gitee