Skip to content

Commit 6bef84c

Browse files
authored
Commands/Utilities: remove GenerateLinuxMain (#6490)
This functionality has been deprecated almost three years ago in Swift 5.4 and should no longer be used. We had test discovery enabled on all platforms for long time, so this seems safe to remove.
1 parent af05a54 commit 6bef84c

File tree

4 files changed

+0
-340
lines changed

4 files changed

+0
-340
lines changed

Sources/Commands/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ add_library(Commands
4040
Utilities/DependenciesSerializer.swift
4141
Utilities/DescribedPackage.swift
4242
Utilities/DOTManifestSerializer.swift
43-
Utilities/GenerateLinuxMain.swift
4443
Utilities/MultiRootSupport.swift
4544
Utilities/PluginDelegate.swift
4645
Utilities/SymbolGraphExtract.swift

Sources/Commands/SwiftTestTool.swift

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ struct TestToolOptions: ParsableArguments {
7676
help: "Lists test methods in specifier format")
7777
var _deprecated_shouldListTests: Bool = false
7878

79-
/// Generate LinuxMain entries and exit.
80-
@Flag(name: .customLong("generate-linuxmain"), help: .hidden)
81-
var _deprecated_shouldGenerateLinuxMain: Bool = false
82-
8379
/// If the path of the exported code coverage JSON should be printed.
8480
@Flag(name: [.customLong("show-codecov-path"), .customLong("show-code-coverage-path"), .customLong("show-coverage-path")],
8581
help: "Print the path of the exported code coverage JSON file")
@@ -146,7 +142,6 @@ public struct SwiftTestTool: SwiftCommand {
146142
version: SwiftVersion.current.completeDisplayString,
147143
subcommands: [
148144
List.self,
149-
GenerateLinuxMain.self
150145
],
151146
helpNames: [.short, .long, .customLong("help", withSingleDash: true)])
152147

@@ -181,10 +176,6 @@ public struct SwiftTestTool: SwiftCommand {
181176
// backward compatibility 6/2022 for deprecation of flag into a subcommand
182177
let command = try List.parse()
183178
try command.run(swiftTool)
184-
} else if self.options._deprecated_shouldGenerateLinuxMain {
185-
// backward compatibility 6/2022 for deprecation of flag into a subcommand
186-
let command = try GenerateLinuxMain.parse()
187-
try command.run(swiftTool)
188179
} else if !self.options.shouldRunInParallel {
189180
let toolchain = try swiftTool.getDestinationToolchain()
190181
let testProducts = try buildTestsIfNeeded(swiftTool: swiftTool)
@@ -435,10 +426,6 @@ public struct SwiftTestTool: SwiftCommand {
435426
}
436427
}
437428

438-
if options._deprecated_shouldGenerateLinuxMain {
439-
observabilityScope.emit(warning: "'--generate-linuxmain' option is deprecated; tests are automatically discovered on all platforms")
440-
}
441-
442429
if options._deprecated_shouldListTests {
443430
observabilityScope.emit(warning: "'--list-tests' option is deprecated; use 'swift test list' instead")
444431
}
@@ -540,56 +527,6 @@ extension SwiftTestTool {
540527
}
541528
}
542529

543-
extension SwiftTestTool {
544-
// this functionality is deprecated as of 12/2020
545-
// but we are keeping it here for transition purposes
546-
// to be removed in future releases
547-
// deprecation warning is emitted by validateArguments
548-
struct GenerateLinuxMain: SwiftCommand {
549-
static let configuration = CommandConfiguration(
550-
commandName: "generate-linuxmain",
551-
abstract: "Generate LinuxMain.swift (deprecated)"
552-
)
553-
554-
@OptionGroup(visibility: .hidden)
555-
var globalOptions: GlobalOptions
556-
557-
// for deprecated passthrough from SwiftTestTool (parse will fail otherwise)
558-
@Flag(name: .customLong("generate-linuxmain"), help: .hidden)
559-
var _deprecated_passthrough: Bool = false
560-
561-
func run(_ swiftTool: SwiftTool) throws {
562-
#if os(Linux)
563-
swiftTool.observabilityScope.emit(warning: "can't discover tests on Linux; please use this option on macOS instead")
564-
#endif
565-
let graph = try swiftTool.loadPackageGraph()
566-
let testProducts = try buildTests(swiftTool: swiftTool)
567-
let testSuites = try TestingSupport.getTestSuites(
568-
in: testProducts,
569-
swiftTool: swiftTool,
570-
enableCodeCoverage: false,
571-
sanitizers: globalOptions.build.sanitizers
572-
)
573-
let allTestSuites = testSuites.values.flatMap { $0 }
574-
let generator = LinuxMainGenerator(graph: graph, testSuites: allTestSuites)
575-
try generator.generate()
576-
}
577-
578-
private func buildTests(swiftTool: SwiftTool) throws -> [BuiltTestProduct] {
579-
let buildParameters = try swiftTool.buildParametersForTest(enableCodeCoverage: false)
580-
let buildSystem = try swiftTool.createBuildSystem(customBuildParameters: buildParameters)
581-
582-
try buildSystem.build(subset: .allIncludingTests)
583-
584-
guard !buildSystem.builtTestProducts.isEmpty else {
585-
throw TestError.testsExecutableNotFound
586-
}
587-
588-
return buildSystem.builtTestProducts
589-
}
590-
}
591-
}
592-
593530
/// A structure representing an individual unit test.
594531
struct UnitTest {
595532
/// The path to the test product containing the test.

Sources/Commands/Utilities/GenerateLinuxMain.swift

Lines changed: 0 additions & 219 deletions
This file was deleted.

Tests/CommandsTests/TestToolTests.swift

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -209,63 +209,6 @@ final class TestToolTests: CommandsTestCase {
209209
#endif
210210
}
211211

212-
func testGenerateLinuxMainDeprecation() throws {
213-
try fixture(name: "Miscellaneous/TestDiscovery/Simple") { fixturePath in
214-
let (_, stderr) = try SwiftPMProduct.SwiftTest.execute(["--generate-linuxmain"], packagePath: fixturePath)
215-
// test deprecation warning
216-
XCTAssertMatch(stderr, .contains("warning: '--generate-linuxmain' option is deprecated"))
217-
}
218-
}
219-
220-
func testGenerateLinuxMain() throws {
221-
#if !os(macOS)
222-
try XCTSkipIf(true, "test is only supported on macOS")
223-
#endif
224-
try fixture(name: "Miscellaneous/TestDiscovery/Simple") { fixturePath in
225-
_ = try SwiftPMProduct.SwiftTest.execute(["--generate-linuxmain"], packagePath: fixturePath)
226-
227-
// Check LinuxMain
228-
let linuxMain = fixturePath.appending(components: "Tests", "LinuxMain.swift")
229-
XCTAssertEqual(try localFileSystem.readFileContents(linuxMain), """
230-
import XCTest
231-
232-
import SimpleTests
233-
234-
var tests = [XCTestCaseEntry]()
235-
tests += SimpleTests.__allTests()
236-
237-
XCTMain(tests)
238-
239-
""")
240-
241-
// Check test manifest
242-
let testManifest = fixturePath.appending(components: "Tests", "SimpleTests", "XCTestManifests.swift")
243-
XCTAssertEqual(try localFileSystem.readFileContents(testManifest), """
244-
#if !canImport(ObjectiveC)
245-
import XCTest
246-
247-
extension SimpleTests {
248-
// DO NOT MODIFY: This is autogenerated, use:
249-
// `swift test --generate-linuxmain`
250-
// to regenerate.
251-
static let __allTests__SimpleTests = [
252-
("test_Example2", test_Example2),
253-
("testExample1", testExample1),
254-
("testThrowing", testThrowing),
255-
]
256-
}
257-
258-
public func __allTests() -> [XCTestCaseEntry] {
259-
return [
260-
testCase(SimpleTests.__allTests__SimpleTests),
261-
]
262-
}
263-
#endif
264-
265-
""")
266-
}
267-
}
268-
269212
func testList() throws {
270213
try fixture(name: "Miscellaneous/TestDiscovery/Simple") { fixturePath in
271214
let (stdout, stderr) = try SwiftPMProduct.SwiftTest.execute(["list"], packagePath: fixturePath)

0 commit comments

Comments
 (0)