Skip to content

Commit

Permalink
Moved fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
rofle100lvl committed Aug 18, 2024
1 parent 8e33fa6 commit 07c5bbd
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 28 deletions.
51 changes: 51 additions & 0 deletions Tests/FrontendTests/AcceptanceTestCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import XCTest
import Commands
import ArgumentParser
import Shared
import System


public enum Fixture: String {
case defaultiOSProject = "Tests/FrontendTests/DefaultiOSProject/DefaultiOSProject.xcodeproj"
}

public class AcceptanceTestCase: XCTestCase {
let packageRootPath = URL(fileURLWithPath: #file).pathComponents
.prefix(while: { $0 != "Tests" }).joined(separator: "/").dropFirst()

public override class func setUp() {
Configuration.shared.reset()
super.setUp()
}

public override class func tearDown() {
Configuration.shared.reset()
super.tearDown()
}

public func run(command: FrontendCommand.Type, arguments: String...) throws {
var command = try command
.parse(arguments)
try command.run()
}

public func setupFixture(fixture: Fixture) -> FilePath {
var file = FilePath(String(packageRootPath))
file.append(fixture.rawValue)
return file
}

public func XCTOutputDefaultOutputWithoutUnusedCode(scheme: String) {
XCTAssertTrue(LoggerStorage.collectedLogs.contains(
[
"* Inspecting project...",
"* Building \(scheme)...",
"* Indexing...",
"* Analyzing...",
"",
"* No unused code detected."
]
))
}

}
32 changes: 5 additions & 27 deletions Tests/FrontendTests/ScanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,20 @@ import ArgumentParser
import Commands
import Shared

final class ScanTests: XCTestCase {
fileprivate let packageRootPath = URL(fileURLWithPath: #file).pathComponents
.prefix(while: { $0 != "Tests" }).joined(separator: "/").dropFirst()

final class ScanTests: AcceptanceTestCase {
func testScanWorkspaceWithPath() async throws {
var file = FilePath(String(packageRootPath))

file.append(FilePath.Component("fixtures"))
file.append(FilePath.Component("DefaultiOSProject"))
file.append(FilePath.Component("DefaultiOSProject.xcodeproj"))
let project = setupFixture(fixture: .defaultiOSProject)

let command = try ScanCommand.parse(
[
"--project", "\(file.string)",
"--schemes", "DefaultiOSProject"
]
)
do {
try command.run()
try run(command: ScanCommand.self, arguments: "--project", "\(project)",
"--schemes", "DefaultiOSProject")
} catch PeripheryError.xcodeProjectsAreUnsupported {
#if os(Linux)
return
#endif
}

XCTAssertTrue(LoggerStorage.collectedLogs.contains(
[
"* Inspecting project...",
"* Building DefaultiOSProject...",
"* Indexing...",
"* Analyzing...",
"",
"* No unused code detected."
]
)
)
XCTOutputDefaultOutputWithoutUnusedCode(scheme: "DefaultiOSProject")
}
}

1 change: 0 additions & 1 deletion Tests/PeripheryTests/Extensions/FilePathGlobTest.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Shared
import SystemPackage
import XCTest

Expand Down

0 comments on commit 07c5bbd

Please sign in to comment.