From 71f25cb8780a4eb7d5ddb6a098bb2d4e571ccc29 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Mon, 19 Feb 2024 17:00:50 +0000 Subject: [PATCH] Split tests into two packages in Bazel build. 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. --- enzyme/BUILD | 53 ++--------------------------------- enzyme/test/BUILD | 32 +++++++++++++++++++++ enzyme/test/Integration/BUILD | 29 +++++++++++++++++++ enzyme/test/MLIR/BUILD | 25 +++++++++++++++++ 4 files changed, 88 insertions(+), 51 deletions(-) create mode 100644 enzyme/test/BUILD create mode 100644 enzyme/test/Integration/BUILD create mode 100644 enzyme/test/MLIR/BUILD diff --git a/enzyme/BUILD b/enzyme/BUILD index 9bf6fadabe9a..79e22ff59658 100644 --- a/enzyme/BUILD +++ b/enzyme/BUILD @@ -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"]) @@ -633,52 +631,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"]) + diff --git a/enzyme/test/BUILD b/enzyme/test/BUILD new file mode 100644 index 000000000000..47143966810d --- /dev/null +++ b/enzyme/test/BUILD @@ -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__"], +) + diff --git a/enzyme/test/Integration/BUILD b/enzyme/test/Integration/BUILD new file mode 100644 index 000000000000..ab14f8fca82e --- /dev/null +++ b/enzyme/test/Integration/BUILD @@ -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"], + ) +] diff --git a/enzyme/test/MLIR/BUILD b/enzyme/test/MLIR/BUILD new file mode 100644 index 000000000000..0af1496b3a5c --- /dev/null +++ b/enzyme/test/MLIR/BUILD @@ -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", + ], + ) +]