-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathlit.cfg.py
67 lines (54 loc) · 2.16 KB
/
lit.cfg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# ===----------------------------------------------------------------------=== #
# Copyright (c) 2024, Modular Inc. All rights reserved.
#
# Licensed under the Apache License v2.0 with LLVM Exceptions:
# https://llvm.org/LICENSE.txt
#
# 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
from pathlib import Path
import lit.formats
import lit.llvm
config.test_format = lit.formats.ShTest(True)
# name: The name of this test suite.
config.name = "Mojo Public Examples"
# suffixes: A list of file extensions to treat as test files.
# TODO: Enable notebooks
config.suffixes = [".mojo", ".🔥"]
config.excludes = [
# No RUN: directive, just bare examples
"hello_interop.mojo",
"matmul.mojo",
] + [path.name for path in os.scandir("../examples/mojo") if path.is_dir()]
# Have the examples run in the build directory.
# The `run-examples.sh` script creates the build directory.
build_root = Path.cwd().parent.parent / "mojo" / "build"
# Execute the examples inside this part of the build
# directory to avoid polluting the source tree.
config.test_exec_root = build_root / "examples" / "mojo"
# test_source_root: The root path where tests are located.
config.test_source_root = Path(__file__).parent.resolve()
# Substitute %mojo for just `mojo` itself.
config.substitutions.insert(0, ("%mojo", "mojo"))
# MODULAR_HOME is at <package root>/share/max by default
pre_built_packages_path = (
Path(os.environ["MODULAR_HOME"]).parent.parent / "lib" / "mojo"
).resolve()
os.environ[
"MODULAR_MOJO_MAX_IMPORT_PATH"
] = f"{build_root},{pre_built_packages_path}"
# Pass through several environment variables
# to the underlying subprocesses that run the tests.
lit.llvm.initialize(lit_config, config)
lit.llvm.llvm_config.with_system_environment(
[
"MODULAR_HOME",
"MODULAR_MOJO_MAX_IMPORT_PATH",
"PATH",
]
)