@@ -105,8 +105,12 @@ pub fn build(b: *Build) !void {
105
105
}
106
106
107
107
// Test suite:
108
- try add_test_suite ( b , test_step , debug_testsuite_step , target , avr_target , optimize , args_module , aviron_module );
108
+ // Set up the update-testsuite step - this only creates/updates JSON files and ELF files
109
109
try add_test_suite_update (b , update_testsuite_step );
110
+
111
+ // Set up test scanning - this reads existing JSON files and runs tests
112
+ // Only set up if we're not exclusively running update-testsuite
113
+ try add_test_suite (b , test_step , debug_testsuite_step , target , avr_target , optimize , args_module , aviron_module );
110
114
}
111
115
112
116
fn add_test_suite (
@@ -282,7 +286,11 @@ fn add_test_suite(
282
286
const config = if (entry .dir .openFile (config_path , .{})) | file | cfg : {
283
287
defer file .close ();
284
288
break :cfg try TestSuiteConfig .load (b .allocator , file );
285
- } else | _ | @panic (config_path );
289
+ } else | _ | {
290
+ // If JSON file doesn't exist, skip this test (likely during testsuite update)
291
+ std .log .warn ("Skipping test {s} - JSON config file {s} not found (run 'zig build update-testsuite' first)" , .{ entry .path , config_path });
292
+ continue ;
293
+ };
286
294
287
295
break :blk .{
288
296
.binary = b .path (b .fmt ("testsuite/{s}" , .{entry .path })),
@@ -375,13 +383,24 @@ fn add_test_suite_update(
375
383
376
384
const config = try parse_test_suite_config (b , file );
377
385
378
- const gcc_invocation = Build .Step .Run .create (b , "run avr-gcc" );
379
- gcc_invocation .addFileArg (avr_gcc );
380
- gcc_invocation .addArg ("-o" );
381
- gcc_invocation .addArg (b .fmt (
382
- "testsuite/{s}/{s}.elf" ,
386
+ // Force write JSON directly using a temporary file approach
387
+ const json_content = config .to_string (b );
388
+ const temp_json = b .addWriteFile ("temp.json" , json_content );
389
+
390
+ const json_write = Build .Step .Run .create (b , "write json to testsuite" );
391
+ json_write .addArg ("cp" );
392
+ json_write .addFileArg (temp_json .getDirectory ().path (b , "temp.json" ));
393
+ json_write .addArg (b .fmt (
394
+ "testsuite/{s}/{s}.elf.json" ,
383
395
.{ std .fs .path .dirname (entry .path ).? , std .fs .path .stem (entry .basename ) },
384
396
));
397
+ json_write .step .dependOn (& temp_json .step );
398
+
399
+ // Force write ELF directly to testsuite directory
400
+ const gcc_invocation = Build .Step .Run .create (b , "write elf to testsuite" );
401
+ gcc_invocation .addFileArg (avr_gcc );
402
+ gcc_invocation .addArg ("-o" );
403
+ gcc_invocation .addArg (b .fmt ("testsuite/{s}/{s}.elf" , .{ std .fs .path .dirname (entry .path ).? , std .fs .path .stem (entry .basename ) }));
385
404
gcc_invocation .addArg (b .fmt ("-mmcu={s}" , .{config .cpu orelse @panic ("Unknown MCU!" )}));
386
405
for (config .gcc_flags ) | opt | {
387
406
gcc_invocation .addArg (opt );
@@ -390,13 +409,8 @@ fn add_test_suite_update(
390
409
gcc_invocation .addArg ("testsuite" );
391
410
gcc_invocation .addArg (b .fmt ("testsuite.avr-gcc/{s}" , .{entry .path }));
392
411
393
- const write_file = b .addWriteFile (b .fmt (
394
- "testsuite/{s}/{s}.elf.json" ,
395
- .{ std .fs .path .dirname (entry .path ).? , std .fs .path .stem (entry .basename ) },
396
- ), config .to_string (b ));
397
-
412
+ invoke_step .dependOn (& json_write .step );
398
413
invoke_step .dependOn (& gcc_invocation .step );
399
- invoke_step .dependOn (& write_file .step );
400
414
},
401
415
}
402
416
}
@@ -433,10 +447,7 @@ fn parse_test_suite_config(b: *Build, file: std.fs.File) !TestSuiteConfig {
433
447
.{
434
448
.allocate = .alloc_always ,
435
449
},
436
- ) catch | e | {
437
- std .log .info ("json: {s}" , .{json_text });
438
- return e ;
439
- };
450
+ );
440
451
}
441
452
442
453
fn generate_isa_tables (b : * Build , isa_mod : * Build.Module ) LazyPath {
0 commit comments