@@ -95,7 +95,7 @@ pub fn build(b: *Build) !void {
95
95
96
96
// Test suite:
97
97
98
- try addTestSuite (b , test_step , debug_testsuite_step , target , optimize , args_module , aviron_module );
98
+ try addTestSuite (b , test_step , debug_testsuite_step , target , avr_target , optimize , args_module , aviron_module );
99
99
100
100
try addTestSuiteUpdate (b , update_testsuite_step );
101
101
}
@@ -104,22 +104,23 @@ fn addTestSuite(
104
104
b : * Build ,
105
105
test_step : * Build.Step ,
106
106
debug_step : * Build.Step ,
107
- target : ResolvedTarget ,
107
+ host_target : ResolvedTarget ,
108
+ avr_target : ResolvedTarget ,
108
109
optimize : std.builtin.OptimizeMode ,
109
110
args_module : * Build.Module ,
110
111
aviron_module : * Build.Module ,
111
112
) ! void {
112
113
const unit_tests = b .addTest (.{
113
114
.root_source_file = b .path ("src/main.zig" ),
114
- .target = target ,
115
+ .target = host_target ,
115
116
.optimize = optimize ,
116
117
});
117
118
test_step .dependOn (& b .addRunArtifact (unit_tests ).step );
118
119
119
120
const testrunner_exe = b .addExecutable (.{
120
121
.name = "aviron-test-runner" ,
121
122
.root_source_file = b .path ("src/testrunner.zig" ),
122
- .target = target ,
123
+ .target = host_target ,
123
124
.optimize = optimize ,
124
125
});
125
126
testrunner_exe .root_module .addImport ("args" , args_module );
@@ -140,6 +141,11 @@ fn addTestSuite(
140
141
if (entry .kind != .file )
141
142
continue ;
142
143
144
+ if (std .mem .eql (u8 , entry .path , "dummy.zig" )) {
145
+ // This file is not interesting to test.
146
+ continue ;
147
+ }
148
+
143
149
const FileAction = union (enum ) {
144
150
compile ,
145
151
load ,
@@ -190,18 +196,33 @@ fn addTestSuite(
190
196
.cpu_features = cpu ,
191
197
}) catch @panic (cpu ))
192
198
else
193
- target ;
199
+ avr_target ;
200
+
201
+ const is_zig_test = std .mem .eql (u8 , std .fs .path .extension (entry .path ), ".zig" );
202
+
203
+ const source_file = b .path (b .fmt ("testsuite/{s}" , .{entry .path }));
204
+ const root_file = if (is_zig_test )
205
+ source_file
206
+ else
207
+ b .path ("testsuite/dummy.zig" );
194
208
195
209
const test_payload = b .addExecutable (.{
196
210
.name = std .fs .path .stem (entry .basename ),
197
211
.target = custom_target ,
198
212
.optimize = config .optimize ,
199
213
.strip = false ,
214
+ .root_source_file = root_file ,
215
+ .link_libc = false ,
200
216
});
201
- test_payload .addCSourceFile (.{
202
- .file = b .path (b .fmt ("testsuite/{s}" , .{entry .path })),
203
- .flags = &.{},
204
- });
217
+ test_payload .want_lto = false ; // AVR has no LTO support!
218
+ test_payload .verbose_link = true ;
219
+ test_payload .verbose_cc = true ;
220
+ if (! is_zig_test ) {
221
+ test_payload .addCSourceFile (.{
222
+ .file = source_file ,
223
+ .flags = &.{},
224
+ });
225
+ }
205
226
test_payload .bundle_compiler_rt = false ;
206
227
test_payload .addIncludePath (b .path ("testsuite" ));
207
228
test_payload .setLinkerScriptPath (b .path ("linker.ld" ));
0 commit comments