|
| 1 | +# Test the safety of `swift package update`. |
| 2 | + |
| 3 | +Establish our sandbox. |
| 4 | + |
| 5 | +``` |
| 6 | +RUN: rm -rf %t.dir |
| 7 | +``` |
| 8 | + |
| 9 | +Create a dummy package. |
| 10 | + |
| 11 | +``` |
| 12 | +RUN: mkdir -p %t.dir/Dep |
| 13 | +RUN: %{swift} package -C %t.dir/Dep init=library |
| 14 | +RUN: git -C %t.dir/Dep init |
| 15 | +RUN: git -C %t.dir/Dep add -A |
| 16 | +RUN: git -C %t.dir/Dep commit -m "Initial commit." |
| 17 | +RUN: git -C %t.dir/Dep tag 1.0.0 |
| 18 | +``` |
| 19 | + |
| 20 | +Create the test package. |
| 21 | + |
| 22 | +``` |
| 23 | +RUN: mkdir -p %t.dir/Cmd |
| 24 | +RUN: %{swift} package -C %t.dir/Cmd init=executable |
| 25 | +RUN: echo "import PackageDescription" > %t.dir/Cmd/Package.swift |
| 26 | +RUN: echo "let package = Package(" >> %t.dir/Cmd/Package.swift |
| 27 | +RUN: echo " name: \"Cmd\"," >> %t.dir/Cmd/Package.swift |
| 28 | +RUN: echo " dependencies: [.Package(url: \"../Dep\", Version(1,0,0))]" >> %t.dir/Cmd/Package.swift |
| 29 | +RUN: echo ")" >> %t.dir/Cmd/Package.swift |
| 30 | +``` |
| 31 | + |
| 32 | +Build the test package. |
| 33 | + |
| 34 | +``` |
| 35 | +RUN: mkdir -p %t.dir/Cmd |
| 36 | +RUN: %{swift} build -C %t.dir/Cmd &> %t.build-log |
| 37 | +RUN: %{FileCheck} --check-prefix CHECK-BUILD-LOG --input-file %t.build-log %s |
| 38 | +
|
| 39 | +CHECK-BUILD-LOG: Compile Swift Module 'Cmd' |
| 40 | +``` |
| 41 | + |
| 42 | +Validate we can run `--update`. |
| 43 | + |
| 44 | +``` |
| 45 | +RUN: %{swift} package -C %t.dir/Cmd update |
| 46 | +``` |
| 47 | + |
| 48 | +Modify the sources of the dependency. |
| 49 | + |
| 50 | +``` |
| 51 | +RUN: test -f %t.dir/Cmd/Packages/Dep-1.0.0/Sources/Dep.swift |
| 52 | +RUN: echo "INVALID CODE" >> %t.dir/Cmd/Packages/Dep-1.0.0/Sources/Dep.swift |
| 53 | +``` |
| 54 | + |
| 55 | +Validate that `--update` errors out. |
| 56 | + |
| 57 | +``` |
| 58 | +RUN: %{not} %{swift} package -C %t.dir/Cmd update |
| 59 | +``` |
| 60 | + |
| 61 | +Stage the changes we made and verify it is still an error. |
| 62 | + |
| 63 | +``` |
| 64 | +RUN: git -C %t.dir/Cmd/Packages/Dep-1.0.0 add Sources/Dep.swift |
| 65 | +RUN: %{not} %{swift} package -C %t.dir/Cmd update |
| 66 | +``` |
| 67 | + |
| 68 | +Validate we still have our modified source. |
| 69 | + |
| 70 | +``` |
| 71 | +RUN: grep "INVALID CODE" %t.dir/Cmd/Packages/Dep-1.0.0/Sources/Dep.swift |
| 72 | +``` |
0 commit comments