Skip to content

Commit 24032f9

Browse files
committed
[test] Make bindings-build-record.swift cross-time-zone-compatible.
This is a Driver test that relies on being able to refer to particular seconds. Previously it (accidentally) relied on 'touch' acting in Pacific time. Fixes https://bugs.swift.org/browse/SR-31 and rdar://problem/23382722.
1 parent 13b679d commit 24032f9

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python
2+
3+
# Like /bin/touch, but takes a time using the LLVM epoch.
4+
5+
import os
6+
import sys
7+
8+
assert len(sys.argv) >= 2
9+
timeVal = int(sys.argv[1])
10+
11+
timeVal += 946684800 # offset between Unix and LLVM epochs
12+
13+
# Update the output file mtime, or create it if necessary.
14+
# From http://stackoverflow.com/a/1160227.
15+
for outputFile in sys.argv[1:]:
16+
with open(outputFile, 'a'):
17+
os.utime(outputFile, (timeVal, timeVal))

test/Driver/Dependencies/bindings-build-record.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
// rdar://problem/21515673
2-
// REQUIRES: OS=macosx
3-
41
// RUN: rm -rf %t && cp -r %S/Inputs/bindings-build-record/ %t
5-
// RUN: touch -t 201401240005 %t/*
2+
// RUN: %S/Inputs/touch.py 443865900 %t/*
63

74
// RUN: cd %t && %swiftc_driver -driver-print-bindings ./main.swift ./other.swift ./yet-another.swift -incremental -output-file-map %t/output.json 2>&1 | FileCheck %s -check-prefix=MUST-EXEC
85

@@ -32,13 +29,13 @@
3229

3330
// FILE-ADDED: inputs: ["./added.swift"], output: {{[{].*[}]}}, condition: newly-added{{$}}
3431

35-
// RUN: touch -t 201401240006 %t/main.swift
32+
// RUN: %S/Inputs/touch.py 443865960 %t/main.swift
3633
// RUN: cd %t && %swiftc_driver -driver-print-bindings ./main.swift ./other.swift ./yet-another.swift -incremental -output-file-map %t/output.json 2>&1 | FileCheck %s -check-prefix=BUILD-RECORD-PLUS-CHANGE
3734
// BUILD-RECORD-PLUS-CHANGE: inputs: ["./main.swift"], output: {{[{].*[}]}}, condition: run-without-cascading
3835
// BUILD-RECORD-PLUS-CHANGE: inputs: ["./other.swift"], output: {{[{].*[}]}}, condition: run-without-cascading{{$}}
3936
// BUILD-RECORD-PLUS-CHANGE: inputs: ["./yet-another.swift"], output: {{[{].*[}]$}}
4037

41-
// RUN: touch -t 201401240005 %t/main.swift
38+
// RUN: %S/Inputs/touch.py 443865900 %t/*
4239
// RUN: cd %t && %swiftc_driver -driver-print-bindings ./main.swift ./other.swift -incremental -output-file-map %t/output.json 2>&1 | FileCheck %s -check-prefix=FILE-REMOVED
4340
// FILE-REMOVED: inputs: ["./main.swift"], output: {{[{].*[}]}}, condition: run-without-cascading
4441
// FILE-REMOVED: inputs: ["./other.swift"], output: {{[{].*[}]}}, condition: run-without-cascading

0 commit comments

Comments
 (0)