diff --git a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/Test.swift b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/Test.swift index 13a4f08128e..68a89a2896b 100644 --- a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/Test.swift +++ b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/Test.swift @@ -23,17 +23,6 @@ struct Test: ParsableCommand, BuildCommand { @OptionGroup var arguments: BuildArguments - @Flag(help: "Don't run lit-based tests") - var skipLitTests: Bool = false - - @Option( - help: """ - Path to the FileCheck executable that was built as part of the LLVM repository. - If not specified, it will be looked up from PATH. - """ - ) - var filecheckExec: String? - func run() throws { try buildExample(exampleName: "ExamplePlugin") @@ -44,74 +33,6 @@ struct Test: ParsableCommand, BuildCommand { private func runTests() throws { logSection("Running SwiftSyntax Tests") - - if !skipLitTests { - try runLitTests() - } - - try runXCTests() - } - - private func runLitTests() throws { - logSection("Running lit-based tests") - - guard FileManager.default.fileExists(atPath: Paths.litExec.path) else { - throw ScriptExectutionError( - message: """ - Error: Could not find lit.py. - Looking at '\(Paths.litExec.path)'. - - Make sure you have the llvm repo checked out next to the swift-syntax repo. - Refer to README.md for more information. - """ - ) - } - - let examplesBinPath = try findExamplesBinPath() - - var litCall = [ - Paths.litExec.path, - Paths.packageDir.appendingPathComponent("lit_tests").path, - ] - - if let filecheckExec { - litCall += ["--param", "FILECHECK=" + filecheckExec] - } - - litCall += ["--param", "EXAMPLES_BIN_PATH=" + examplesBinPath.path] - litCall += ["--param", "TOOLCHAIN=" + arguments.toolchain.path] - - // Print all failures - litCall += ["--verbose"] - // Don't show all commands if verbose is not enabled - if !arguments.verbose { - litCall += ["--succinct"] - } - - guard let pythonExec = Paths.python3Exec else { - throw ScriptExectutionError(message: "Didn't find python3 executable") - } - - let process = ProcessRunner( - executableURL: pythonExec, - arguments: litCall - ) - - let processOutput = try process.run(verbose: arguments.verbose) - - if !processOutput.stdout.isEmpty { - logSection("lit test stdout") - print(processOutput.stdout) - } - - if !processOutput.stderr.isEmpty { - logSection("lit test stderr") - print(processOutput.stderr) - } - } - - private func runXCTests() throws { - logSection("Running XCTests") var swiftpmCallArguments: [String] = [] if arguments.verbose { diff --git a/lit_tests/compiler_plugin_basic.swift b/lit_tests/compiler_plugin_basic.swift deleted file mode 100644 index f318e75ddbc..00000000000 --- a/lit_tests/compiler_plugin_basic.swift +++ /dev/null @@ -1,108 +0,0 @@ -// REQUIRES: platform=Darwin -// -// RUN: %empty-directory(%t) -// -// RUN: %swift-frontend -typecheck -verify -swift-version 5 \ -// RUN: -enable-experimental-feature CodeItemMacros \ -// RUN: -enable-experimental-feature ExtensionMacros \ -// RUN: -dump-macro-expansions \ -// RUN: -load-plugin-executable %examples_bin_path/ExamplePlugin#ExamplePlugin \ -// RUN: -parse-as-library \ -// RUN: -module-name TestApp \ -// RUN: %s 2>&1 | tee %t/expansions-dump.txt -// -// RUN: %FileCheck %s < %t/expansions-dump.txt - -@freestanding(expression) -macro echo(_: T) -> T = #externalMacro(module: "ExamplePlugin", type: "EchoExpressionMacro") - -@freestanding(declaration) -macro funcUnique() = #externalMacro(module: "ExamplePlugin", type: "FuncUniqueMacro") - -@freestanding(codeItem) -macro printAny(_: Any) = #externalMacro(module: "ExamplePlugin", type: "PrintAnyMacro") - -@attached(member, names: named(__metadata__)) -macro Metadata() = #externalMacro(module: "ExamplePlugin", type: "MetadataMacro") - -@attached(peer, names: suffixed(_peer)) -macro PeerWithSuffix() = #externalMacro(module: "ExamplePlugin", type: "PeerValueWithSuffixNameMacro") - -@attached(memberAttribute) -macro MemberDeprecated() = #externalMacro(module: "ExamplePlugin", type: "MemberDeprecatedMacro") - -@attached(extension, conformances: Equatable) -macro Equatable() = #externalMacro(module: "ExamplePlugin", type: "EquatableConformanceMacro") - -@attached(accessor) -macro DidSetPrint() = #externalMacro(module: "ExamplePlugin", type: "DidSetPrintMacro") - -@Metadata -@MemberDeprecated -@Equatable -@PeerWithSuffix -struct MyStruct { - @DidSetPrint - var value: Int = #echo(12) - // expected-error@-1 {{expansion of macro 'DidSetPrint()' did not produce a non-observing accessor}} - - func _test() { - #printAny("test") - } -} - -#funcUnique - -// CHECK: @__swiftmacro_7TestApp8MyStruct14PeerWithSuffixfMp_.swift -// CHECK-NEXT: ------------------------------ -// CHECK-NEXT: var MyStruct_peer: Int { -// CHECK-NEXT: 1 -// CHECK-NEXT: } -// CHECK-NEXT: ------------------------------ - -// CHECK: @__swiftmacro_7TestApp8MyStruct8MetadatafMm_.swift -// CHECK-NEXT: ------------------------------ -// CHECK-NEXT: static var __metadata__: [String: String] { -// CHECK-NEXT: ["name": "MyStruct"] -// CHECK-NEXT: } -// CHECK-NEXT: ------------------------------ - -// CHECK: @__swiftmacro_7TestApp8MyStructV5value16MemberDeprecatedfMr_.swift -// CHECK-NEXT: ------------------------------ -// CHECK-NEXT: @available(*, deprecated) -// CHECK-NEXT: ------------------------------ - -// CHECK: @__swiftmacro_7TestApp8MyStructV5_test16MemberDeprecatedfMr0_.swift -// CHECK-NEXT: ------------------------------ -// CHECK-NEXT: @available(*, deprecated) -// CHECK-NEXT: ------------------------------ - -// CHECK: @__swiftmacro_7TestApp8MyStruct9EquatablefMe_.swift -// CHECK-NEXT: ------------------------------ -// CHECK-NEXT: extension MyStruct: Equatable { -// CHECK-NEXT: } -// CHECK-NEXT: ------------------------------ - -// CHECK: @__swiftmacro_7TestApp8MyStructV5value11DidSetPrintfMa_.swift -// CHECK-NEXT: ------------------------------ -// CHECK-NEXT: { -// CHECK-NEXT: didSet { -// CHECK-NEXT: print(value) -// CHECK-NEXT: } -// CHECK-NEXT: } -// CHECK-NEXT: ------------------------------ - -// CHECK: @__swiftmacro_7TestApp8MyStructV4echofMf_.swift -// CHECK-NEXT: ------------------------------ -// CHECK-NEXT: /* echo */12 -// CHECK-NEXT: ------------------------------ - -// CHECK: @__swiftmacro_7TestApp33_B5E4CA48BE2C4AA1BE7F954C809E362ALl10funcUniquefMf_.swift -// CHECK-NEXT: ------------------------------ -// CHECK-NEXT: func $s7TestApp33_B5E4CA48BE2C4AA1BE7F954C809E362ALl10funcUniquefMf_6uniquefMu_() { -// CHECK-NEXT: } - -// CHECK: @__swiftmacro_7TestApp8MyStructV5_testyyF8printAnyfMf0_.swift -// CHECK-NEXT: ------------------------------ -// CHECK-NEXT: print("test") -// CHECK-NEXT: ------------------------------ diff --git a/lit_tests/lit.cfg b/lit_tests/lit.cfg deleted file mode 100644 index 81700f1c0ca..00000000000 --- a/lit_tests/lit.cfg +++ /dev/null @@ -1,81 +0,0 @@ -# ------- test/lit.cfg - Configuration for the 'lit' test runner -*- python -*- -# -# This source file is part of the Swift.org open source project -# -# Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors -# Licensed under Apache License v2.0 with Runtime Library Exception -# -# See https://swift.org/LICENSE.txt for license information -# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -# -# ----------------------------------------------------------------------------- - -import lit -import platform -import tempfile - - -def inferSwiftBinaryImpl(binaryName, envVarName): - # If the user set the variable in the environment, definitely use that. - execPath = os.getenv(envVarName) - if execPath: - return execPath - - # Otherwise, see if we were passed the path to the binary using a param. - execPath = lit_config.params.get(envVarName) - if execPath: - return execPath - - # Find in the toolchain. - execPath = lit_config.params.get('TOOLCHAIN') + '/bin/' + binaryName - if os.path.exists(execPath): - return execPath - - # Lastly, look in the path. - return lit.util.which(binaryName, config.environment["PATH"]) - - -# Discover the Swift binaries to use. -def inferSwiftBinary(binaryName): - envVarName = binaryName.upper().replace("-", "_") - execPath = inferSwiftBinaryImpl(binaryName, envVarName) - - if execPath: - if not lit_config.quiet: - lit_config.note("using %s: %s" % (binaryName, execPath)) - else: - msg = "couldn't find '%s' program, try setting %s in your environment" - lit_config.warning(msg % (binaryName, envVarName)) - - # Just substitute the plain executable name, so the run line remains - # reasonable. - execPath = binaryName - - return execPath - - -config.name = "SwiftSyntax" -config.suffixes = [".swift"] -config.test_format = lit.formats.ShTest(execute_external=True) -config.test_exec_root = tempfile.gettempdir() - -config.examples_bin_path = lit_config.params.get("EXAMPLES_BIN_PATH") -config.filecheck = inferSwiftBinary("FileCheck") -config.swift = inferSwiftBinary("swift") -config.swiftc = inferSwiftBinary("swiftc") -config.swift_frontend = inferSwiftBinary("swift-frontend") - -# Use features like this in lit: -# // REQUIRES: platform= -# where is Linux or Darwin -# Add a platform feature. -config.available_features.add("platform=" + platform.system()) - -config.substitutions.append(("%examples_bin_path", config.examples_bin_path)) -config.substitutions.append( - ("%empty-directory\(([^)]+)\)", 'rm -rf "\\1" && mkdir -p "\\1"') -) -config.substitutions.append(("%FileCheck", config.filecheck)) -config.substitutions.append(("%swiftc", config.swiftc)) -config.substitutions.append(("%swift", config.swift)) -config.substitutions.append(("%swift-frontend", config.swift_frontend))