[test] api-digester: add a test to ensure the dumped module content is expected.

This commit is contained in:
Xi Ge
2016-10-13 11:21:44 -07:00
parent c2617483b7
commit ab9b035dbc
4 changed files with 81 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
public struct S1 {
public func foo1() {}
public func foo2() {}
}

View File

@@ -0,0 +1,66 @@
{
"kind": "Root",
"name": "TopLevel",
"printedName": "TopLevel",
"children": [
{
"kind": "TypeDecl",
"name": "S1",
"printedName": "S1",
"declKind": "Struct",
"usr": "s:V4cake2S1",
"location": "",
"moduleName": "cake",
"children": [
{
"kind": "Function",
"name": "foo1",
"printedName": "foo1()",
"declKind": "Func",
"usr": "s:FV4cake2S14foo1FT_T_",
"location": "",
"moduleName": "cake",
"children": [
{
"kind": "TypeNominal",
"name": "Void",
"printedName": "()"
}
]
},
{
"kind": "Function",
"name": "foo2",
"printedName": "foo2()",
"declKind": "Func",
"usr": "s:FV4cake2S14foo2FT_T_",
"location": "",
"moduleName": "cake",
"children": [
{
"kind": "TypeNominal",
"name": "Void",
"printedName": "()"
}
]
},
{
"kind": "Constructor",
"name": "init",
"printedName": "init()",
"declKind": "Constructor",
"usr": "s:FV4cake2S1cFT_S0_",
"location": "",
"moduleName": "cake",
"children": [
{
"kind": "TypeNominal",
"name": "S1",
"printedName": "S1"
}
]
}
]
}
]
}

View File

@@ -0,0 +1,7 @@
// RUN: rm -rf %t.mod && mkdir -p %t.mod
// RUN: rm -rf %t.sdk && mkdir -p %t.sdk
// RUN: rm -rf %t.module-cache && mkdir -p %t.module-cache
// RUN: %swift -emit-module -o %t.mod/cake.swiftmodule %S/Inputs/cake.swift -parse-as-library
// 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
// RUN: diff -u %t.dump.json %S/Outputs/cake.json
// RUN: %api-digester -diagnose-sdk --input-paths %t.dump.json -input-paths %S/Outputs/cake.json

View File

@@ -98,6 +98,9 @@ ResourceDir("resource-dir",
static llvm::cl::list<std::string> static llvm::cl::list<std::string>
FrameworkPaths("F", llvm::cl::desc("add a directory to the framework search path")); FrameworkPaths("F", llvm::cl::desc("add a directory to the framework search path"));
static llvm::cl::list<std::string>
ModuleInputPaths("I", llvm::cl::desc("add a module for input"));
static llvm::cl::opt<bool> static llvm::cl::opt<bool>
AbortOnModuleLoadFailure("abort-on-module-fail", AbortOnModuleLoadFailure("abort-on-module-fail",
llvm::cl::desc("Abort if a module failed to load")); llvm::cl::desc("Abort if a module failed to load"));
@@ -3303,6 +3306,7 @@ static int prepareForDump(const char *Main,
InitInvok.setRuntimeResourcePath(options::ResourceDir); InitInvok.setRuntimeResourcePath(options::ResourceDir);
} }
InitInvok.setFrameworkSearchPaths(options::FrameworkPaths); InitInvok.setFrameworkSearchPaths(options::FrameworkPaths);
InitInvok.setImportSearchPaths(options::ModuleInputPaths);
if (!options::ModuleList.empty()) { if (!options::ModuleList.empty()) {
if (readFileLineByLine(options::ModuleList, Modules)) if (readFileLineByLine(options::ModuleList, Modules))