Skip to content

Commit ab9b035

Browse files
committed
[test] api-digester: add a test to ensure the dumped module content is expected.
1 parent c261748 commit ab9b035

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public struct S1 {
2+
public func foo1() {}
3+
public func foo2() {}
4+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"kind": "Root",
3+
"name": "TopLevel",
4+
"printedName": "TopLevel",
5+
"children": [
6+
{
7+
"kind": "TypeDecl",
8+
"name": "S1",
9+
"printedName": "S1",
10+
"declKind": "Struct",
11+
"usr": "s:V4cake2S1",
12+
"location": "",
13+
"moduleName": "cake",
14+
"children": [
15+
{
16+
"kind": "Function",
17+
"name": "foo1",
18+
"printedName": "foo1()",
19+
"declKind": "Func",
20+
"usr": "s:FV4cake2S14foo1FT_T_",
21+
"location": "",
22+
"moduleName": "cake",
23+
"children": [
24+
{
25+
"kind": "TypeNominal",
26+
"name": "Void",
27+
"printedName": "()"
28+
}
29+
]
30+
},
31+
{
32+
"kind": "Function",
33+
"name": "foo2",
34+
"printedName": "foo2()",
35+
"declKind": "Func",
36+
"usr": "s:FV4cake2S14foo2FT_T_",
37+
"location": "",
38+
"moduleName": "cake",
39+
"children": [
40+
{
41+
"kind": "TypeNominal",
42+
"name": "Void",
43+
"printedName": "()"
44+
}
45+
]
46+
},
47+
{
48+
"kind": "Constructor",
49+
"name": "init",
50+
"printedName": "init()",
51+
"declKind": "Constructor",
52+
"usr": "s:FV4cake2S1cFT_S0_",
53+
"location": "",
54+
"moduleName": "cake",
55+
"children": [
56+
{
57+
"kind": "TypeNominal",
58+
"name": "S1",
59+
"printedName": "S1"
60+
}
61+
]
62+
}
63+
]
64+
}
65+
]
66+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: rm -rf %t.mod && mkdir -p %t.mod
2+
// RUN: rm -rf %t.sdk && mkdir -p %t.sdk
3+
// RUN: rm -rf %t.module-cache && mkdir -p %t.module-cache
4+
// RUN: %swift -emit-module -o %t.mod/cake.swiftmodule %S/Inputs/cake.swift -parse-as-library
5+
// RUN: %api-digester -dump-sdk -module cake -o %t.dump.json -module-cache-path %t.module-cache -sdk %t.sdk -swift-version 3.0 -I %t.mod
6+
// RUN: diff -u %t.dump.json %S/Outputs/cake.json
7+
// RUN: %api-digester -diagnose-sdk --input-paths %t.dump.json -input-paths %S/Outputs/cake.json

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ ResourceDir("resource-dir",
9898
static llvm::cl::list<std::string>
9999
FrameworkPaths("F", llvm::cl::desc("add a directory to the framework search path"));
100100

101+
static llvm::cl::list<std::string>
102+
ModuleInputPaths("I", llvm::cl::desc("add a module for input"));
103+
101104
static llvm::cl::opt<bool>
102105
AbortOnModuleLoadFailure("abort-on-module-fail",
103106
llvm::cl::desc("Abort if a module failed to load"));
@@ -3303,6 +3306,7 @@ static int prepareForDump(const char *Main,
33033306
InitInvok.setRuntimeResourcePath(options::ResourceDir);
33043307
}
33053308
InitInvok.setFrameworkSearchPaths(options::FrameworkPaths);
3309+
InitInvok.setImportSearchPaths(options::ModuleInputPaths);
33063310

33073311
if (!options::ModuleList.empty()) {
33083312
if (readFileLineByLine(options::ModuleList, Modules))

0 commit comments

Comments
 (0)