From 2bdbb467b2d4f4e4189c75aa228d406c6bd473ab Mon Sep 17 00:00:00 2001 From: tydeu Date: Wed, 1 Nov 2023 18:09:30 -0400 Subject: [PATCH] test: lake: add manifest version upgrade test --- src/lake/tests/manifest/bar/lakefile.lean | 3 ++ src/lake/tests/manifest/clean.sh | 1 + src/lake/tests/manifest/foo/lakefile.lean | 3 ++ src/lake/tests/manifest/lake-manifest-v5.json | 12 +++++ src/lake/tests/manifest/lake-manifest-v6.json | 13 +++++ src/lake/tests/manifest/lake-manifest-v7.json | 19 +++++++ src/lake/tests/manifest/lakefile.lean | 7 +++ src/lake/tests/manifest/test.sh | 51 +++++++++++++++++++ 8 files changed, 109 insertions(+) create mode 100644 src/lake/tests/manifest/bar/lakefile.lean create mode 100755 src/lake/tests/manifest/clean.sh create mode 100644 src/lake/tests/manifest/foo/lakefile.lean create mode 100644 src/lake/tests/manifest/lake-manifest-v5.json create mode 100644 src/lake/tests/manifest/lake-manifest-v6.json create mode 100644 src/lake/tests/manifest/lake-manifest-v7.json create mode 100644 src/lake/tests/manifest/lakefile.lean create mode 100755 src/lake/tests/manifest/test.sh diff --git a/src/lake/tests/manifest/bar/lakefile.lean b/src/lake/tests/manifest/bar/lakefile.lean new file mode 100644 index 000000000000..2b2488da9557 --- /dev/null +++ b/src/lake/tests/manifest/bar/lakefile.lean @@ -0,0 +1,3 @@ +import Lake +open Lake DSL +package bar diff --git a/src/lake/tests/manifest/clean.sh b/src/lake/tests/manifest/clean.sh new file mode 100755 index 000000000000..fae9e3cc521d --- /dev/null +++ b/src/lake/tests/manifest/clean.sh @@ -0,0 +1 @@ +rm -rf lakefile.olean foo/lakefile.olean bar/.git lake-packages lake-manifest.json diff --git a/src/lake/tests/manifest/foo/lakefile.lean b/src/lake/tests/manifest/foo/lakefile.lean new file mode 100644 index 000000000000..d868010b142f --- /dev/null +++ b/src/lake/tests/manifest/foo/lakefile.lean @@ -0,0 +1,3 @@ +import Lake +open Lake DSL +package foo diff --git a/src/lake/tests/manifest/lake-manifest-v5.json b/src/lake/tests/manifest/lake-manifest-v5.json new file mode 100644 index 000000000000..bb70411f54c0 --- /dev/null +++ b/src/lake/tests/manifest/lake-manifest-v5.json @@ -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"}}]} diff --git a/src/lake/tests/manifest/lake-manifest-v6.json b/src/lake/tests/manifest/lake-manifest-v6.json new file mode 100644 index 000000000000..0da6c9210a90 --- /dev/null +++ b/src/lake/tests/manifest/lake-manifest-v6.json @@ -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"} diff --git a/src/lake/tests/manifest/lake-manifest-v7.json b/src/lake/tests/manifest/lake-manifest-v7.json new file mode 100644 index 000000000000..b0a62b393a10 --- /dev/null +++ b/src/lake/tests/manifest/lake-manifest-v7.json @@ -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"} diff --git a/src/lake/tests/manifest/lakefile.lean b/src/lake/tests/manifest/lakefile.lean new file mode 100644 index 000000000000..345340cf305d --- /dev/null +++ b/src/lake/tests/manifest/lakefile.lean @@ -0,0 +1,7 @@ +import Lake +open Lake DSL + +package test + +require foo from "foo" +require bar from git "bar" diff --git a/src/lake/tests/manifest/test.sh b/src/lake/tests/manifest/test.sh new file mode 100755 index 000000000000..4818437cf41a --- /dev/null +++ b/src/lake/tests/manifest/test.sh @@ -0,0 +1,51 @@ +#!/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 test@example.com +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 +sed_i 's/\\\\/\//g' lake-manifest.json # normalize Windows paths +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 +sed_i 's/\\\\/\//g' lake-manifest.json # normalize Windows paths +diff --strip-trailing-cr lake-manifest-v7.json lake-manifest.json