Skip to content

Commit

Permalink
added external dependency to simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
LeFrosch committed Oct 25, 2024
1 parent 6f92aa4 commit 3d7e126
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public void testClwb() {
errors.assertNoErrors();

checkCompiler();
checkTest();
}

private void checkCompiler() {
Expand All @@ -36,4 +37,11 @@ private void checkCompiler() {

assertContainsHeader("iostream", compilerSettings);
}

private void checkTest() {
final var compilerSettings = findFileCompilerSettings("main/test.cc");

assertContainsHeader("iostream", compilerSettings);
assertContainsHeader("catch2/catch_test_macros.hpp", compilerSettings);
}
}
20 changes: 20 additions & 0 deletions clwb/tests/projects/simple/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_skylib",
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()

http_archive(
name = "catch2",
sha256 = "c991b247a1a0d7bb9c39aa35faf0fe9e19764213f28ffba3109388e62ee0269c",
strip_prefix = "Catch2-3.7.1",
urls = ["https://github.com/catchorg/Catch2/archive/v3.7.1.tar.gz"],
)
9 changes: 7 additions & 2 deletions clwb/tests/projects/simple/main/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")

cc_binary(
name = "hello-world",
srcs = ["hello-world.cc"],
visibility = ["//visibility:public"]
)

cc_test(
name = "test",
srcs = ["test.cc"],
deps = ["@catch2//:catch2_main"],
)
5 changes: 5 additions & 0 deletions clwb/tests/projects/simple/main/test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <catch2/catch_test_macros.hpp>

TEST_CASE("0") {
REQUIRE(0 == 0);
}

0 comments on commit 3d7e126

Please sign in to comment.