@@ -12,11 +12,14 @@ pub fn build(b: *std.Build) void {
1212 });
1313
1414 // Unit tests
15- const tests = b .addExecutable (.{
16- .name = "minish-tests" ,
17- .root_module = minish_mod ,
15+ const test_mod = b .createModule (.{
16+ .root_source_file = b .path ("src/lib.zig" ),
17+ .target = target ,
18+ .optimize = optimize ,
19+ });
20+ const tests = b .addTest (.{
21+ .root_module = test_mod ,
1822 });
19- tests .kind = .@"test" ;
2023
2124 const run_tests = b .addRunArtifact (tests );
2225 b .step ("test" , "Run unit tests" ).dependOn (& run_tests .step );
@@ -25,8 +28,7 @@ pub fn build(b: *std.Build) void {
2528 const docs_step = b .step ("docs" , "Generate API documentation" );
2629 const doc_path = "docs/api" ;
2730
28- // Create docs directory if it doesn't exist
29- std .fs .cwd ().makePath ("docs" ) catch {};
31+ const io = b .graph .io ;
3032
3133 const gen_docs_cmd = b .addSystemCommand (&[_ ][]const u8 {
3234 b .graph .zig_exe ,
@@ -38,12 +40,13 @@ pub fn build(b: *std.Build) void {
3840 docs_step .dependOn (& gen_docs_cmd .step );
3941
4042 // Examples (only when developing minish itself, not when used as a dependency)
41- if (std . fs . cwd () .openDir ("examples" , .{ .iterate = true })) | examples_dir | {
43+ if (b . build_root . handle .openDir (io , "examples" , .{ .iterate = true })) | examples_dir | {
4244 var dir = examples_dir ;
45+ defer dir .close (io );
4346 const run_all_step = b .step ("run-all" , "Run all examples" );
4447
4548 var it = dir .iterate ();
46- while (it .next () catch null ) | entry | {
49+ while (it .next (io ) catch null ) | entry | {
4750 if (entry .kind != .file ) continue ;
4851 if (! std .mem .endsWith (u8 , entry .name , ".zig" )) continue ;
4952
0 commit comments