Skip to content

Commit c261ac6

Browse files
committed
migrate SystemTests
1 parent 3974b66 commit c261ac6

File tree

3 files changed

+91
-101
lines changed

3 files changed

+91
-101
lines changed

Package.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,10 +682,9 @@ let package:Package = .init(
682682
.target(name: "Symbols"),
683683
]),
684684

685-
.executableTarget(name: "SystemTests",
685+
.testTarget(name: "SystemTests",
686686
dependencies: [
687687
.target(name: "System_"),
688-
.target(name: "Testing_"),
689688
],
690689
exclude: [
691690
"directories",

Sources/SystemTests/Directories.swift

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import System_
2+
import Testing
3+
4+
@Suite
5+
enum Directories
6+
{
7+
@Test
8+
static func ExistenceDoesNotExist() throws
9+
{
10+
let path:FilePath = "Sources/SystemTests/TheLimit"
11+
#expect(!path.directory.exists())
12+
}
13+
@Test
14+
static func ExistenceDoesExist() throws
15+
{
16+
let path:FilePath = "Sources/SystemTests/directories/flat"
17+
#expect(path.directory.exists())
18+
}
19+
@Test
20+
static func ExistenceIsSymlink() throws
21+
{
22+
let path:FilePath = "Sources/SystemTests/directories/flat-link/a.txt"
23+
#expect(!path.directory.exists())
24+
}
25+
@Test
26+
static func ExistenceIsSymlinkToDirectory() throws
27+
{
28+
let path:FilePath = "Sources/SystemTests/directories/flat-link"
29+
#expect(path.directory.exists())
30+
}
31+
@Test
32+
static func ExistenceIsNotDirectory() throws
33+
{
34+
let path:FilePath = "Sources/SystemTests/directories/flat/a.txt"
35+
#expect(!path.directory.exists())
36+
}
37+
@Test
38+
static func Flat() throws
39+
{
40+
var files:[FilePath] = []
41+
42+
let path:FilePath = "Sources/SystemTests/directories/flat"
43+
try path.directory.walk
44+
{
45+
files.append($0)
46+
return true
47+
}
48+
let discovered:Set<FilePath.Component> = files.reduce(into: [])
49+
{
50+
if let file:FilePath.Component = $1.lastComponent
51+
{
52+
$0.insert(file)
53+
}
54+
}
55+
56+
#expect(discovered == ["a.txt", "b.txt", "c.txt"])
57+
}
58+
59+
@Test
60+
static func Complex() throws
61+
{
62+
var files:[FilePath] = []
63+
64+
let path:FilePath = "Sources/SystemTests/directories/complex"
65+
try path.directory.walk
66+
{
67+
files.append($0)
68+
return true
69+
}
70+
71+
let discovered:Set<FilePath.Component> = files.reduce(into: [])
72+
{
73+
if let file:FilePath.Component = $1.lastComponent
74+
{
75+
$0.insert(file)
76+
}
77+
}
78+
79+
#expect(discovered == [
80+
"a.txt",
81+
"b.txt",
82+
"x",
83+
"c.txt",
84+
"y",
85+
"d.txt",
86+
"z",
87+
"e.txt"
88+
])
89+
}
90+
}

Sources/SystemTests/Main.swift

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

0 commit comments

Comments
 (0)