forked from swiftlang/swift-build
- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestSupportTests.swift
82 lines (74 loc) · 3.31 KB
/
TestSupportTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import Testing
import SWBCore
import SWBTestSupport
import SWBUtil
@SuitefileprivatestructAssertionTests{
@Testfunc assertMatchStringLists(){
XCTAssertMatch([],[])
XCTAssertMatch(["a"],[])
XCTAssertMatch([],[.anySequence])
XCTAssertMatch(["a"],[.anySequence])
XCTAssertMatch(["a","b"],[.anySequence])
XCTAssertMatch([],[.start])
XCTAssertMatch([],[.start,.end])
XCTAssertMatch([],[.end])
XCTAssertNoMatch([],[.end,"a"])
XCTAssertMatch(["a"],[.start,"a",.end])
XCTAssertMatch(["a"],[.start,.anySequence,.end])
XCTAssertNoMatch(["a"],[.start,"b",.end])
XCTAssertNoMatch(["a"],["a",.start])
XCTAssertMatch(["a","c"],["a",.anySequence,"c"])
XCTAssertMatch(["a","b","c"],["a",.anySequence,"c"])
XCTAssertMatch(["a","b","b","c"],["a",.anySequence,"c"])
}
}
@SuitefileprivatestructTaskCheckingTests:CoreBasedTests{
@Test(.requireSDKs(.host))
func ensureTaskBelongToCorrectBuild()asyncthrows{
tryawaitwithTemporaryDirectory{ tmpDir in
lettestWorkspace=TestWorkspace("TestWorkspace", sourceRoot: tmpDir, projects:[
TestProject("TestProject",
groupTree:TestGroup("Root", children:[TestFile("test.c")]),
buildConfigurations:[
TestBuildConfiguration(
"Debug",
buildSettings:[
"GENERATE_INFOPLIST_FILE":"YES",
"PRODUCT_NAME":"$(TARGET_NAME)",
"CODE_SIGN_IDENTITY":"-",
]),
],
targets:[
TestStandardTarget("TestTarget", type:.commandLineTool, buildPhases:[
TestSourcesBuildPhase([
TestBuildFile("test.c")
])
])
])
])
letcore=tryawaitgetCore()
letbuildA=tryTaskConstructionTester(core, testWorkspace)
tryawait buildA.checkBuild(runDestination:.host){ outerResults in
lettasks= outerResults.getTasks(.matchRuleItem("CompileC"))
letbuildB=tryTaskConstructionTester(core, testWorkspace)
await buildB.checkBuild(runDestination:.host){ results in
// This is not a not a known issue but rather an expected failure
withKnownIssue("Task does not belong to the current build"){
try results.checkTaskFollows(#require(tasks.only),.matchRuleItem("CompileC"))
}
}
}
}
}
}