Skip to content

Commit d8f45ee

Browse files
committed
Export headers and build test
1 parent ab6f955 commit d8f45ee

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

build.zig

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub fn build(b: *std.Build) !void {
3535
.flags = &CXXFLAGS,
3636
});
3737
catch2.installConfigHeader(config);
38+
catch2.installHeadersDirectory(upstream.path("src"), "", .{ .include_extensions = &.{".hpp"} });
3839

3940
const with_main = b.addStaticLibrary(.{ .name = "Catch2WithMain", .target = target, .optimize = optimize });
4041
with_main.addCSourceFiles(.{
@@ -43,12 +44,21 @@ pub fn build(b: *std.Build) !void {
4344
.flags = &CXXFLAGS,
4445
});
4546

47+
const test_step = b.step("test", "Run tests");
48+
const test_exe = b.addExecutable(.{ .name = "SelfTest", .target = target, .optimize = optimize });
49+
test_exe.addIncludePath(upstream.path("tests/SelfTest"));
50+
test_exe.addCSourceFiles(.{ .root = upstream.path("tests/SelfTest"), .files = &test_files, .flags = &CXXFLAGS });
51+
test_exe.linkLibCpp();
52+
const install_test = b.addInstallArtifact(test_exe, .{});
53+
test_step.dependOn(&install_test.step);
54+
4655
const libs = [_]*std.Build.Step.Compile{ catch2, with_main };
4756
for (libs) |lib| {
4857
lib.linkLibCpp();
4958
lib.addIncludePath(upstream.path("src"));
5059
lib.addConfigHeader(config);
5160
b.installArtifact(lib);
61+
test_exe.linkLibrary(lib);
5262
}
5363
}
5464

@@ -171,3 +181,64 @@ const source_files = .{
171181
"reporters/catch_reporter_teamcity.cpp",
172182
"reporters/catch_reporter_xml.cpp",
173183
};
184+
185+
const test_files = .{
186+
"TestRegistrations.cpp",
187+
"IntrospectiveTests/Algorithms.tests.cpp",
188+
"IntrospectiveTests/AssertionHandler.tests.cpp",
189+
"IntrospectiveTests/Clara.tests.cpp",
190+
"IntrospectiveTests/CmdLine.tests.cpp",
191+
"IntrospectiveTests/CmdLineHelpers.tests.cpp",
192+
"IntrospectiveTests/ColourImpl.tests.cpp",
193+
"IntrospectiveTests/Details.tests.cpp",
194+
"IntrospectiveTests/FloatingPoint.tests.cpp",
195+
"IntrospectiveTests/GeneratorsImpl.tests.cpp",
196+
"IntrospectiveTests/Integer.tests.cpp",
197+
"IntrospectiveTests/InternalBenchmark.tests.cpp",
198+
"IntrospectiveTests/Json.tests.cpp",
199+
"IntrospectiveTests/Parse.tests.cpp",
200+
"IntrospectiveTests/PartTracker.tests.cpp",
201+
"IntrospectiveTests/RandomNumberGeneration.tests.cpp",
202+
"IntrospectiveTests/Reporters.tests.cpp",
203+
"IntrospectiveTests/Tag.tests.cpp",
204+
"IntrospectiveTests/TestCaseInfoHasher.tests.cpp",
205+
"IntrospectiveTests/TestSpec.tests.cpp",
206+
"IntrospectiveTests/TestSpecParser.tests.cpp",
207+
"IntrospectiveTests/TextFlow.tests.cpp",
208+
"IntrospectiveTests/Sharding.tests.cpp",
209+
"IntrospectiveTests/Stream.tests.cpp",
210+
"IntrospectiveTests/String.tests.cpp",
211+
"IntrospectiveTests/StringManip.tests.cpp",
212+
"IntrospectiveTests/Xml.tests.cpp",
213+
"IntrospectiveTests/Traits.tests.cpp",
214+
"IntrospectiveTests/ToString.tests.cpp",
215+
"IntrospectiveTests/UniquePtr.tests.cpp",
216+
"helpers/parse_test_spec.cpp",
217+
"TimingTests/Sleep.tests.cpp",
218+
"UsageTests/Approx.tests.cpp",
219+
"UsageTests/BDD.tests.cpp",
220+
"UsageTests/Benchmark.tests.cpp",
221+
"UsageTests/Class.tests.cpp",
222+
"UsageTests/Compilation.tests.cpp",
223+
"UsageTests/Condition.tests.cpp",
224+
"UsageTests/Decomposition.tests.cpp",
225+
"UsageTests/EnumToString.tests.cpp",
226+
"UsageTests/Exception.tests.cpp",
227+
"UsageTests/Generators.tests.cpp",
228+
"UsageTests/Message.tests.cpp",
229+
"UsageTests/Misc.tests.cpp",
230+
"UsageTests/Skip.tests.cpp",
231+
"UsageTests/ToStringByte.tests.cpp",
232+
"UsageTests/ToStringChrono.tests.cpp",
233+
"UsageTests/ToStringGeneral.tests.cpp",
234+
"UsageTests/ToStringOptional.tests.cpp",
235+
"UsageTests/ToStringPair.tests.cpp",
236+
"UsageTests/ToStringTuple.tests.cpp",
237+
"UsageTests/ToStringVariant.tests.cpp",
238+
"UsageTests/ToStringVector.tests.cpp",
239+
"UsageTests/ToStringWhich.tests.cpp",
240+
"UsageTests/Tricky.tests.cpp",
241+
"UsageTests/VariadicMacros.tests.cpp",
242+
"UsageTests/MatchersRanges.tests.cpp",
243+
"UsageTests/Matchers.tests.cpp",
244+
};

0 commit comments

Comments
 (0)