Skip to content

Commit a5a032d

Browse files
committed
Moved fixtures
1 parent 8e33fa6 commit a5a032d

File tree

62 files changed

+63
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+63
-36
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import XCTest
2+
import Commands
3+
import ArgumentParser
4+
import Shared
5+
import System
6+
7+
public enum Fixture: String {
8+
case defaultiOSProject = "DefaultiOSProject/DefaultiOSProject.xcodeproj"
9+
}
10+
11+
public class AcceptanceTestCase: XCTestCase {
12+
let packageRootPath = URL(fileURLWithPath: #file).pathComponents
13+
.prefix(while: { $0 != "Tests" }).joined(separator: "/").dropFirst()
14+
15+
public override class func setUp() {
16+
Configuration.shared.reset()
17+
super.setUp()
18+
}
19+
20+
public override class func tearDown() {
21+
Configuration.shared.reset()
22+
super.tearDown()
23+
}
24+
25+
public func run(command: FrontendCommand.Type, arguments: String...) throws {
26+
var command = try command
27+
.parse(arguments)
28+
try command.run()
29+
}
30+
31+
public func setupFixture(fixture: Fixture) -> FilePath {
32+
var file = FilePath(String(packageRootPath))
33+
file.append(FilePath.Component("fixtures"))
34+
file.append(fixture.rawValue)
35+
return file
36+
}
37+
38+
public func XCTOutputDefaultOutputWithoutUnusedCode(scheme: String) {
39+
XCTAssertTrue(LoggerStorage.collectedLogs.contains(
40+
[
41+
"* Inspecting project...",
42+
"* Building \(scheme)...",
43+
"* Indexing...",
44+
"* Analyzing...",
45+
"",
46+
"* No unused code detected."
47+
]
48+
))
49+
}
50+
51+
}

Tests/FrontendTests/ScanTests.swift

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,20 @@ import ArgumentParser
44
import Commands
55
import Shared
66

7-
final class ScanTests: XCTestCase {
8-
fileprivate let packageRootPath = URL(fileURLWithPath: #file).pathComponents
9-
.prefix(while: { $0 != "Tests" }).joined(separator: "/").dropFirst()
10-
7+
final class ScanTests: AcceptanceTestCase {
118
func testScanWorkspaceWithPath() async throws {
12-
var file = FilePath(String(packageRootPath))
13-
14-
file.append(FilePath.Component("fixtures"))
15-
file.append(FilePath.Component("DefaultiOSProject"))
16-
file.append(FilePath.Component("DefaultiOSProject.xcodeproj"))
9+
let project = setupFixture(fixture: .defaultiOSProject)
1710

18-
let command = try ScanCommand.parse(
19-
[
20-
"--project", "\(file.string)",
21-
"--schemes", "DefaultiOSProject"
22-
]
23-
)
2411
do {
25-
try command.run()
12+
try run(command: ScanCommand.self, arguments: "--project", "\(project)",
13+
"--schemes", "DefaultiOSProject")
2614
} catch PeripheryError.xcodeProjectsAreUnsupported {
2715
#if os(Linux)
2816
return
2917
#endif
3018
}
3119

32-
XCTAssertTrue(LoggerStorage.collectedLogs.contains(
33-
[
34-
"* Inspecting project...",
35-
"* Building DefaultiOSProject...",
36-
"* Indexing...",
37-
"* Analyzing...",
38-
"",
39-
"* No unused code detected."
40-
]
41-
)
42-
)
20+
XCTOutputDefaultOutputWithoutUnusedCode(scheme: "DefaultiOSProject")
4321
}
4422
}
4523

Tests/Shared/Helper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ var ProjectRootPath: FilePath {
66
}
77

88
var FixturesProjectPath: FilePath {
9-
ProjectRootPath.appending("Tests/Fixtures")
9+
ProjectRootPath.appending("fixtures")
1010
}

Tests/XcodeTests/Helper.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import SystemPackage
33
@testable import TestShared
44

55
var UIKitProjectPath: FilePath {
6-
ProjectRootPath.appending("Tests/XcodeTests/UIKitProject/UIKitProject.xcodeproj")
6+
ProjectRootPath.appending("fixtures/UIKitProject/UIKitProject.xcodeproj")
77
}
88

99
var SwiftUIProjectPath: FilePath {
10-
ProjectRootPath.appending("Tests/XcodeTests/SwiftUIProject/SwiftUIProject.xcodeproj")
10+
ProjectRootPath.appending("fixtures/SwiftUIProject/SwiftUIProject.xcodeproj")
1111
}

Tests/XcodeTests/XcodeSourceGraphTestCase.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import XcodeSupport
66

77
class XcodeSourceGraphTestCase: SourceGraphTestCase {
88
static func build(projectPath: FilePath) {
9-
projectPath.chdir {
10-
let driver = try! XcodeProjectDriver.build(projectPath: projectPath)
11-
try! driver.build()
12-
plan = try! driver.plan(logger: Logger().contextualized(with: "index"))
13-
}
9+
let driver = try! XcodeProjectDriver.build(projectPath: projectPath)
10+
try! driver.build()
11+
plan = try! driver.plan(logger: Logger().contextualized(with: "index"))
1412
}
1513
}

Tests/XcodeTests/XcodeTargetTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ final class XcodeTargetTest: XCTestCase {
1010
try target.identifyFiles()
1111

1212
XCTAssertTrue(target.files(kind: .interfaceBuilder).contains {
13-
$0.relativeTo(ProjectRootPath).string == "Tests/XcodeTests/UIKitProject/UIKitProject/FileInGroupWithoutFolder.xib"
13+
$0.relativeTo(ProjectRootPath).string == "fixtures/UIKitProject/UIKitProject/FileInGroupWithoutFolder.xib"
1414
})
1515
}
1616

0 commit comments

Comments
 (0)