• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2025 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15
16_tryit() {
17    coverage run --parallel-mode --module taihe.cli.tryit "$@"
18}
19
20run-core-tests() {
21    for test_dir in ../test/rgb ../test/object; do
22        echo "Testing: $test_dir"
23        _tryit test -u cpp $test_dir
24    done
25}
26
27run-ani-tests() {
28    echo "Running ANI tests..."
29
30    cd ..
31    if [ -d "build" ]; then
32        echo "Build directory found. Skipping CMake configuration."
33    else
34        echo "Build directory not found. Configuring with CMake."
35        if [ -n "$1" ]; then
36            echo "Using custom PANDA_HOME: $1"
37            cmake -B build -GNinja -DENABLE_COVERAGE=ON -DPANDA_HOME="$1"
38        else
39            echo "No PANDA_HOME provided"
40            cmake -B build -GNinja -DENABLE_COVERAGE=ON
41        fi
42    fi
43    cmake --build build --verbose
44    cd compiler
45}
46
47run-cmake-test() {
48    test_dir=../test/cmake_test
49    echo "Testing: $test_dir"
50    _tryit generate -u sts $test_dir --cmake
51    cd ../test/cmake_test/
52    cmake -B build/generated \
53        -D EXTERNAL_INCLUDE=$(realpath ../../.panda_vm/package/ohos_arm64/include/plugins/ets/runtime/ani)
54    cmake --build build/generated
55    cd ../..
56    cd compiler
57}
58
59run-pytest() {
60    echo "Running pytest..."
61    coverage run --parallel-mode --module pytest
62}
63
64source "$(dirname "$0")/common_lib.sh"
65init_py_env
66
67# Add trap to ensure coverage is reported even if script exits early
68trap "coverage combine && coverage report" EXIT
69
70run-pytest
71if [ $# -eq 0 ]; then
72    echo "No PANDA_HOME provided, running without -DPANDA_HOME"
73    run-ani-tests ""
74else
75    run-ani-tests $1
76fi
77
78# The coverage report will be generated by the EXIT trap
79echo "Generating coverage report..."
80