mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-11-23 19:29:17 +03:00
Simplified definition of tests.
This commit is contained in:
parent
6003d8346f
commit
0b5a88b9ab
@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
bazel build //test:all-tests && bazel-bin/test/all-tests
|
||||
bazel test //test:all-tests
|
||||
|
@ -1,8 +1,12 @@
|
||||
load(":macros.bzl", "simple_target_test")
|
||||
|
||||
# Catch2 is test framework that we are using. It has only one header file, which we included directly in code.
|
||||
cc_library(
|
||||
name = "catch2",
|
||||
hdrs = ["catch.hpp"]
|
||||
)
|
||||
|
||||
# In order to be able to run Catch2 tests, it is important to have this main method defined (as by Catch2 documentation).
|
||||
cc_library(
|
||||
name = "catch-main",
|
||||
srcs = ["main.cpp"],
|
||||
@ -11,16 +15,14 @@ cc_library(
|
||||
]
|
||||
)
|
||||
|
||||
# TODO: I could use macros to define each test individiually in easy way.
|
||||
# Individual tests (per target). Each expects .test.cpp file with same name to exist.
|
||||
# Add new tests here! Also, add them to test suite all-tests below.
|
||||
simple_target_test("hello-world")
|
||||
|
||||
cc_test(
|
||||
# Test suite that runs all the tests.
|
||||
test_suite(
|
||||
name = "all-tests",
|
||||
srcs = glob(["**/*.test.cpp"]),
|
||||
copts = ["-Isrc/"],
|
||||
deps = [
|
||||
":catch2",
|
||||
"catch-main",
|
||||
|
||||
"//src:hello-world"
|
||||
tests = [
|
||||
"hello-world"
|
||||
]
|
||||
)
|
||||
|
13
stic/test/macros.bzl
Normal file
13
stic/test/macros.bzl
Normal file
@ -0,0 +1,13 @@
|
||||
# Given target name from //src package, expects .test.cpp file with same name.
|
||||
# Creates a cc_test for that target.
|
||||
def simple_target_test(target_name):
|
||||
native.cc_test(
|
||||
name = target_name,
|
||||
srcs = [target_name + ".test.cpp"],
|
||||
copts = ["-Isrc/"],
|
||||
deps = [
|
||||
":catch2",
|
||||
"catch-main",
|
||||
"//src:" + target_name
|
||||
]
|
||||
)
|
Loading…
Reference in New Issue
Block a user