• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -- coding: utf-8 --
3#
4# Copyright (c) 2024-2025 Huawei Device Co., Ltd.
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15
16
17from pathlib import Path
18
19import yaml
20
21from runner.logger import Log
22
23_LOGGER = Log.get_logger(__file__)
24
25
26class StepUtils:
27    TEST_GENERATOR_REPORT = "test_generator_report.yaml"
28
29    def are_tests_generated(self, generated_folder: Path) -> bool:
30        report_path = generated_folder / self.TEST_GENERATOR_REPORT
31        return report_path.is_file()
32
33    def create_report(self, generated_folder: Path, tests: list[Path]) -> None:
34        report_path = generated_folder / self.TEST_GENERATOR_REPORT
35        report_obj = {}
36        for test_full_name in tests:
37            test_name = test_full_name.name
38            dir_name = test_full_name.parent
39            test_dir = str(dir_name.relative_to(generated_folder))
40            if test_dir not in report_obj:
41                report_obj[test_dir] = [test_name]
42            else:
43                report_obj[test_dir].append(test_name)
44        report_path.parent.mkdir(exist_ok=True)
45        report_path.write_text(yaml.dump(report_obj), encoding="utf-8")
46