Skip to content

Commit c8dbbc3

Browse files
committed
[swift_snapshot_tool] Make the run command just accept a date like bisect does.
Previously, we wanted a full tag name, but that is really not needed. Better to harmonize the two and eliminate the need for a full tag name.
1 parent 607c7c5 commit c8dbbc3

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

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)