diff --git a/Tests/AppKit/DropInArchiveTest.j b/Tests/AppKit/DropInArchiveTest.j index d7165f03a..e1132369a 100644 --- a/Tests/AppKit/DropInArchiveTest.j +++ b/Tests/AppKit/DropInArchiveTest.j @@ -125,6 +125,14 @@ var fs = require("fs"), /* An archive written by main must restore the view it was written from. + + The descriptions compared must be the same on every machine. A date, and the + string value of a control that holds one, are recorded by the date's instant in + UTC, because their text is in the local time zone (DropInSnapshot.j). GitHub's + continuous integration runs this test in UTC, so run it in UTC as well as in the + local time zone before committing a change: + + TZ=UTC npx jake test */ - (void)testExistingArchivesRestoreTheOriginalView { diff --git a/Tests/AppKit/DropInSnapshot.j b/Tests/AppKit/DropInSnapshot.j index 1247781b9..f097190a0 100644 --- a/Tests/AppKit/DropInSnapshot.j +++ b/Tests/AppKit/DropInSnapshot.j @@ -165,6 +165,13 @@ function DropInDescribeValue(aValue) if (aValue.isa) { + /* + A date is recorded by its instant in UTC. Its description is in the time zone + of the machine that runs the test, so it differs between machines. + */ + if ([aValue isKindOfClass:[CPDate class]]) + return "CPDate:" + (isNaN(aValue.getTime()) ? "invalid" : aValue.toISOString()); + if ([aValue isKindOfClass:[CPColor class]]) return "CPColor:" + [aValue cssString]; @@ -286,6 +293,15 @@ function DropInViewTreeState(aView) var value = [aView performSelector:selector]; + /* + A control that holds a date gives its string value in the time zone of the + machine that runs the test, because the browser formats it, not Cappuccino. It + is recorded by the date's instant instead, so that every machine records the + same snapshot. + */ + if (aGetter === @"stringValue" && [aView respondsToSelector:@selector(objectValue)] && [[aView objectValue] isKindOfClass:[CPDate class]]) + value = [aView objectValue]; + state[aGetter] = DropInDescribeValue(DropInBooleanGetters.indexOf(aGetter) !== -1 ? !!value : value); }); diff --git a/Tests/AppKit/Resources/DropInArchives.json b/Tests/AppKit/Resources/DropInArchives.json index 3875862d4..8c6fa8389 100644 --- a/Tests/AppKit/Resources/DropInArchives.json +++ b/Tests/AppKit/Resources/DropInArchives.json @@ -755,8 +755,8 @@ "lineBreakMode": "2", "verticalAlignment": "1", "doubleValue": "0", - "objectValue": "CPDate", - "stringValue": "Sat Oct 31 2026 06:00:00 GMT-0600 (Mountain Daylight Time)", + "objectValue": "CPDate:2026-10-31T12:00:00.000Z", + "stringValue": "CPDate:2026-10-31T12:00:00.000Z", "tag": "-1" }, "subviews": [