diff --git a/BUILD.bazel b/BUILD.bazel index 36d1c5a25ba..da5071a9a29 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1311,3 +1311,12 @@ gentbl_cc_library( ":vhlo_ops_td_files", ], ) + +test_suite( + name = "stablehlo_ci_tests", + tests = [ + "//stablehlo/tests:stablehlo_tests", + "//stablehlo/testdata:stablehlo_testdata_tests", + "//stablehlo/conversions/tosa/tests:stablehlo_tosa_tests" + ], +) diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 776cd5ca09d..f395aa1164e 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -13,6 +13,8 @@ # limitations under the License. """Workspace for StableHLO.""" +workspace(name = "stablehlo") + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") SKYLIB_VERSION = "1.3.0" diff --git a/stablehlo/conversions/tosa/tests/BUILD.bazel b/stablehlo/conversions/tosa/tests/BUILD.bazel index 9304c1ad543..cdbc35e1112 100644 --- a/stablehlo/conversions/tosa/tests/BUILD.bazel +++ b/stablehlo/conversions/tosa/tests/BUILD.bazel @@ -27,8 +27,8 @@ expand_template( substitutions = { "@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.", "@LLVM_TOOLS_DIR@": package_path("@llvm-project//llvm:BUILD"), - "@STABLEHLO_TOOLS_DIR@": ".", - "@STABLEHLO_SOURCE_DIR@": ".", + "\"@STABLEHLO_TOOLS_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'stablehlo')", + "\"@STABLEHLO_SOURCE_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'stablehlo')", }, template = "lit.site.cfg.py.in", ) @@ -45,6 +45,12 @@ expand_template( "@llvm-project//llvm:FileCheck", ], size = "small", + tags = ["stablehlo_tosa_tests"], ) for src in glob(["**/*.mlir"]) ] + +test_suite( + name = "stablehlo_tosa_tests", + tags = ["stablehlo_tosa_tests"], +) diff --git a/stablehlo/conversions/tosa/tests/lit.site.cfg.py.in b/stablehlo/conversions/tosa/tests/lit.site.cfg.py.in index bc65774850e..bfa327d5ae3 100644 --- a/stablehlo/conversions/tosa/tests/lit.site.cfg.py.in +++ b/stablehlo/conversions/tosa/tests/lit.site.cfg.py.in @@ -17,4 +17,4 @@ import lit.llvm lit.llvm.initialize(lit_config, config) config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.stablehlo_tools_dir = "@STABLEHLO_TOOLS_DIR@" -lit_config.load_config(config, "@STABLEHLO_SOURCE_DIR@/stablehlo/conversions/tosa/tests/lit.cfg.py") +lit_config.load_config(config, "@STABLEHLO_SOURCE_DIR@" + "/stablehlo/conversions/tosa/tests/lit.cfg.py") diff --git a/stablehlo/testdata/BUILD.bazel b/stablehlo/testdata/BUILD.bazel index 1b34e945324..366ec22f2af 100644 --- a/stablehlo/testdata/BUILD.bazel +++ b/stablehlo/testdata/BUILD.bazel @@ -27,8 +27,8 @@ expand_template( substitutions = { "@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.", "@LLVM_TOOLS_DIR@": package_path("@llvm-project//llvm:BUILD"), - "@STABLEHLO_TOOLS_DIR@": ".", - "@STABLEHLO_SOURCE_DIR@": ".", + "\"@STABLEHLO_TOOLS_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'stablehlo')", + "\"@STABLEHLO_SOURCE_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'stablehlo')", }, template = "lit.site.cfg.py.in", ) @@ -46,6 +46,13 @@ expand_template( "@llvm-project//llvm:FileCheck", ], size = "small", + tags = ["stablehlo_testdata_tests"], + ) for src in glob(["**/*.mlir"]) ] + +test_suite( + name = "stablehlo_testdata_tests", + tags = ["stablehlo_testdata_tests"], +) diff --git a/stablehlo/testdata/lit.site.cfg.py.in b/stablehlo/testdata/lit.site.cfg.py.in index b78557087da..d1da2093318 100644 --- a/stablehlo/testdata/lit.site.cfg.py.in +++ b/stablehlo/testdata/lit.site.cfg.py.in @@ -18,4 +18,4 @@ import lit.llvm lit.llvm.initialize(lit_config, config) config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.stablehlo_tools_dir = "@STABLEHLO_TOOLS_DIR@" -lit_config.load_config(config, "@STABLEHLO_SOURCE_DIR@/stablehlo/testdata/lit.cfg.py") +lit_config.load_config(config, "@STABLEHLO_SOURCE_DIR@" + "/stablehlo/testdata/lit.cfg.py") diff --git a/stablehlo/tests/BUILD.bazel b/stablehlo/tests/BUILD.bazel index 968627d42ec..50b74ce3514 100644 --- a/stablehlo/tests/BUILD.bazel +++ b/stablehlo/tests/BUILD.bazel @@ -130,8 +130,8 @@ expand_template( substitutions = { "@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.", "@LLVM_TOOLS_DIR@": package_path("@llvm-project//llvm:BUILD"), - "@STABLEHLO_TOOLS_DIR@": ".", - "@STABLEHLO_SOURCE_DIR@": ".", + "\"@STABLEHLO_TOOLS_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'stablehlo')", + "\"@STABLEHLO_SOURCE_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'stablehlo')", }, template = "lit.site.cfg.py.in", ) @@ -150,6 +150,12 @@ expand_template( "@llvm-project//llvm:not", ] + glob(["%s.bc" % src]), size = "small", + tags = ["stablehlo_tests"], ) for src in glob(["**/*.mlir"]) ] + +test_suite( + name = "stablehlo_tests", + tags = ["stablehlo_tests"], +) diff --git a/stablehlo/tests/lit.site.cfg.py.in b/stablehlo/tests/lit.site.cfg.py.in index 6f916bf7663..75537da56d1 100644 --- a/stablehlo/tests/lit.site.cfg.py.in +++ b/stablehlo/tests/lit.site.cfg.py.in @@ -18,4 +18,4 @@ import lit.llvm lit.llvm.initialize(lit_config, config) config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.stablehlo_tools_dir = "@STABLEHLO_TOOLS_DIR@" -lit_config.load_config(config, "@STABLEHLO_SOURCE_DIR@/stablehlo/tests/lit.cfg.py") +lit_config.load_config(config, "@STABLEHLO_SOURCE_DIR@" + "/stablehlo/tests/lit.cfg.py")