Skip to content

Commit

Permalink
test: lake: add manifest version upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
tydeu committed Nov 1, 2023
1 parent 814e5db commit 222f08e
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lake/tests/manifest/bar/lakefile.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Lake
open Lake DSL
package bar
1 change: 1 addition & 0 deletions src/lake/tests/manifest/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm -rf lakefile.olean foo/lakefile.olean bar/.git lake-packages lake-manifest.json
3 changes: 3 additions & 0 deletions src/lake/tests/manifest/foo/lakefile.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Lake
open Lake DSL
package foo
12 changes: 12 additions & 0 deletions src/lake/tests/manifest/lake-manifest-v5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{"version": 5,
"packagesDir": "lake-packages",
"packages":
[{"git":
{"url": "bar",
"subDir?": null,
"rev": "253735aaee71d8bb0f29ae5cfc3ce086a4b9e64f",
"opts": {},
"name": "bar",
"inputRev?": null,
"inherited": false}},
{"path": {"opts": {}, "name": "foo", "inherited": false, "dir": ".\\foo"}}]}
13 changes: 13 additions & 0 deletions src/lake/tests/manifest/lake-manifest-v6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{"version": 6,
"packagesDir": "lake-packages",
"packages":
[{"path": {"opts": {}, "name": "foo", "inherited": false, "dir": ".\\foo"}},
{"git":
{"url": "bar",
"subDir?": null,
"rev": "dab525a78710d185f3d23622b143bdd837e44ab0",
"opts": {},
"name": "bar",
"inputRev?": null,
"inherited": false}}],
"name": "test"}
19 changes: 19 additions & 0 deletions src/lake/tests/manifest/lake-manifest-v7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{"version": 7,
"packagesDir": "lake-packages",
"packages":
[{"type": "path",
"name": "foo",
"manifestFile": "lake-manifest.json",
"inherited": false,
"dir": ".\\foo",
"configFile": "lakefile.lean"},
{"url": "bar",
"type": "git",
"subDir": null,
"rev": "0538596b94a0510f55dc820cabd3bde41ad93c3e",
"name": "bar",
"manifestFile": "lake-manifest.json",
"inputRev": null,
"inherited": false,
"configFile": "lakefile.lean"}],
"name": "test"}
7 changes: 7 additions & 0 deletions src/lake/tests/manifest/lakefile.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Lake
open Lake DSL

package test

require foo from "foo"
require bar from git "bar"
49 changes: 49 additions & 0 deletions src/lake/tests/manifest/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -exo pipefail

LAKE=${LAKE:-../../build/bin/lake}

if [ "`uname`" = Darwin ]; then
sed_i() { sed -i '' "$@"; }
else
sed_i() { sed -i "$@"; }
fi

./clean.sh

# Since committing a Git repository to a Git repository is not well-supported,
# We reinitialize the bar repository on each test. This requires updating the
# locked manifest to the new hash to ensure things work properly.
pushd bar
git init
git checkout -b master
git config user.name test
git config user.email [email protected]
git add --all
git commit -m "initial commit"
REV=`git rev-parse HEAD`
popd

# ---
# Test manifest properly upgrades from supported versions
# ---

# Test successful loading of a V5 manifest
cp lake-manifest-v5.json lake-manifest.json
sed_i "s/253735aaee71d8bb0f29ae5cfc3ce086a4b9e64f/$REV/g" lake-manifest.json
$LAKE resolve-deps

# Test update produces the expected V7 manifest
$LAKE update
sed_i "s/$REV/0538596b94a0510f55dc820cabd3bde41ad93c3e/g" lake-manifest.json
diff --strip-trailing-cr lake-manifest-v7.json lake-manifest.json

# Test successful loading of a V6 manifest
cp lake-manifest-v6.json lake-manifest.json
sed_i "s/dab525a78710d185f3d23622b143bdd837e44ab0/$REV/g" lake-manifest.json
$LAKE resolve-deps

# Test update produces the expected V7 manifest
$LAKE update
sed_i "s/$REV/0538596b94a0510f55dc820cabd3bde41ad93c3e/g" lake-manifest.json
diff --strip-trailing-cr lake-manifest-v7.json lake-manifest.json

0 comments on commit 222f08e

Please sign in to comment.