• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3
4# Copyright (c) 2021-2024 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# limitations under the License.
16#
17
18from functools import cached_property
19from pathlib import Path
20from runner.options.options_general import GeneralOptions
21from runner.code_coverage.coverage_dir import CoverageDir
22
23
24class WorkDir:
25    def __init__(self, general: GeneralOptions, default_work_dir: Path):
26        self.__general = general
27        self.__default_work_dir = default_work_dir
28
29    @property
30    def report(self) -> Path:
31        return self.root / "report"
32
33    @property
34    def gen(self) -> Path:
35        return self.root / "gen"
36
37    @property
38    def intermediate(self) -> Path:
39        return self.root / "intermediate"
40
41    @cached_property
42    def root(self) -> Path:
43        root = Path(self.__general.work_dir) if self.__general.work_dir else self.__default_work_dir
44        root.mkdir(parents=True, exist_ok=True)
45        return root
46
47    @cached_property
48    def coverage_dir(self) -> CoverageDir:
49        return CoverageDir(self.__general, self.root)
50