Skip to content

Commit 502bf8e

Browse files
authored
Merge pull request #42 from apple/master
[pull] swiftwasm from apple:master
2 parents b0dd5f1 + 509ffb3 commit 502bf8e

File tree

4 files changed

+37
-132
lines changed

4 files changed

+37
-132
lines changed

Diff for: test/stdlib/subString.swift

+16-23
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,17 @@ func checkMatch<S: Collection, T: Collection>(_ x: S, _ y: T, _ i: S.Index)
1212
expectEqual(x[i], y[i])
1313
}
1414

15-
func checkMatchContiguousStorage<S: Collection, T: Collection>(_ x: S, _ y: T, expected: Bool)
15+
func checkMatchContiguousStorage<S: Collection, T: Collection>(_ x: S, _ y: T)
1616
where S.Element == T.Element, S.Element: Equatable
1717
{
1818
let xElement = x.withContiguousStorageIfAvailable { $0.first }
1919
let yElement = y.withContiguousStorageIfAvailable { $0.first }
2020

21-
if expected {
22-
expectEqual(xElement, yElement)
23-
} else {
24-
expectNotEqual(xElement, yElement)
25-
}
21+
expectEqual(xElement, yElement)
2622
}
2723

28-
func checkHasContiguousStorage<S: Collection>(_ x: S, expected: Bool) {
29-
let hasStorage = x.withContiguousStorageIfAvailable { _ in true } ?? false
30-
expectEqual(hasStorage, expected)
24+
func checkHasContiguousStorage<S: Collection>(_ x: S) {
25+
expectTrue(x.withContiguousStorageIfAvailable { _ in true } ?? false)
3126
}
3227

3328
func checkHasContiguousStorageSubstring(_ x: Substring.UTF8View) {
@@ -252,23 +247,21 @@ SubstringTests.test("UTF8View") {
252247
expectEqual("", String(u.dropFirst(100))!)
253248
expectEqual("", String(u.dropLast(100))!)
254249

255-
let expectSubstringWCSIA: Bool
256-
// This availability guard should refer to a concrete OS version in
257-
// future.
258-
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
259-
expectSubstringWCSIA = true
260-
} else {
261-
expectSubstringWCSIA = false
262-
}
263250

264-
checkHasContiguousStorage(s.utf8, expected: true) // Strings always do
265-
checkHasContiguousStorage(t, expected: expectSubstringWCSIA)
266-
checkHasContiguousStorage(u, expected: expectSubstringWCSIA)
251+
checkHasContiguousStorage(s.utf8) // Strings always do
267252
checkHasContiguousStorageSubstring(t)
268253
checkHasContiguousStorageSubstring(u)
269-
checkMatchContiguousStorage(Array(s.utf8), s.utf8, expected: true)
270-
checkMatchContiguousStorage(Array(t), t, expected: expectSubstringWCSIA)
271-
checkMatchContiguousStorage(Array(u), u, expected: expectSubstringWCSIA)
254+
checkMatchContiguousStorage(Array(s.utf8), s.utf8)
255+
256+
// The specialization for Substring.withContiguousStorageIfAvailable was
257+
// added in https://github.com/apple/swift/pull/29146.
258+
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else {
259+
return
260+
}
261+
checkHasContiguousStorage(t)
262+
checkHasContiguousStorage(u)
263+
checkMatchContiguousStorage(Array(t), t)
264+
checkMatchContiguousStorage(Array(u), u)
272265
}
273266
}
274267

Diff for: utils/build-script

+21-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ from swift_build_support.swift_build_support import (
3030
diagnostics,
3131
products,
3232
shell,
33-
tar,
3433
targets,
3534
workspace
3635
)
@@ -89,6 +88,25 @@ def print_xcodebuild_versions(file=sys.stdout):
8988
file.flush()
9089

9190

91+
def tar(source, destination):
92+
"""
93+
Create a gzip archive of the file at 'source' at the given
94+
'destination' path.
95+
"""
96+
# We do not use `tarfile` here because:
97+
# - We wish to support LZMA2 compression while also supporting Python 2.7.
98+
# - We wish to explicitly set the owner and group of the archive.
99+
args = ['tar', '-c', '-z', '-f', destination]
100+
101+
if platform.system() != 'Darwin' and platform.system() != 'Windows':
102+
args += ['--owner=0', '--group=0']
103+
104+
# Discard stderr output such as 'tar: Failed to open ...'. We'll detect
105+
# these cases using the exit code, which should cause 'shell.call' to
106+
# raise.
107+
shell.call(args + [source], stderr=shell.DEVNULL)
108+
109+
92110
class BuildScriptInvocation(object):
93111

94112
"""Represent a single build script invocation."""
@@ -1202,8 +1220,8 @@ def main_normal():
12021220
# run `tar` without the leading '/' (we remove it ourselves to keep
12031221
# `tar` from emitting a warning).
12041222
with shell.pushd(args.install_symroot):
1205-
tar.tar(source=prefix.lstrip('/'),
1206-
destination=args.symbols_package)
1223+
tar(source=prefix.lstrip('/'),
1224+
destination=args.symbols_package)
12071225

12081226
return 0
12091227

Diff for: utils/swift_build_support/swift_build_support/tar.py

-34
This file was deleted.

Diff for: utils/swift_build_support/tests/test_tar.py

-72
This file was deleted.

0 commit comments

Comments
 (0)