Skip to content

Commit

Permalink
chore: bzlmod tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Sep 15, 2023
1 parent 1c446cc commit a369a16
Show file tree
Hide file tree
Showing 21 changed files with 130 additions and 126 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
external
test
.vsocde
.github
16 changes: 1 addition & 15 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
build --enable_platform_specific_config
build --incompatible_use_platforms_repo_for_constraints
build --incompatible_enable_cc_toolchain_resolution
build --incompatible_strict_action_env
build --enable_runfiles

build:windows --platforms=//bazel/platforms:windows

build:linux --platforms=//bazel/platforms:linux
build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux

build:no-warnings --per_file_copt=//.*@-Werror

common:ci --announce_rc
common:ci --disk_cache=~/.cache/bazel-disk-cache
import %workspace%/bazel/common.bazelrc

try-import %workspace%/user.bazelrc
15 changes: 7 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# bazel
/bazel-*
/user.bazelrc
bazel-*/
user.bazelrc

# https://github.com/hedronvision/bazel-compile-commands-extractor
/compile_commands.json
/external

# clangd
/.cache/
# editor stuff
compile_commands.json
external/
.cache/
.helix/
11 changes: 11 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module(
name = "ecsact_interpret",
version = "0.3.0",
compatibility_level = 3,
)

bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "magic_enum", version = "0.9.3")
bazel_dep(name = "ecsact_runtime", version = "0.4.1")
bazel_dep(name = "ecsact_parse", version = "0.2.2")
44 changes: 4 additions & 40 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -1,39 +1,5 @@
workspace(name = "ecsact_interpret")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "magic_enum",
sha256 = "6b948d1680f02542d651fc82154a9e136b341ce55c5bf300736b157e23f9df11",
strip_prefix = "magic_enum-0.8.1",
url = "https://github.com/Neargye/magic_enum/archive/refs/tags/v0.8.1.tar.gz",
)

http_archive(
name = "ecsact_runtime",
sha256 = "35b03aaef0925fda5b5aefb2d6a6e2c9593f31d6414ab157091f9ca26a992da3",
strip_prefix = "ecsact_runtime-0.3.0",
urls = ["https://github.com/ecsact-dev/ecsact_runtime/archive/refs/tags/0.3.0.tar.gz"],
)

http_archive(
name = "ecsact_parse",
sha256 = "3f83ae8af26b08472fceef768d2c719a7ea9bedfc907303b9d80d9a7c9b937e9",
strip_prefix = "ecsact_parse-0.2.0",
urls = ["https://github.com/ecsact-dev/ecsact_parse/archive/refs/tags/0.2.0.tar.gz"],
)

load("@ecsact_parse//:repositories.bzl", "ecsact_parse_dependencies")

ecsact_parse_dependencies()

http_archive(
name = "com_google_googletest",
sha256 = "d4cb2430eb82495a49a24310a609b99726726bf126c2fbfa92fd04c14f6a3b31",
strip_prefix = "googletest-d1a0039b97291dd1dc14f123b906bb7622ffe07c",
url = "https://github.com/google/googletest/archive/d1a0039b97291dd1dc14f123b906bb7622ffe07c.zip",
)

