krz/orgstar

A native macOS editor for org-mode files. editor org-mode swift

Commit 3855cfb4a1

3855cfb4a1a4927ac63e5aaa4b673ae8f28e4c37

parent: 778058aafc

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-09 01:26 UTC

Run the sort-list oracle test in UTC

The oracle runs Emacs with TZ=UTC; items without a time sort as now, so
the two sides disagreed whenever the local date differed from UTC.

Layout: unified · split

Tests/OrgCoreTests/EmacsOracle.swift +3 −2
@@ -162,8 +162,9 @@ func withOptions(_ options: EditingOptions, _ form: String) -> String {
162162let doomOptions = EditingOptions(tagsColumn: 0, insertHeadingRespectContent: true, metaReturnMaySplitLine: false, listAllowAlphabetical: true, fillColumn: 80, hideEmphasisMarkers: true, prettyEntities: true, subSuperscriptsNeedBraces: true)
163163
164164/// Runs a command the way an editor would: build a context, run, apply the edits.
165func runCommand(_ command: any OrgCommand, _ text: String, caret: Int, answers: [String: String] = [:], options: EditingOptions = .org) -> (text: String, caret: Int, failure: String?) {
166 let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], answers: answers, options: options)
165func runCommand(_ command: any OrgCommand, _ text: String, caret: Int, answers: [String: String] = [:], options: EditingOptions = .org,
166 calendar: Calendar = .current) -> (text: String, caret: Int, failure: String?) {
167 let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], calendar: calendar, answers: answers, options: options)
167168 switch command.run(in: context) {
168169 case .commit(let result):
169170 var new = text
Tests/OrgCoreTests/SortListTests.swift +8 −1
@@ -14,6 +14,12 @@ struct SortListTests {
1414 "Intro\n- one\n- two\n continued\n- three\nOutro\n",
1515 ]
1616
17 static let utc: Calendar = {
18 var calendar = Calendar(identifier: .gregorian)
19 calendar.timeZone = TimeZone(identifier: "UTC")!
20 return calendar
21 }()
22
1723 @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
1824 func matchesEmacs() throws {
1925 var cases: [EmacsOracle.Case] = []
@@ -33,7 +39,8 @@ struct SortListTests {
3339 for caret in carets.prefix(2) {
3440 for key in ["a", "A", "n", "N", "t", "T", "x", "X"] {
3541 cases.append(EmacsOracle.Case(text: text, point: EmacsOracle.point(caret, in: text), form: "(org-sort-list nil ?\(key))"))
36 ours.append(runCommand(SortEntries(), text, caret: caret, answers: ["sort": key]))
42 // In UTC, as the oracle runs Emacs: an item without a time sorts as now.
43 ours.append(runCommand(SortEntries(), text, caret: caret, answers: ["sort": key], calendar: Self.utc))
3744 }
3845 }
3946 }