Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ if not os.path.exists(lldb_path):
lit_config.fatal("lldb does not exist!")

# Define our supported substitutions.
config.substitutions.append( ('%{not}', os.path.join(srcroot, "not")) )
config.substitutions.append( ('%{lldb}', lldb_path) )
config.substitutions.append( ('%{swift}', swift_path) )
config.substitutions.append( ('%{swiftc}', swiftc_path) )
Expand Down
Empty file modified litTest
100644 → 100755
Empty file.
8 changes: 8 additions & 0 deletions not
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# Check that a command terminates with an error exit code.
if "$@"; then
echo "error: unexpected successful exit: " "$@" 1>&2
exit 1
fi
exit 0
72 changes: 72 additions & 0 deletions swift-update-safety.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Test the safety of `swift package update`.

Establish our sandbox.

```
RUN: rm -rf %t.dir
```

Create a dummy package.

```
RUN: mkdir -p %t.dir/Dep
RUN: %{swift} package -C %t.dir/Dep init=library
RUN: git -C %t.dir/Dep init
RUN: git -C %t.dir/Dep add -A
RUN: git -C %t.dir/Dep commit -m "Initial commit."
RUN: git -C %t.dir/Dep tag 1.0.0
```

Create the test package.

```
RUN: mkdir -p %t.dir/Cmd
RUN: %{swift} package -C %t.dir/Cmd init=executable
RUN: echo "import PackageDescription" > %t.dir/Cmd/Package.swift
RUN: echo "let package = Package(" >> %t.dir/Cmd/Package.swift
RUN: echo " name: \"Cmd\"," >> %t.dir/Cmd/Package.swift
RUN: echo " dependencies: [.Package(url: \"../Dep\", Version(1,0,0))]" >> %t.dir/Cmd/Package.swift
RUN: echo ")" >> %t.dir/Cmd/Package.swift
```

Build the test package.

```
RUN: mkdir -p %t.dir/Cmd
RUN: %{swift} build -C %t.dir/Cmd &> %t.build-log
RUN: %{FileCheck} --check-prefix CHECK-BUILD-LOG --input-file %t.build-log %s

CHECK-BUILD-LOG: Compile Swift Module 'Cmd'
```

Validate we can run `--update`.

```
RUN: %{swift} package -C %t.dir/Cmd update
```

Modify the sources of the dependency.

```
RUN: test -f %t.dir/Cmd/Packages/Dep-1.0.0/Sources/Dep.swift
RUN: echo "INVALID CODE" >> %t.dir/Cmd/Packages/Dep-1.0.0/Sources/Dep.swift
```

Validate that `--update` errors out.

```
RUN: %{not} %{swift} package -C %t.dir/Cmd update
```

Stage the changes we made and verify it is still an error.

```
RUN: git -C %t.dir/Cmd/Packages/Dep-1.0.0 add Sources/Dep.swift
RUN: %{not} %{swift} package -C %t.dir/Cmd update
```

Validate we still have our modified source.

```
RUN: grep "INVALID CODE" %t.dir/Cmd/Packages/Dep-1.0.0/Sources/Dep.swift
```