Skip to content

Commit 013a9fd

Browse files
authored
Merge pull request swiftlang#2240 from ahoppen/ahoppen/skip-long-tests-environment-var
Add a global variable to check if long tests should be skipped
2 parents 8c2ac6a + 42cbd17 commit 013a9fd

File tree

7 files changed

+34
-13
lines changed

7 files changed

+34
-13
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ let package = Package(
309309

310310
.testTarget(
311311
name: "PerformanceTest",
312-
dependencies: ["_InstructionCounter", "SwiftIDEUtils", "SwiftParser", "SwiftSyntax"],
312+
dependencies: ["_InstructionCounter", "_SwiftSyntaxTestSupport", "SwiftIDEUtils", "SwiftParser", "SwiftSyntax"],
313313
exclude: ["Inputs"]
314314
),
315315
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import Foundation
14+
15+
public var longTestsDisabled: Bool {
16+
if let value = ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] {
17+
return value == "1" || value == "YES"
18+
}
19+
return false
20+
}

Tests/PerformanceTest/ParsingPerformanceTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import SwiftParser
1414
import SwiftSyntax
1515
import XCTest
16+
import _SwiftSyntaxTestSupport
1617

1718
public class ParsingPerformanceTests: XCTestCase {
1819

@@ -24,7 +25,7 @@ public class ParsingPerformanceTests: XCTestCase {
2425
}
2526

2627
func testNativeParsingPerformance() throws {
27-
try XCTSkipIf(ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] == "1")
28+
try XCTSkipIf(longTestsDisabled)
2829

2930
let source = try String(contentsOf: inputFile)
3031

Tests/PerformanceTest/SyntaxClassifierPerformanceTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import SwiftIDEUtils
1414
import SwiftParser
1515
import SwiftSyntax
1616
import XCTest
17+
import _SwiftSyntaxTestSupport
1718

1819
public class SyntaxClassifierPerformanceTests: XCTestCase {
1920

@@ -25,7 +26,7 @@ public class SyntaxClassifierPerformanceTests: XCTestCase {
2526
}
2627

2728
func testClassifierPerformance() throws {
28-
try XCTSkipIf(ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] == "1")
29+
try XCTSkipIf(longTestsDisabled)
2930

3031
let source = try String(contentsOf: inputFile)
3132
let parsed = Parser.parse(source: source)

Tests/PerformanceTest/VisitorPerformanceTests.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import SwiftParser
1414
import SwiftSyntax
1515
import XCTest
16+
import _SwiftSyntaxTestSupport
1617

1718
public class VisitorPerformanceTests: XCTestCase {
1819

@@ -24,7 +25,7 @@ public class VisitorPerformanceTests: XCTestCase {
2425
}
2526

2627
func testEmptyVisitorPerformance() throws {
27-
try XCTSkipIf(ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] == "1")
28+
try XCTSkipIf(longTestsDisabled)
2829
class EmptyVisitor: SyntaxVisitor {}
2930

3031
let source = try String(contentsOf: inputFile)
@@ -37,7 +38,7 @@ public class VisitorPerformanceTests: XCTestCase {
3738
}
3839

3940
func testEmptyRewriterPerformance() throws {
40-
try XCTSkipIf(ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] == "1")
41+
try XCTSkipIf(longTestsDisabled)
4142
class EmptyRewriter: SyntaxRewriter {}
4243

4344
let source = try String(contentsOf: inputFile)
@@ -50,7 +51,7 @@ public class VisitorPerformanceTests: XCTestCase {
5051
}
5152

5253
func testEmptyAnyVisitorPerformance() throws {
53-
try XCTSkipIf(ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] == "1")
54+
try XCTSkipIf(longTestsDisabled)
5455
class EmptyAnyVisitor: SyntaxAnyVisitor {}
5556

5657
let source = try String(contentsOf: inputFile)

Tests/SwiftParserTest/Assertions.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,11 +599,9 @@ extension ParserTestCase {
599599
var (markerLocations, source) = extractMarkers(markedSource)
600600
markerLocations["START"] = 0
601601

602-
let enableLongTests = ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] != "1"
603-
604602
var parser = Parser(source, experimentalFeatures: experimentalFeatures)
605603
#if SWIFTPARSER_ENABLE_ALTERNATE_TOKEN_INTROSPECTION
606-
if enableLongTests {
604+
if !longTestsDisabled {
607605
parser.enableAlternativeTokenChoices()
608606
}
609607
#endif
@@ -684,7 +682,7 @@ extension ParserTestCase {
684682
assertBasicFormat(source: source, parse: parse, experimentalFeatures: experimentalFeatures, file: file, line: line)
685683
}
686684

687-
if enableLongTests {
685+
if !longTestsDisabled {
688686
DispatchQueue.concurrentPerform(iterations: Array(tree.tokens(viewMode: .all)).count) { tokenIndex in
689687
let flippedTokenTree = TokenPresenceFlipper(flipTokenAtIndex: tokenIndex).rewrite(Syntax(tree))
690688
_ = ParseDiagnosticsGenerator.diagnostics(for: flippedTokenTree)

Tests/SwiftParserTest/ParserTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public class ParserTests: ParserTestCase {
9393
func testSelfParse() throws {
9494
// Allow skipping the self parse test in local development environments
9595
// because it takes very long compared to all the other tests.
96-
try XCTSkipIf(ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] == "1")
96+
try XCTSkipIf(longTestsDisabled)
9797
let currentDir =
9898
packageDir
9999
.appendingPathComponent("Sources")
@@ -108,7 +108,7 @@ public class ParserTests: ParserTestCase {
108108
/// This requires the Swift compiler to have been checked out into the "swift"
109109
/// directory alongside swift-syntax.
110110
func testSwiftTestsuite() throws {
111-
try XCTSkipIf(ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] == "1")
111+
try XCTSkipIf(longTestsDisabled)
112112
let testDir =
113113
packageDir
114114
.deletingLastPathComponent()
@@ -125,7 +125,7 @@ public class ParserTests: ParserTestCase {
125125
/// Swift compiler. This requires the Swift compiler to have been checked
126126
/// out into the "swift" directory alongside swift-syntax.
127127
func testSwiftValidationTestsuite() throws {
128-
try XCTSkipIf(ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] == "1")
128+
try XCTSkipIf(longTestsDisabled)
129129
let testDir =
130130
packageDir
131131
.deletingLastPathComponent()

0 commit comments

Comments
 (0)