Skip to content

Commit 49260b7

Browse files
authored
Merge pull request #80834 from gottesmm/swift-snapshot-fixes
[swift-snapshot-tool] Two small fixes
2 parents aa2bb0c + a2da134 commit 49260b7

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

utils/swift_snapshot_tool/Sources/swift_snapshot_tool/bisect_toolchains.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ struct BisectToolchains: AsyncParsableCommand {
9595
// just say 50 toolchains ago. To get a few weeks worth. This is easier than
9696
// writing dates a lot.
9797
let oldDateAsDate = self.oldDateAsDate
98-
guard let goodTagIndex = tags.firstIndex(where: { $0.tag.date(branch: self.branch) < oldDateAsDate }) else {
98+
guard let goodTagIndex = tags.firstIndex(where: { $0.tag.date(branch: self.branch) <= oldDateAsDate }) else {
9999
log("Failed to find tag with date: \(oldDateAsDate)")
100100
fatalError()
101101
}

utils/swift_snapshot_tool/Sources/swift_snapshot_tool/run_toolchain.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,18 @@ struct RunToolchains: AsyncParsableCommand {
3939
""")
4040
var script: String
4141

42-
@Option(help: "Snapshot tag to run the test for")
43-
var tag: String
42+
@Option(help: "Date. We use the first snapshot produced before the given date")
43+
var date: String
44+
45+
var dateAsDate: Date {
46+
let d = DateFormatter()
47+
d.dateFormat = "yyyy-MM-dd"
48+
guard let result = d.date(from: date) else {
49+
log("Improperly formatted date: \(date)! Expected format: yyyy_MM_dd.")
50+
fatalError()
51+
}
52+
return result
53+
}
4454

4555
@Flag(help: "Invert the test so that we assume the newest succeeds")
4656
var invert = false
@@ -69,8 +79,9 @@ struct RunToolchains: AsyncParsableCommand {
6979
// Load our tags from swift's github repo
7080
let tags = try! await getTagsFromSwiftRepo(branch: branch)
7181

72-
guard var tagIndex = tags.firstIndex(where: { $0.tag.name == self.tag }) else {
73-
log("Failed to find tag: \(self.tag)")
82+
let date = self.dateAsDate
83+
guard var tagIndex = tags.firstIndex(where: { $0.tag.date(branch: self.branch) <= date }) else {
84+
log("Failed to find tag with date: \(date)")
7485
fatalError()
7586
}
7687

0 commit comments

Comments
 (0)