Skip to content

Commit 2cc743a

Browse files
author
Fædon Jóhannes Sinis
committed
Add Bazel support for unit tests
1 parent ac4e2ee commit 2cc743a

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

.bazelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# bzlmod enables access to the Bazel Central Registry.
2+
# See https://registry.bazel.build/ for more details.
3+
# Enable Bzlmod for every Bazel command.
4+
# https://bazel.build/external/migration#enable-bzlmod
5+
common --enable_bzlmod
6+
7+
build --cxxopt=-std=c++20
8+
9+
# Display details on failing tests to stdout.
10+
# See https://bazel.build/docs/user-manual#test-output for documentation.
11+
test --test_output=errors

BUILD.bazel

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,28 @@ cc_library(
2424
"@nlohmann_json//:json",
2525
],
2626
)
27+
28+
cc_library(
29+
name = "polyscope_mock",
30+
srcs = glob(
31+
["src/**/*.cpp"],
32+
),
33+
hdrs = glob(
34+
[
35+
"include/**/*.h",
36+
"include/**/*.ipp",
37+
],
38+
),
39+
defines = [
40+
"POLYSCOPE_BACKEND_OPENGL_MOCK_ENABLED",
41+
],
42+
strip_include_prefix = "include",
43+
deps = [
44+
"//deps/MarchingCubeCpp:marching_cube",
45+
"//deps/glad",
46+
"//deps/stb",
47+
"@glm",
48+
"@imgui-1.86",
49+
"@nlohmann_json//:json",
50+
],
51+
)

test/BUILD.bazel

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cc_library(
2+
name = "test_lib",
3+
hdrs = glob(["include/*.h"]),
4+
includes = ["."],
5+
strip_include_prefix = "include",
6+
)
7+
8+
cc_test(
9+
name = "polyscope_tests",
10+
srcs = glob([
11+
"src/*.cpp",
12+
]),
13+
deps = [
14+
":test_lib",
15+
"//:polyscope_mock",
16+
"@com_google_googletest//:gtest_main",
17+
],
18+
)

0 commit comments

Comments
 (0)