http_archive(
name = "hedron_compile_commands",
sha256 = "ed5aea1dc87856aa2029cb6940a51511557c5cac3dbbcb05a4abd989862c36b4",
Expand All @@ -47,9 +13,9 @@ hedron_compile_commands_setup()

http_archive(
name = "com_grail_bazel_toolchain",
sha256 = "c53acf847fb52198758635490c5e987aacc7c64a5731a4027824762ba4e3f961",
strip_prefix = "bazel-toolchain-c217c03479717279035906273702b8bc3309bbb4",
url = "https://github.com/grailbio/bazel-toolchain/archive/c217c03479717279035906273702b8bc3309bbb4.zip",
sha256 = "6c0234db448fea2533c33468ea37207fb4add601667c2e0842f20104ed2ff366",
strip_prefix = "bazel-toolchain-e4fad4e6c1821d805ffd9c21bdd6e2cc52764862",
url = "https://github.com/grailbio/bazel-toolchain/archive/e4fad4e6c1821d805ffd9c21bdd6e2cc52764862.zip",
)

load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies")
Expand All @@ -60,9 +26,7 @@ load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")

llvm_toolchain(
name = "llvm_toolchain",
cxx_standard = {"linux": "c++20"},
distribution = "clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz",
llvm_version = "15.0.6",
llvm_version = "16.0.4",
)

load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
Expand Down
6 changes: 6 additions & 0 deletions bazel/common.bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# This file is maintained by ecsact-dev/ecsact_common
# If changes are required please make them there

startup --windows_enable_symlinks
common --enable_bzlmod
common --registry=https://raw.githubusercontent.com/ecsact-dev/bazel_registry/main
common --registry=https://raw.githubusercontent.com/bazelboost/registry/main
common --registry=https://bcr.bazel.build
build --enable_platform_specific_config
build --incompatible_use_platforms_repo_for_constraints
build --incompatible_enable_cc_toolchain_resolution
Expand Down
19 changes: 0 additions & 19 deletions bazel/platforms/BUILD.bazel

This file was deleted.

3 changes: 3 additions & 0 deletions test/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import %workspace%/../bazel/common.bazelrc

try-import %workspace%/user.bazelrc
26 changes: 13 additions & 13 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//bazel:copts.bzl", "copts")
load("@ecsact_interpret//bazel:copts.bzl", "copts")

cc_library(
name = "test_lib",
hdrs = ["test_lib.hh"],
visibility = ["//test:__subpackages__"],
visibility = ["//:__subpackages__"],
deps = [
"//:ecsact_interpret",
"@ecsact_interpret",
"@bazel_sundry//bazel_sundry:runfiles",
"@com_google_googletest//:gtest",
"@googletest//:gtest",
],
)

Expand All @@ -18,10 +18,10 @@ cc_test(
copts = copts,
data = ["test.ecsact"],
deps = [
"//:ecsact_interpret",
"@ecsact_interpret",
"@bazel_sundry//bazel_sundry:runfiles",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)

Expand All @@ -32,10 +32,10 @@ cc_test(
data = ["comment_before_package.ecsact"],
deps = [
":test_lib",
"//:ecsact_interpret",
"@ecsact_interpret",
"@bazel_sundry//bazel_sundry:runfiles",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)

Expand All @@ -51,9 +51,9 @@ cc_test(
],
deps = [
":test_lib",
"//:ecsact_interpret",
"@ecsact_interpret",
"@bazel_sundry//bazel_sundry:runfiles",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)
18 changes: 18 additions & 0 deletions test/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module(name = "ecsact_interpret_test")

bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "googletest", version = "1.14.0")
bazel_dep(name = "bazel_sundry")
bazel_dep(name = "ecsact_interpret")

git_override(
module_name = "bazel_sundry",
commit = "a999751b4992fab12a06f1bede2414708c6db540",
remote = "https://github.com/seaube/bazel_sundry",
)

local_path_override(
module_name = "ecsact_interpret",
path = "..",
)
34 changes: 34 additions & 0 deletions test/WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "hedron_compile_commands",
sha256 = "ed5aea1dc87856aa2029cb6940a51511557c5cac3dbbcb05a4abd989862c36b4",
strip_prefix = "bazel-compile-commands-extractor-e16062717d9b098c3c2ac95717d2b3e661c50608",
url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/e16062717d9b098c3c2ac95717d2b3e661c50608.tar.gz",
)

load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")

hedron_compile_commands_setup()

http_archive(
name = "com_grail_bazel_toolchain",
sha256 = "6c0234db448fea2533c33468ea37207fb4add601667c2e0842f20104ed2ff366",
strip_prefix = "bazel-toolchain-e4fad4e6c1821d805ffd9c21bdd6e2cc52764862",
url = "https://github.com/grailbio/bazel-toolchain/archive/e4fad4e6c1821d805ffd9c21bdd6e2cc52764862.zip",
)

load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies")

bazel_toolchain_dependencies()

load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")

llvm_toolchain(
name = "llvm_toolchain",
llvm_version = "16.0.4",
)

load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")

llvm_register_toolchains()
2 changes: 1 addition & 1 deletion test/comment_before_package.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"

#include "test/test_lib.hh"
#include "test_lib.hh"

TEST(NoPackageStatementFirst, NoPackageStatementFirst) {
auto errs = ecsact_interpret_test_files({"comment_before_package.ecsact"});
Expand Down
9 changes: 5 additions & 4 deletions test/errors/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("//bazel:copts.bzl", "copts")
load("@ecsact_interpret//bazel:copts.bzl", "copts")

_TESTS = [
"no_capabilities",
Expand All @@ -14,8 +14,9 @@ _TESTS = [
data = ["{}.ecsact".format(test)],
args = ["--gtest_catch_exceptions=0"],
deps = [
"//test:test_lib",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
"//:test_lib",
"@ecsact_interpret",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
) for test in _TESTS]
2 changes: 1 addition & 1 deletion test/errors/no_capabilities.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"

#include "test/test_lib.hh"
#include "test_lib.hh"

TEST(NoCapabilities, NoCapabilitiesAction) {
auto errs = ecsact_interpret_test_files({"errors/no_capabilities.ecsact"});
Expand Down
2 changes: 1 addition & 1 deletion test/errors/no_package_statement_first.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"

#include "test/test_lib.hh"
#include "test_lib.hh"

TEST(NoPackageStatementFirst, NoPackageStatementFirst) {
auto errs =
Expand Down
2 changes: 1 addition & 1 deletion test/errors/unknown_association_field.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"

#include "test/test_lib.hh"
#include "test_lib.hh"

TEST(InterpretError, UnknownAssociationField) {
auto errs =
Expand Down
38 changes: 19 additions & 19 deletions test/extra/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//bazel:copts.bzl", "copts")

cc_test(
name = "extra",
srcs = ["extra.cc"],
copts = copts,
data = [
"runtime_test.ecsact",
"imported_pkg.ecsact",
],
deps = [
"//test:test_lib",
"//:ecsact_interpret",
"@bazel_sundry//bazel_sundry:runfiles",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@ecsact_interpret//bazel:copts.bzl", "copts")

cc_test(
name = "extra",
srcs = ["extra.cc"],
copts = copts,
data = [
"runtime_test.ecsact",
"imported_pkg.ecsact",
],
deps = [
"//:test_lib",
"@ecsact_interpret",
"@bazel_sundry//bazel_sundry:runfiles",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)
2 changes: 1 addition & 1 deletion test/extra/extra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ecsact/interpret/eval.h"
#include "ecsact/runtime/meta.hh"

#include "test/test_lib.hh"
#include "test_lib.hh"

TEST(MultiPkgTest, NoErrors) {
auto errs = ecsact_interpret_test_files({
Expand Down
2 changes: 1 addition & 1 deletion test/multi_pkg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ecsact/interpret/eval.h"
#include "ecsact/runtime/meta.hh"

#include "test/test_lib.hh"
#include "test_lib.hh"

TEST(MultiPkgTest, NoErrors) {
auto errs = ecsact_interpret_test_files({
Expand Down
2 changes: 1 addition & 1 deletion test/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ TEST(EcsactParseRuntimeInterop, Simple) {
auto runfiles = bazel_sundry::CreateDefaultRunfiles();
ASSERT_TRUE(runfiles);

auto test_ecsact = runfiles->Rlocation("ecsact_interpret/test/test.ecsact");
auto test_ecsact = runfiles->Rlocation("ecsact_interpret_test/test.ecsact");
ASSERT_FALSE(test_ecsact.empty());
ASSERT_TRUE(fs::exists(test_ecsact));

Expand Down
2 changes: 1 addition & 1 deletion test/test_lib.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ auto ecsact_interpret_test_files(std::vector<std::string> relative_file_paths)
file_paths.reserve(relative_file_paths.size());

for(auto rel_p : relative_file_paths) {
auto path_rloc = "ecsact_interpret/test/" + rel_p;
auto path_rloc = "ecsact_interpret_test/" + rel_p;
auto path = runfiles->Rlocation(path_rloc);
[&] {
ASSERT_FALSE(path.empty()) << "couldn't find: " << path_rloc << "\n";
Expand Down

0 comments on commit a369a16

Please sign in to comment.