Skip to content

Commit

Permalink
Split tests into two packages in Bazel build. (#1741)
Browse files Browse the repository at this point in the history
This separates MLIR tests and regular Enzyme integration tests into independent
packages, making sure only a subset of targets is rebuilt and retested when
requested to decrease overhead.
  • Loading branch information
ftynse authored Feb 20, 2024
1 parent 1ea2e0b commit e8ca2b1
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 51 deletions.
53 changes: 2 additions & 51 deletions enzyme/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
load("@llvm-project//llvm:lit_test.bzl", "lit_test", "package_path")
load("@llvm-project//llvm:tblgen.bzl", "gentbl")
load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")

licenses(["notice"])

Expand Down Expand Up @@ -640,52 +638,5 @@ cc_binary(
],
)

# Generates lit config input file by applying path placeholder substitutions
# similar to the configure_lit_site_cfg CMake macro.
expand_template(
name = "lit_site_cfg_py",
testonly = True,
out = "test/lit.site.cfg.py",
substitutions = {
"@LLVM_VERSION_MAJOR@": "18",
"@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.",
"@LLVM_BINARY_DIR@": package_path("@llvm-project//llvm:BUILD"),
"@LLVM_TOOLS_BINARY_DIR@": package_path("@llvm-project//llvm:BUILD"),
"@LLVM_LIBS_DIR@": package_path("@llvm-project//llvm:BUILD"),
"@ENZYME_SOURCE_DIR@": "",
"@ENZYME_BINARY_DIR@": "",
"@TARGET_TRIPLE@": "",
"@TARGETS_TO_BUILD@": "ALL",
"@LLVM_SHLIBEXT@": ".so",
},
template = "test/lit.site.cfg.py.in",
visibility = ["//visibility:private"],
)

[
lit_test(
name = "%s.test" % src,
srcs = [src],
data = [
":enzyme-clang",
":enzyme-clang++",
":enzyme-opt",
":enzymemlir-opt",
":test/lit.cfg.py",
":test/lit.site.cfg.py",
"@llvm-project//clang:builtin_headers_gen",
"@llvm-project//llvm:FileCheck",
"@llvm-project//llvm:count",
"@llvm-project//llvm:lli",
"@llvm-project//llvm:not",
] + glob(["test/**/*.h"]),
)
for src in glob(
[
"test/**/*.mlir",
"test/Integration/**/*.c",
"test/Integration/**/.cpp",
],
exclude = ["test/**/*omp*.c"],
)
]
exports_files(["run_lit.sh"])

32 changes: 32 additions & 0 deletions enzyme/test/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Enzyme tests.

load("@llvm-project//llvm:lit_test.bzl", "package_path")
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")

# Generates lit config input file by applying path placeholder substitutions
# similar to the configure_lit_site_cfg CMake macro.
expand_template(
name = "lit_site_cfg_py",
testonly = True,
out = "lit.site.cfg.py",
substitutions = {
"@LLVM_VERSION_MAJOR@": "18",
"@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.",
"@LLVM_BINARY_DIR@": package_path("@llvm-project//llvm:BUILD"),
"@LLVM_TOOLS_BINARY_DIR@": package_path("@llvm-project//llvm:BUILD"),
"@LLVM_LIBS_DIR@": package_path("@llvm-project//llvm:BUILD"),
"@ENZYME_SOURCE_DIR@": "",
"@ENZYME_BINARY_DIR@": "",
"@TARGET_TRIPLE@": "",
"@TARGETS_TO_BUILD@": "ALL",
"@LLVM_SHLIBEXT@": ".so",
},
template = "lit.site.cfg.py.in",
visibility = [":__subpackages__"],
)

exports_files(
["lit.cfg.py"],
visibility = [":__subpackages__"],
)

29 changes: 29 additions & 0 deletions enzyme/test/Integration/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Enzyme integration tests.

load("@llvm-project//llvm:lit_test.bzl", "lit_test")

[
lit_test(
name = "%s.test" % src,
srcs = [src],
data = [
"//:enzyme-clang",
"//:enzyme-clang++",
"//:enzyme-opt",
"//test:lit.cfg.py",
"//test:lit.site.cfg.py",
"@llvm-project//clang:builtin_headers_gen",
"@llvm-project//llvm:FileCheck",
"@llvm-project//llvm:count",
"@llvm-project//llvm:lli",
"@llvm-project//llvm:not",
] + glob(["**/*.h"]),
)
for src in glob(
[
"**/*.c",
"**/.cpp",
],
exclude = ["**/*omp*.c"],
)
]
25 changes: 25 additions & 0 deletions enzyme/test/MLIR/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# MLIR-specific tests for Enzyme.

load("@llvm-project//llvm:lit_test.bzl", "lit_test")

[
lit_test(
name = "%s.test" % src,
srcs = [src],
data = [
"//:enzymemlir-opt",
"//test:lit.cfg.py",
"//test:lit.site.cfg.py",
"@llvm-project//clang:builtin_headers_gen",
"@llvm-project//llvm:FileCheck",
"@llvm-project//llvm:count",
"@llvm-project//llvm:lli",
"@llvm-project//llvm:not",
] + glob(["**/*.h"]),
)
for src in glob(
[
"**/*.mlir",
],
)
]

0 comments on commit e8ca2b1

Please sign in to comment.