Skip to content

Commit 11f24ca

Browse files
authored
Merge pull request swiftlang#59256 from artemcm/FrontendParseableUnknownExtensions
[Parseable Output] Generate valid output for files of unknown types
2 parents 7cf67e7 + 19c5c20 commit 11f24ca

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

lib/Basic/ParseableOutput.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ template <> struct ScalarEnumerationTraits<file_types::ID> {
4242
std::string typeName = file_types::getTypeName(ty).str();
4343
out.enumCase(value, typeName.c_str(), ty);
4444
});
45+
out.enumCase(value, "unknown", file_types::ID::TY_INVALID);
4546
}
4647
};
4748

lib/FrontendTool/FrontendTool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ static swift::file_types::ID computeFileTypeForPath(const StringRef Path) {
602602
// then iterate over all preceeding possible extension variants.
603603
while (llvm::sys::path::has_extension(PathStem)) {
604604
auto NextExtension = llvm::sys::path::extension(PathStem);
605+
PathStem = llvm::sys::path::stem(PathStem);
605606
Extension = NextExtension.str() + Extension;
606607
FileType = file_types::lookupTypeForExtension(Extension);
607608
if (FileType != swift::file_types::ID::TY_INVALID)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// RUN: %target-swift-frontend -primary-file %s %S/Inputs/filelist-other.swift -o %t.out -module-name parseable_output -empty-abi-descriptor -emit-abi-descriptor-path %t.abi.weird_file_extension -emit-module -emit-module-path %t.swiftmodule -frontend-parseable-output 2>&1 | %FileCheck %s
2+
3+
// CHECK: {{[1-9][0-9]*}}
4+
// CHECK-NEXT: {
5+
// CHECK-NEXT: "kind": "began",
6+
// CHECK-NEXT: "name": "compile",
7+
// CHECK: "inputs": [
8+
// CHECK-NEXT: "{{.*[\\/]}}parseable_output_unknown_file_type.swift"
9+
// CHECK: "outputs": [
10+
// CHECK-NEXT: {
11+
// CHECK-NEXT: "type": "image",
12+
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output_unknown_file_type.swift.tmp.out"
13+
// CHECK-NEXT: },
14+
// CHECK-NEXT: {
15+
// CHECK-NEXT: "type": "swiftmodule",
16+
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output_unknown_file_type.swift.tmp.swiftmodule"
17+
// CHECK-NEXT: },
18+
// CHECK-NEXT: {
19+
// CHECK-NEXT: "type": "unknown",
20+
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output_unknown_file_type.swift.tmp.abi.weird_file_extension"
21+
// CHECK-NEXT: }
22+
// CHECK-NEXT: ],
23+
// CHECK-NEXT: "pid": [[PID:[0-9]*]]
24+
// CHECK-NEXT: "process": {
25+
// CHECK-NEXT: "real_pid": [[PID]]
26+
// CHECK-NEXT: }
27+
// CHECK-NEXT: }
28+
29+
// CHECK-NEXT: {{[1-9][0-9]*}}
30+
// CHECK-NEXT: {
31+
// CHECK-NEXT: "kind": "finished",
32+
// CHECK-NEXT: "name": "compile",
33+
// CHECK-NEXT: "pid": [[PID]],
34+
// CHECK-NEXT: "process": {
35+
// CHECK-NEXT: "real_pid": [[PID]]
36+
// CHECK-NEXT: },
37+
// CHECK-NEXT: "exit-status": 0
38+
// CHECK-NEXT: }

0 commit comments

Comments
 (0)