Skip to content

Commit d8c69ad

Browse files
authored
Add tags to swift-testing tests withKnownIssues (#9313)
Augment Swift Testing test that has "withKnownIssues" with tags. Also, augment tests to run against the SwiftBuild and Native build system, in addition to the debug and release build configuraitons. Relates to: #9283
1 parent aef93af commit d8c69ad

18 files changed

+733
-495
lines changed

Sources/_InternalTestSupport/SwiftTesting+Tags.swift

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Testing
1313
extension Tag {
1414
public enum TestSize {}
1515
public enum Feature {}
16+
public enum Platform {}
1617
@Tag public static var UserWorkflow: Tag
1718
}
1819

@@ -22,25 +23,35 @@ extension Tag.TestSize {
2223
@Tag public static var large: Tag
2324
}
2425

26+
extension Tag.Platform {
27+
@Tag public static var FileSystem: Tag
28+
}
29+
2530
extension Tag.Feature {
2631
public enum Command {}
2732
public enum CommandLineArguments {}
28-
public enum EnvironmentVariables {}
33+
public enum EnvironmentVariables {}
2934
public enum PackageType {}
3035
public enum ProductType {}
3136
public enum TargetType {}
3237
public enum Product {}
3338

3439
@Tag public static var BuildCache: Tag
3540
@Tag public static var CodeCoverage: Tag
41+
@Tag public static var CTargets: Tag
42+
@Tag public static var DependencyResolution: Tag
43+
@Tag public static var ModuleAliasing: Tag
3644
@Tag public static var Mirror: Tag
3745
@Tag public static var NetRc: Tag
46+
@Tag public static var Plugin: Tag
3847
@Tag public static var Resource: Tag
48+
@Tag public static var SourceGeneration: Tag
3949
@Tag public static var SpecialCharacters: Tag
4050
@Tag public static var Snippets: Tag
51+
@Tag public static var TestDiscovery: Tag
4152
@Tag public static var Traits: Tag
4253
@Tag public static var TargetSettings: Tag
43-
54+
@Tag public static var Version: Tag
4455
}
4556

4657
extension Tag.Feature.Command {
@@ -75,9 +86,10 @@ extension Tag.Feature.CommandLineArguments {
7586
@Tag public static var Verbose: Tag
7687
@Tag public static var VeryVerbose: Tag
7788
@Tag public static var Xlinker: Tag
89+
@Tag public static var XbuildToolsSwiftc: Tag
7890
@Tag public static var Xcc: Tag
7991
@Tag public static var Xcxx: Tag
80-
@Tag public static var SWIFT_ORIGINAL_PATH: Tag
92+
@Tag public static var Xld: Tag
8193
@Tag public static var Xswiftc: Tag
8294
@Tag public static var TestParallel: Tag
8395
@Tag public static var TestNoParallel: Tag
@@ -93,7 +105,8 @@ extension Tag.Feature.CommandLineArguments {
93105
}
94106

95107
extension Tag.Feature.CommandLineArguments.Experimental {
96-
@Tag public static var BuildDylibsAsFrameworks: Tag
108+
@Tag public static var BuildDylibsAsFrameworks: Tag
109+
@Tag public static var PruneUnusedDependencies: Tag
97110
}
98111
extension Tag.Feature.EnvironmentVariables {
99112
@Tag public static var CUSTOM_SWIFT_VERSION: Tag
@@ -143,9 +156,16 @@ extension Tag.Feature.Command.PackageRegistry {
143156
}
144157

145158
extension Tag.Feature.TargetType {
159+
public enum BinaryTarget {}
146160
@Tag public static var Executable: Tag
147161
@Tag public static var Library: Tag
148162
@Tag public static var Macro: Tag
163+
@Tag public static var Test: Tag
164+
}
165+
166+
extension Tag.Feature.TargetType.BinaryTarget {
167+
@Tag public static var ArtifactBundle: Tag
168+
@Tag public static var XCFramework: Tag
149169
}
150170

151171
extension Tag.Feature.ProductType {
@@ -157,6 +177,7 @@ extension Tag.Feature.ProductType {
157177
}
158178
extension Tag.Feature.PackageType {
159179
@Tag public static var Library: Tag
180+
@Tag public static var Empty: Tag
160181
@Tag public static var Executable: Tag
161182
@Tag public static var Tool: Tag
162183
@Tag public static var Plugin: Tag

Sources/_InternalTestSupport/SwiftTesting+TraitConditional.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import TSCclibc // for SPM_posix_spawn_file_actions_addchdir_np_supported
1818

1919
extension Trait where Self == Testing.ConditionTrait {
2020
/// Skip test if the host operating system does not match the running OS.
21-
public static func requireHostOS(_ os: OperatingSystem, when condition: Bool = true) -> Self {
22-
enabled("This test requires a \(os) host OS.") {
21+
public static func requireHostOS(_ os: OperatingSystem, _ comment: Comment? = nil, when condition: Bool = true) -> Self {
22+
enabled(comment ?? "This test requires a \(os) host OS.") {
2323
ProcessInfo.hostOperatingSystem == os && condition
2424
}
2525
}

Tests/BasicsTests/FileSystem/InMemoryFilesSystemTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ let isLinux = true
2121
let isLinux = false
2222
#endif
2323

24+
@Suite(
25+
.tags(
26+
.TestSize.small,
27+
.Platform.FileSystem,
28+
),
29+
)
2430
struct InMemoryFileSystemTests {
2531
@Test(
2632
arguments: [

Tests/BasicsTests/FileSystem/PathTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ private var windows: Bool { false }
1919
#endif
2020

2121

22+
@Suite(
23+
.tags(
24+
.TestSize.small,
25+
.Platform.FileSystem,
26+
),
27+
)
2228
struct PathTests {
2329
struct AbsolutePathTests {
2430
private func pathStringIsSetCorrectlyTestImplementation(path: String, expected: String, label: String) {

Tests/BasicsTests/FileSystem/VFSTests.swift

Lines changed: 106 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -37,110 +37,114 @@ func testWithTemporaryDirectory(
3737

3838

3939
struct VFSTests {
40-
@Test
40+
@Test(
41+
.issue("https://github.com/swiftlang/swift-package-manager/issues/9310", relationship: .defect),
42+
.skipHostOS(.windows, "Test currently fails with: you don't have permissions."),
43+
.tags(
44+
.TestSize.medium,
45+
.Platform.FileSystem,
46+
.UserWorkflow,
47+
)
48+
)
4149
func localBasics() throws {
42-
try withKnownIssue("Permission issues on Windows") {
43-
// tiny PE binary from: https://archive.is/w01DO
44-
let contents: [UInt8] = [
45-
0x4d, 0x5a, 0x00, 0x00, 0x50, 0x45, 0x00, 0x00, 0x4c, 0x01, 0x01, 0x00,
46-
0x6a, 0x2a, 0x58, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47-
0x04, 0x00, 0x03, 0x01, 0x0b, 0x01, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00,
48-
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
49-
0x04, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
50-
0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
51-
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52-
0x68, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53-
0x02
54-
]
55-
56-
let fs = localFileSystem
57-
try withTemporaryFile { [contents] vfsPath in
58-
try withTemporaryDirectory(removeTreeOnDeinit: true) { [contents] tempDirPath in
59-
let file = tempDirPath.appending("best")
60-
try fs.writeFileContents(file, string: "best")
61-
62-
let sym = tempDirPath.appending("hello")
63-
try fs.createSymbolicLink(sym, pointingAt: file, relative: false)
64-
65-
let executable = tempDirPath.appending("exec-foo")
66-
try fs.writeFileContents(executable, bytes: ByteString(contents))
67-
#if !os(Windows)
68-
try fs.chmod(.executable, path: executable, options: [])
69-
#endif
70-
71-
let executableSym = tempDirPath.appending("exec-sym")
72-
try fs.createSymbolicLink(executableSym, pointingAt: executable, relative: false)
73-
74-
try fs.createDirectory(tempDirPath.appending("dir"))
75-
try fs.writeFileContents(tempDirPath.appending(components: ["dir", "file"]), bytes: [])
76-
77-
try VirtualFileSystem.serializeDirectoryTree(tempDirPath, into: AbsolutePath(vfsPath.path), fs: fs, includeContents: [executable])
78-
}
79-
80-
let vfs = try VirtualFileSystem(path: vfsPath.path, fs: fs)
81-
82-
// exists()
83-
#expect(vfs.exists(AbsolutePath("/")))
84-
#expect(!vfs.exists(AbsolutePath("/does-not-exist")))
85-
86-
// isFile()
87-
let filePath = AbsolutePath("/best")
88-
#expect(vfs.exists(filePath))
89-
#expect(vfs.isFile(filePath))
90-
#expect(try vfs.getFileInfo(filePath).fileType == .typeRegular)
91-
#expect(!vfs.isDirectory(filePath))
92-
#expect(!vfs.isFile(AbsolutePath("/does-not-exist")))
93-
#expect(!vfs.isSymlink(AbsolutePath("/does-not-exist")))
94-
#expect(throws: (any Error).self) {
95-
try vfs.getFileInfo(AbsolutePath("/does-not-exist"))
96-
}
97-
98-
// isSymlink()
99-
let symPath = AbsolutePath("/hello")
100-
#expect(vfs.isSymlink(symPath))
101-
#expect(vfs.isFile(symPath))
102-
#expect(try vfs.getFileInfo(symPath).fileType == .typeSymbolicLink)
103-
#expect(!vfs.isDirectory(symPath))
104-
105-
// isExecutableFile
106-
let executablePath = AbsolutePath("/exec-foo")
107-
let executableSymPath = AbsolutePath("/exec-sym")
108-
#expect(vfs.isExecutableFile(executablePath))
109-
#expect(vfs.isExecutableFile(executableSymPath))
110-
#expect(vfs.isSymlink(executableSymPath))
111-
#expect(!vfs.isExecutableFile(symPath))
112-
#expect(!vfs.isExecutableFile(filePath))
113-
#expect(!vfs.isExecutableFile(AbsolutePath("/does-not-exist")))
114-
#expect(!vfs.isExecutableFile(AbsolutePath("/")))
115-
116-
// readFileContents
117-
let execFileContents = try vfs.readFileContents(executablePath)
118-
#expect(execFileContents == ByteString(contents))
119-
120-
// isDirectory()
121-
#expect(vfs.isDirectory(AbsolutePath("/")))
122-
#expect(!vfs.isDirectory(AbsolutePath("/does-not-exist")))
123-
124-
// getDirectoryContents()
125-
let dirContents = try vfs.getDirectoryContents(AbsolutePath("/"))
126-
#expect(dirContents.sorted() == ["best", "dir", "exec-foo", "exec-sym", "hello"])
127-
#expect {try vfs.getDirectoryContents(AbsolutePath("/does-not-exist"))} throws: { error in
128-
(error.localizedDescription == "no such file or directory: \(AbsolutePath("/does-not-exist"))")
129-
}
130-
131-
let thisDirectoryContents = try vfs.getDirectoryContents(AbsolutePath("/"))
132-
#expect(!thisDirectoryContents.contains(where: { $0 == "." }))
133-
#expect(!thisDirectoryContents.contains(where: { $0 == ".." }))
134-
#expect(thisDirectoryContents.sorted() == ["best", "dir", "exec-foo", "exec-sym", "hello"])
135-
136-
let contents = try vfs.getDirectoryContents(AbsolutePath("/dir"))
137-
#expect(contents == ["file"])
138-
139-
let fileContents = try vfs.readFileContents(AbsolutePath("/dir/file"))
140-
#expect(fileContents == "")
50+
// tiny PE binary from: https://archive.is/w01DO
51+
let contents: [UInt8] = [
52+
0x4d, 0x5a, 0x00, 0x00, 0x50, 0x45, 0x00, 0x00, 0x4c, 0x01, 0x01, 0x00,
53+
0x6a, 0x2a, 0x58, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54+
0x04, 0x00, 0x03, 0x01, 0x0b, 0x01, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00,
55+
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
56+
0x04, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
57+
0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
58+
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59+
0x68, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60+
0x02
61+
]
62+
63+
let fs = localFileSystem
64+
try withTemporaryFile { [contents] vfsPath in
65+
try withTemporaryDirectory(removeTreeOnDeinit: true) { [contents] tempDirPath in
66+
let file = tempDirPath.appending("best")
67+
try fs.writeFileContents(file, string: "best")
68+
69+
let sym = tempDirPath.appending("hello")
70+
try fs.createSymbolicLink(sym, pointingAt: file, relative: false)
71+
72+
let executable = tempDirPath.appending("exec-foo")
73+
try fs.writeFileContents(executable, bytes: ByteString(contents))
74+
#if !os(Windows)
75+
try fs.chmod(.executable, path: executable, options: [])
76+
#endif
77+
78+
let executableSym = tempDirPath.appending("exec-sym")
79+
try fs.createSymbolicLink(executableSym, pointingAt: executable, relative: false)
80+
81+
try fs.createDirectory(tempDirPath.appending("dir"))
82+
try fs.writeFileContents(tempDirPath.appending(components: ["dir", "file"]), bytes: [])
83+
84+
try VirtualFileSystem.serializeDirectoryTree(tempDirPath, into: AbsolutePath(vfsPath.path), fs: fs, includeContents: [executable])
14185
}
142-
} when: {
143-
ProcessInfo.hostOperatingSystem == .windows
86+
87+
let vfs = try VirtualFileSystem(path: vfsPath.path, fs: fs)
88+
89+
// exists()
90+
#expect(vfs.exists(AbsolutePath("/")))
91+
#expect(!vfs.exists(AbsolutePath("/does-not-exist")))
92+
93+
// isFile()
94+
let filePath = AbsolutePath("/best")
95+
#expect(vfs.exists(filePath))
96+
#expect(vfs.isFile(filePath))
97+
#expect(try vfs.getFileInfo(filePath).fileType == .typeRegular)
98+
#expect(!vfs.isDirectory(filePath))
99+
#expect(!vfs.isFile(AbsolutePath("/does-not-exist")))
100+
#expect(!vfs.isSymlink(AbsolutePath("/does-not-exist")))
101+
#expect(throws: (any Error).self) {
102+
try vfs.getFileInfo(AbsolutePath("/does-not-exist"))
103+
}
104+
105+
// isSymlink()
106+
let symPath = AbsolutePath("/hello")
107+
#expect(vfs.isSymlink(symPath))
108+
#expect(vfs.isFile(symPath))
109+
#expect(try vfs.getFileInfo(symPath).fileType == .typeSymbolicLink)
110+
#expect(!vfs.isDirectory(symPath))
111+
112+
// isExecutableFile
113+
let executablePath = AbsolutePath("/exec-foo")
114+
let executableSymPath = AbsolutePath("/exec-sym")
115+
#expect(vfs.isExecutableFile(executablePath))
116+
#expect(vfs.isExecutableFile(executableSymPath))
117+
#expect(vfs.isSymlink(executableSymPath))
118+
#expect(!vfs.isExecutableFile(symPath))
119+
#expect(!vfs.isExecutableFile(filePath))
120+
#expect(!vfs.isExecutableFile(AbsolutePath("/does-not-exist")))
121+
#expect(!vfs.isExecutableFile(AbsolutePath("/")))
122+
123+
// readFileContents
124+
let execFileContents = try vfs.readFileContents(executablePath)
125+
#expect(execFileContents == ByteString(contents))
126+
127+
// isDirectory()
128+
#expect(vfs.isDirectory(AbsolutePath("/")))
129+
#expect(!vfs.isDirectory(AbsolutePath("/does-not-exist")))
130+
131+
// getDirectoryContents()
132+
let dirContents = try vfs.getDirectoryContents(AbsolutePath("/"))
133+
#expect(dirContents.sorted() == ["best", "dir", "exec-foo", "exec-sym", "hello"])
134+
#expect {try vfs.getDirectoryContents(AbsolutePath("/does-not-exist"))} throws: { error in
135+
(error.localizedDescription == "no such file or directory: \(AbsolutePath("/does-not-exist"))")
136+
}
137+
138+
let thisDirectoryContents = try vfs.getDirectoryContents(AbsolutePath("/"))
139+
#expect(!thisDirectoryContents.contains(where: { $0 == "." }))
140+
#expect(!thisDirectoryContents.contains(where: { $0 == ".." }))
141+
#expect(thisDirectoryContents.sorted() == ["best", "dir", "exec-foo", "exec-sym", "hello"])
142+
143+
let contents = try vfs.getDirectoryContents(AbsolutePath("/dir"))
144+
#expect(contents == ["file"])
145+
146+
let fileContents = try vfs.readFileContents(AbsolutePath("/dir/file"))
147+
#expect(fileContents == "")
144148
}
145149
}
146150
}

Tests/BuildTests/BuildSystemDelegateTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ struct BuildSystemDelegateTests {
6363
@Test(
6464
.issue("https://github.com/swiftlang/swift-package-manager/issues/8540", relationship: .defect), // Package fails to build when the test is being executed"
6565
.requiresSDKDependentTestsSupport,
66+
.tags(
67+
.Feature.Command.Build,
68+
.Feature.TargetType.Executable,
69+
.Feature.TargetType.Library,
70+
.Feature.CommandLineArguments.BuildSystem,
71+
.Feature.CommandLineArguments.Configuration,
72+
),
6673
arguments: getBuildData(for: SupportedBuildSystemOnAllPlatforms),
6774
)
6875
func filterNonFatalCodesignMessages(

Tests/BuildTests/PluginsBuildPlanTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ struct PluginsBuildPlanTests {
2727
@Test(
2828
.tags(
2929
.Feature.Command.Build,
30+
.Feature.Plugin,
31+
.Feature.SourceGeneration,
3032
),
3133
.IssueWindowsPathTestsFailures, // Fails to build the project to due to incorrect Path handling
3234
arguments: BuildConfiguration.allCases,

0 commit comments

Comments
 (0)