Skip to content

Commit c543d1a

Browse files
authored
Merge pull request #2809 from abertelrud/eng/65200866-xcodeproj-generation-tests-are-hanging
Some of the GenerateXcodeprojTests are hanging on pull request testing
2 parents b3c0adb + 409f52f commit c543d1a

File tree

1 file changed

+70
-58
lines changed

1 file changed

+70
-58
lines changed

Tests/XcodeprojTests/GenerateXcodeprojTests.swift

Lines changed: 70 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
4+
Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -29,15 +29,18 @@ class GenerateXcodeprojTests: XCTestCase {
2929
func testXcodebuildCanParseIt() {
3030
#if os(macOS)
3131
mktmpdir { dstdir in
32-
let fileSystem = InMemoryFileSystem(emptyFiles: "/Sources/DummyModuleName/source.swift")
32+
let packagePath = dstdir.appending(component: "foo")
33+
let modulePath = packagePath.appending(components: "Sources", "DummyModuleName")
34+
try makeDirectories(modulePath)
35+
try localFileSystem.writeFileContents(modulePath.appending(component: "source.swift"), bytes: "")
3336

3437
let diagnostics = DiagnosticsEngine()
35-
let graph = loadPackageGraph(fs: fileSystem, diagnostics: diagnostics,
38+
let graph = loadPackageGraph(fs: localFileSystem, diagnostics: diagnostics,
3639
manifests: [
3740
Manifest.createV4Manifest(
3841
name: "Foo",
39-
path: "/",
40-
url: "/foo",
42+
path: packagePath.pathString,
43+
url: packagePath.pathString,
4144
packageKind: .root,
4245
targets: [
4346
TargetDescription(name: "DummyModuleName"),
@@ -77,63 +80,72 @@ class GenerateXcodeprojTests: XCTestCase {
7780
}
7881

7982
func testXcconfigOverrideValidatesPath() throws {
80-
let fileSystem = InMemoryFileSystem(emptyFiles: "/Bar/Sources/Bar/bar.swift")
81-
let diagnostics = DiagnosticsEngine()
82-
let graph = loadPackageGraph(fs: fileSystem, diagnostics: diagnostics,
83-
manifests: [
84-
Manifest.createV4Manifest(
85-
name: "Bar",
86-
path: "/Bar",
87-
url: "/Bar",
88-
packageKind: .root,
89-
targets: [
90-
TargetDescription(name: "Bar"),
91-
])
92-
]
93-
)
94-
XCTAssertNoDiagnostics(diagnostics)
95-
96-
let options = XcodeprojOptions(xcconfigOverrides: AbsolutePath("/doesntexist"))
97-
do {
98-
_ = try xcodeProject(xcodeprojPath: AbsolutePath.root.appending(component: "xcodeproj"),
99-
graph: graph, extraDirs: [], extraFiles: [], options: options, fileSystem: fileSystem, diagnostics: diagnostics)
100-
XCTFail("Project generation should have failed")
101-
} catch ProjectGenerationError.xcconfigOverrideNotFound(let path) {
102-
XCTAssertEqual(options.xcconfigOverrides, path)
103-
} catch {
104-
XCTFail("Project generation shouldn't have had another error")
83+
mktmpdir { dstdir in
84+
let packagePath = dstdir.appending(component: "Bar")
85+
let modulePath = packagePath.appending(components: "Sources", "Bar")
86+
try makeDirectories(modulePath)
87+
try localFileSystem.writeFileContents(modulePath.appending(component: "bar.swift"), bytes: "")
88+
89+
let diagnostics = DiagnosticsEngine()
90+
let graph = loadPackageGraph(fs: localFileSystem, diagnostics: diagnostics,
91+
manifests: [
92+
Manifest.createV4Manifest(
93+
name: "Bar",
94+
path: packagePath.pathString,
95+
url: packagePath.pathString,
96+
packageKind: .root,
97+
targets: [
98+
TargetDescription(name: "Bar"),
99+
])
100+
]
101+
)
102+
XCTAssertNoDiagnostics(diagnostics)
103+
104+
let options = XcodeprojOptions(xcconfigOverrides: AbsolutePath("/doesntexist"))
105+
do {
106+
_ = try xcodeProject(xcodeprojPath: AbsolutePath.root.appending(component: "xcodeproj"),
107+
graph: graph, extraDirs: [], extraFiles: [], options: options, fileSystem: localFileSystem, diagnostics: diagnostics)
108+
XCTFail("Project generation should have failed")
109+
} catch ProjectGenerationError.xcconfigOverrideNotFound(let path) {
110+
XCTAssertEqual(options.xcconfigOverrides, path)
111+
} catch {
112+
XCTFail("Project generation shouldn't have had another error")
113+
}
105114
}
106115
}
107116

108117
func testGenerateXcodeprojWithInvalidModuleNames() throws {
109-
let warningStream = BufferedOutputByteStream()
110-
let fileSystem = InMemoryFileSystem(
111-
emptyFiles: "/Bar/Sources/Modules/example.swift"
112-
)
113-
114-
let diagnostics = DiagnosticsEngine()
115-
let graph = loadPackageGraph(fs: fileSystem, diagnostics: diagnostics,
116-
manifests: [
117-
Manifest.createV4Manifest(
118-
name: "Modules",
119-
path: "/Bar",
120-
url: "/Bar",
121-
packageKind: .root,
122-
targets: [
123-
TargetDescription(name: "Modules"),
124-
])
125-
]
126-
)
127-
XCTAssertNoDiagnostics(diagnostics)
128-
129-
_ = try xcodeProject(
130-
xcodeprojPath: AbsolutePath.root.appending(component: "xcodeproj"),
131-
graph: graph, extraDirs: [], extraFiles: [],
132-
options: XcodeprojOptions(), fileSystem: fileSystem,
133-
diagnostics: diagnostics, warningStream: warningStream)
134-
135-
let warnings = warningStream.bytes.description
136-
XCTAssertMatch(warnings, .contains("warning: Target 'Modules' conflicts with required framework filenames, rename this target to avoid conflicts."))
118+
mktmpdir { dstdir in
119+
let packagePath = dstdir.appending(component: "Bar")
120+
let modulePath = packagePath.appending(components: "Sources", "Modules")
121+
try makeDirectories(modulePath)
122+
try localFileSystem.writeFileContents(modulePath.appending(component: "example.swift"), bytes: "")
123+
124+
let diagnostics = DiagnosticsEngine()
125+
let graph = loadPackageGraph(fs: localFileSystem, diagnostics: diagnostics,
126+
manifests: [
127+
Manifest.createV4Manifest(
128+
name: "Modules",
129+
path: packagePath.pathString,
130+
url: packagePath.pathString,
131+
packageKind: .root,
132+
targets: [
133+
TargetDescription(name: "Modules"),
134+
])
135+
]
136+
)
137+
XCTAssertNoDiagnostics(diagnostics)
138+
139+
let warningStream = BufferedOutputByteStream()
140+
_ = try xcodeProject(
141+
xcodeprojPath: AbsolutePath.root.appending(component: "xcodeproj"),
142+
graph: graph, extraDirs: [], extraFiles: [],
143+
options: XcodeprojOptions(), fileSystem: localFileSystem,
144+
diagnostics: diagnostics, warningStream: warningStream)
145+
146+
let warnings = warningStream.bytes.description
147+
XCTAssertMatch(warnings, .contains("warning: Target 'Modules' conflicts with required framework filenames, rename this target to avoid conflicts."))
148+
}
137149
}
138150

139151
func testGenerateXcodeprojWithoutGitRepo() {

0 commit comments

Comments
 (0)