@@ -196,6 +196,15 @@ pub fn build(b: *std.Build) void {
196196 ast_clean_tests .root_module .addImport ("ora" , lib_mod );
197197 const run_ast_clean_tests = b .addRunArtifact (ast_clean_tests );
198198
199+ // Add AST visitor tests
200+ const ast_visitor_tests = b .addTest (.{
201+ .root_source_file = b .path ("tests/ast_visitor_test.zig" ),
202+ .target = target ,
203+ .optimize = optimize ,
204+ });
205+ ast_visitor_tests .root_module .addImport ("ora" , lib_mod );
206+ const run_ast_visitor_tests = b .addRunArtifact (ast_visitor_tests );
207+
199208 // Legacy lexer test (keep for compatibility)
200209 const simple_lexer_test = b .addTest (.{
201210 .root_source_file = b .path ("tests/lexer_test.zig" ),
@@ -224,6 +233,7 @@ pub fn build(b: *std.Build) void {
224233 const test_ast_step = b .step ("test-ast" , "Run AST tests" );
225234 test_ast_step .dependOn (& run_ast_tests .step );
226235 test_ast_step .dependOn (& run_ast_clean_tests .step );
236+ test_ast_step .dependOn (& run_ast_visitor_tests .step );
227237
228238 // Create comprehensive test step that runs all tests
229239 const test_all_step = b .step ("test" , "Run all tests" );
@@ -643,7 +653,7 @@ fn runExampleTests(step: *std.Build.Step, options: std.Build.Step.MakeOptions) a
643653 std .log .info ("Testing all .ora example files..." , .{});
644654
645655 // Get examples directory
646- var examples_dir = std .fs .cwd ().openDir ("examples " , .{ .iterate = true }) catch | err | {
656+ var examples_dir = std .fs .cwd ().openDir ("ora-example " , .{ .iterate = true }) catch | err | {
647657 std .log .err ("Failed to open examples directory: {}" , .{err });
648658 return err ;
649659 };
@@ -667,7 +677,7 @@ fn runExampleTests(step: *std.Build.Step, options: std.Build.Step.MakeOptions) a
667677 if (entry .kind != .file ) continue ;
668678 if (! std .mem .endsWith (u8 , entry .basename , ".ora" )) continue ;
669679
670- const file_path = b .fmt ("examples /{s}" , .{entry .path });
680+ const file_path = b .fmt ("ora-example /{s}" , .{entry .path });
671681 std .log .info ("Testing: {s}" , .{file_path });
672682
673683 // Test each compilation phase
@@ -688,11 +698,27 @@ fn runExampleTests(step: *std.Build.Step, options: std.Build.Step.MakeOptions) a
688698 continue ;
689699 };
690700
691- if (result .term .Exited != 0 ) {
692- std .log .err ("FAILED: {s} (phase: {s})" , .{ file_path , phase });
693- std .log .err ("Error output: {s}" , .{result .stderr });
694- failed_count += 1 ;
695- break ; // Don't test further phases if one fails
701+ switch (result .term ) {
702+ .Exited = > | code | {
703+ if (code != 0 ) {
704+ std .log .err ("FAILED: {s} (phase: {s}) with exit code {}" , .{ file_path , phase , code });
705+ std .log .err ("Error output: {s}" , .{result .stderr });
706+ failed_count += 1 ;
707+ break ; // Don't test further phases if one fails
708+ }
709+ },
710+ .Signal = > | sig | {
711+ std .log .err ("FAILED: {s} (phase: {s}) terminated by signal {}" , .{ file_path , phase , sig });
712+ std .log .err ("Error output: {s}" , .{result .stderr });
713+ failed_count += 1 ;
714+ break ; // Don't test further phases if one fails
715+ },
716+ else = > {
717+ std .log .err ("FAILED: {s} (phase: {s}) with unexpected termination" , .{ file_path , phase });
718+ std .log .err ("Error output: {s}" , .{result .stderr });
719+ failed_count += 1 ;
720+ break ; // Don't test further phases if one fails
721+ },
696722 }
697723 }
698724
0 commit comments