Skip to content

Commit

Permalink
Merge pull request #42 from apple/master
Browse files Browse the repository at this point in the history
[pull] swiftwasm from apple:master
  • Loading branch information
pull[bot] authored Jan 27, 2020
2 parents b0dd5f1 + 509ffb3 commit 502bf8e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 132 deletions.
39 changes: 16 additions & 23 deletions test/stdlib/subString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,17 @@ func checkMatch<S: Collection, T: Collection>(_ x: S, _ y: T, _ i: S.Index)
expectEqual(x[i], y[i])
}

func checkMatchContiguousStorage<S: Collection, T: Collection>(_ x: S, _ y: T, expected: Bool)
func checkMatchContiguousStorage<S: Collection, T: Collection>(_ x: S, _ y: T)
where S.Element == T.Element, S.Element: Equatable
{
let xElement = x.withContiguousStorageIfAvailable { $0.first }
let yElement = y.withContiguousStorageIfAvailable { $0.first }

if expected {
expectEqual(xElement, yElement)
} else {
expectNotEqual(xElement, yElement)
}
expectEqual(xElement, yElement)
}

func checkHasContiguousStorage<S: Collection>(_ x: S, expected: Bool) {
let hasStorage = x.withContiguousStorageIfAvailable { _ in true } ?? false
expectEqual(hasStorage, expected)
func checkHasContiguousStorage<S: Collection>(_ x: S) {
expectTrue(x.withContiguousStorageIfAvailable { _ in true } ?? false)
}

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

let expectSubstringWCSIA: Bool
// This availability guard should refer to a concrete OS version in
// future.
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
expectSubstringWCSIA = true
} else {
expectSubstringWCSIA = false
}

checkHasContiguousStorage(s.utf8, expected: true) // Strings always do
checkHasContiguousStorage(t, expected: expectSubstringWCSIA)
checkHasContiguousStorage(u, expected: expectSubstringWCSIA)
checkHasContiguousStorage(s.utf8) // Strings always do
checkHasContiguousStorageSubstring(t)
checkHasContiguousStorageSubstring(u)
checkMatchContiguousStorage(Array(s.utf8), s.utf8, expected: true)
checkMatchContiguousStorage(Array(t), t, expected: expectSubstringWCSIA)
checkMatchContiguousStorage(Array(u), u, expected: expectSubstringWCSIA)
checkMatchContiguousStorage(Array(s.utf8), s.utf8)

// The specialization for Substring.withContiguousStorageIfAvailable was
// added in https://github.com/apple/swift/pull/29146.
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else {
return
}
checkHasContiguousStorage(t)
checkHasContiguousStorage(u)
checkMatchContiguousStorage(Array(t), t)
checkMatchContiguousStorage(Array(u), u)
}
}

Expand Down
24 changes: 21 additions & 3 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ from swift_build_support.swift_build_support import (
diagnostics,
products,
shell,
tar,
targets,
workspace
)
Expand Down Expand Up @@ -89,6 +88,25 @@ def print_xcodebuild_versions(file=sys.stdout):
file.flush()


def tar(source, destination):
"""
Create a gzip archive of the file at 'source' at the given
'destination' path.
"""
# We do not use `tarfile` here because:
# - We wish to support LZMA2 compression while also supporting Python 2.7.
# - We wish to explicitly set the owner and group of the archive.
args = ['tar', '-c', '-z', '-f', destination]

if platform.system() != 'Darwin' and platform.system() != 'Windows':
args += ['--owner=0', '--group=0']

# Discard stderr output such as 'tar: Failed to open ...'. We'll detect
# these cases using the exit code, which should cause 'shell.call' to
# raise.
shell.call(args + [source], stderr=shell.DEVNULL)


class BuildScriptInvocation(object):

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

return 0

Expand Down
34 changes: 0 additions & 34 deletions utils/swift_build_support/swift_build_support/tar.py

This file was deleted.

72 changes: 0 additions & 72 deletions utils/swift_build_support/tests/test_tar.py

This file was deleted.

0 comments on commit 502bf8e

Please sign in to comment.