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 18import logging 19from typing import List, Any 20 21from runner.test_file_based import TestFileBased 22from runner.enum_types.params import TestEnv 23 24_LOGGER = logging.getLogger("runner.plugins.declgenparser.test_declgenparser") 25 26 27class TestDeclgenParser(TestFileBased): 28 def __init__(self, test_env: TestEnv, test_path: str, flags: List[str], test_id: str) -> None: 29 TestFileBased.__init__(self, test_env, test_path, flags, test_id) 30 31 def do_run(self) -> TestFileBased: 32 es2panda_flags = self.es2panda_flags() 33 es2panda_flags.extend(self.flags) 34 es2panda_flags.append("--output=/dev/null") 35 self.passed, self.report, self.fail_kind = self.run_es2panda( 36 flags=es2panda_flags, 37 test_abc="", 38 result_validator=self.es2panda_result_validator, 39 ) 40 return self 41 42 def es2panda_flags(self) -> List[str]: 43 # we want "--opt-level=2", but currently it does not work with `--output=/dev/null` 44 return [] 45 46 def es2panda_result_validator(self, _actual_output: str, _: Any, actual_return_code: int) -> bool: 47 return actual_return_code == 0 48