@@ -400,7 +400,7 @@ fn addFromDirInner(
400
400
for (targets ) | target_query | {
401
401
const output = try manifest .trailingLinesSplit (ctx .arena );
402
402
try ctx .translate .append (.{
403
- .name = std . fs . path . stem ( filename ),
403
+ .name = try caseNameFromPath ( ctx . arena , filename ),
404
404
.c_frontend = c_frontend ,
405
405
.target = b .resolveTargetQuery (target_query ),
406
406
.link_libc = link_libc ,
@@ -416,7 +416,7 @@ fn addFromDirInner(
416
416
for (targets ) | target_query | {
417
417
const output = try manifest .trailingSplit (ctx .arena );
418
418
try ctx .translate .append (.{
419
- .name = std . fs . path . stem ( filename ),
419
+ .name = try caseNameFromPath ( ctx . arena , filename ),
420
420
.c_frontend = c_frontend ,
421
421
.target = b .resolveTargetQuery (target_query ),
422
422
.link_libc = link_libc ,
@@ -454,7 +454,7 @@ fn addFromDirInner(
454
454
455
455
const next = ctx .cases .items .len ;
456
456
try ctx .cases .append (.{
457
- .name = std . fs . path . stem ( filename ),
457
+ .name = try caseNameFromPath ( ctx . arena , filename ),
458
458
.import_path = std .fs .path .dirname (filename ),
459
459
.backend = backend ,
460
460
.files = .init (ctx .arena ),
@@ -1138,3 +1138,17 @@ fn knownFileExtension(filename: []const u8) bool {
1138
1138
if (it .next () != null ) return false ;
1139
1139
return false ;
1140
1140
}
1141
+
1142
+ /// `path` is a path relative to the root case directory.
1143
+ /// e.g. `compile_errors/undeclared_identifier.zig`
1144
+ /// The case name is computed by removing the extension and substituting path separators for dots.
1145
+ /// e.g. `compile_errors.undeclared_identifier`
1146
+ /// Including the directory components makes `-Dtest-filter` more useful, because you can filter
1147
+ /// based on subdirectory; e.g. `-Dtest-filter=compile_errors` to run the compile error tets.
1148
+ fn caseNameFromPath (arena : Allocator , path : []const u8 ) Allocator.Error ! []const u8 {
1149
+ const ext_len = std .fs .path .extension (path ).len ;
1150
+ const path_sans_ext = path [0 .. path .len - ext_len ];
1151
+ const result = try arena .dupe (u8 , path_sans_ext );
1152
+ std .mem .replaceScalar (u8 , result , std .fs .path .sep , '.' );
1153
+ return result ;
1154
+ }
0 commit comments