forked from lix-project/lix
treewide: Stop using URL literals
They must die
Change-Id: Ibe2b1818b21d98ec1a68836d01d5dad729b8c501
This commit is contained in:
parent
41a0b08e64
commit
1c080a8239
|
@ -32,14 +32,14 @@ git -C $repo tag -a tag2 -m tag2
|
||||||
|
|
||||||
# Fetch a worktree
|
# Fetch a worktree
|
||||||
unset _NIX_FORCE_HTTP
|
unset _NIX_FORCE_HTTP
|
||||||
path0=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$TEST_ROOT/worktree).outPath")
|
path0=$(nix eval --impure --raw --expr "(builtins.fetchGit \"file://$TEST_ROOT/worktree\").outPath")
|
||||||
path0_=$(nix eval --impure --raw --expr "(builtins.fetchTree { type = \"git\"; url = file://$TEST_ROOT/worktree; }).outPath")
|
path0_=$(nix eval --impure --raw --expr "(builtins.fetchTree { type = \"git\"; url = \"file://$TEST_ROOT/worktree\"; }).outPath")
|
||||||
[[ $path0 = $path0_ ]]
|
[[ $path0 = $path0_ ]]
|
||||||
export _NIX_FORCE_HTTP=1
|
export _NIX_FORCE_HTTP=1
|
||||||
[[ $(tail -n 1 $path0/hello) = "hello" ]]
|
[[ $(tail -n 1 $path0/hello) = "hello" ]]
|
||||||
|
|
||||||
# Fetch the default branch.
|
# Fetch the default branch.
|
||||||
path=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath")
|
path=$(nix eval --impure --raw --expr "(builtins.fetchGit \"file://$repo\").outPath")
|
||||||
[[ $(cat $path/hello) = world ]]
|
[[ $(cat $path/hello) = world ]]
|
||||||
|
|
||||||
# Fetch a rev from another branch
|
# Fetch a rev from another branch
|
||||||
|
@ -49,37 +49,37 @@ git -C $repo add differentbranch
|
||||||
git -C $repo commit -m 'Test2'
|
git -C $repo commit -m 'Test2'
|
||||||
git -C $repo checkout master
|
git -C $repo checkout master
|
||||||
devrev=$(git -C $repo rev-parse devtest)
|
devrev=$(git -C $repo rev-parse devtest)
|
||||||
out=$(nix eval --impure --raw --expr "builtins.fetchGit { url = file://$repo; rev = \"$devrev\"; }" 2>&1) || status=$?
|
out=$(nix eval --impure --raw --expr "builtins.fetchGit { url = \"file://$repo\"; rev = \"$devrev\"; }" 2>&1) || status=$?
|
||||||
[[ $status == 1 ]]
|
[[ $status == 1 ]]
|
||||||
[[ $out =~ 'Cannot find Git revision' ]]
|
[[ $out =~ 'Cannot find Git revision' ]]
|
||||||
|
|
||||||
[[ $(nix eval --raw --expr "builtins.readFile (builtins.fetchGit { url = file://$repo; rev = \"$devrev\"; allRefs = true; } + \"/differentbranch\")") = 'different file' ]]
|
[[ $(nix eval --raw --expr "builtins.readFile (builtins.fetchGit { url = \"file://$repo\"; rev = \"$devrev\"; allRefs = true; } + \"/differentbranch\")") = 'different file' ]]
|
||||||
|
|
||||||
# In pure eval mode, fetchGit without a revision should fail.
|
# In pure eval mode, fetchGit without a revision should fail.
|
||||||
[[ $(nix eval --impure --raw --expr "builtins.readFile (fetchGit file://$repo + \"/hello\")") = world ]]
|
[[ $(nix eval --impure --raw --expr "builtins.readFile (fetchGit \"file://$repo\" + \"/hello\")") = world ]]
|
||||||
(! nix eval --raw --expr "builtins.readFile (fetchGit file://$repo + \"/hello\")")
|
(! nix eval --raw --expr "builtins.readFile (fetchGit \"file://$repo\" + \"/hello\")")
|
||||||
|
|
||||||
# Fetch using an explicit revision hash.
|
# Fetch using an explicit revision hash.
|
||||||
path2=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev2\"; }).outPath")
|
path2=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$repo\"; rev = \"$rev2\"; }).outPath")
|
||||||
[[ $path = $path2 ]]
|
[[ $path = $path2 ]]
|
||||||
|
|
||||||
# In pure eval mode, fetchGit with a revision should succeed.
|
# In pure eval mode, fetchGit with a revision should succeed.
|
||||||
[[ $(nix eval --raw --expr "builtins.readFile (fetchGit { url = file://$repo; rev = \"$rev2\"; } + \"/hello\")") = world ]]
|
[[ $(nix eval --raw --expr "builtins.readFile (fetchGit { url = \"file://$repo\"; rev = \"$rev2\"; } + \"/hello\")") = world ]]
|
||||||
|
|
||||||
# Fetch again. This should be cached.
|
# Fetch again. This should be cached.
|
||||||
mv $repo ${repo}-tmp
|
mv $repo ${repo}-tmp
|
||||||
path2=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath")
|
path2=$(nix eval --impure --raw --expr "(builtins.fetchGit \"file://$repo\").outPath")
|
||||||
[[ $path = $path2 ]]
|
[[ $path = $path2 ]]
|
||||||
|
|
||||||
[[ $(nix eval --impure --expr "(builtins.fetchGit file://$repo).revCount") = 2 ]]
|
[[ $(nix eval --impure --expr "(builtins.fetchGit \"file://$repo\").revCount") = 2 ]]
|
||||||
[[ $(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).rev") = $rev2 ]]
|
[[ $(nix eval --impure --raw --expr "(builtins.fetchGit \"file://$repo\").rev") = $rev2 ]]
|
||||||
[[ $(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).shortRev") = ${rev2:0:7} ]]
|
[[ $(nix eval --impure --raw --expr "(builtins.fetchGit \"file://$repo\").shortRev") = ${rev2:0:7} ]]
|
||||||
|
|
||||||
# Fetching with a explicit hash should succeed.
|
# Fetching with a explicit hash should succeed.
|
||||||
path2=$(nix eval --refresh --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev2\"; }).outPath")
|
path2=$(nix eval --refresh --raw --expr "(builtins.fetchGit { url = \"file://$repo\"; rev = \"$rev2\"; }).outPath")
|
||||||
[[ $path = $path2 ]]
|
[[ $path = $path2 ]]
|
||||||
|
|
||||||
path2=$(nix eval --refresh --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev1\"; }).outPath")
|
path2=$(nix eval --refresh --raw --expr "(builtins.fetchGit { url = \"file://$repo\"; rev = \"$rev1\"; }).outPath")
|
||||||
[[ $(cat $path2/hello) = utrecht ]]
|
[[ $(cat $path2/hello) = utrecht ]]
|
||||||
|
|
||||||
mv ${repo}-tmp $repo
|
mv ${repo}-tmp $repo
|
||||||
|
@ -118,7 +118,7 @@ path3=$(nix eval --raw --expr "(builtins.fetchGit { url = $repo; rev = \"$rev2\"
|
||||||
# Committing should not affect the store path.
|
# Committing should not affect the store path.
|
||||||
git -C $repo commit -m 'Bla3' -a
|
git -C $repo commit -m 'Bla3' -a
|
||||||
|
|
||||||
path4=$(nix eval --impure --refresh --raw --expr "(builtins.fetchGit file://$repo).outPath")
|
path4=$(nix eval --impure --refresh --raw --expr "(builtins.fetchGit \"file://$repo\").outPath")
|
||||||
[[ $path2 = $path4 ]]
|
[[ $path2 = $path4 ]]
|
||||||
|
|
||||||
[[ $(nix eval --impure --expr "builtins.hasAttr \"rev\" (builtins.fetchGit $repo)") == "true" ]]
|
[[ $(nix eval --impure --expr "builtins.hasAttr \"rev\" (builtins.fetchGit $repo)") == "true" ]]
|
||||||
|
@ -140,14 +140,14 @@ rev3=$(git -C $repo rev-parse HEAD)
|
||||||
nix eval --tarball-ttl 3600 --expr "builtins.fetchGit { url = $repo; rev = \"$rev3\"; }" >/dev/null
|
nix eval --tarball-ttl 3600 --expr "builtins.fetchGit { url = $repo; rev = \"$rev3\"; }" >/dev/null
|
||||||
|
|
||||||
# Update 'path' to reflect latest master
|
# Update 'path' to reflect latest master
|
||||||
path=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath")
|
path=$(nix eval --impure --raw --expr "(builtins.fetchGit \"file://$repo\").outPath")
|
||||||
|
|
||||||
# Check behavior when non-master branch is used
|
# Check behavior when non-master branch is used
|
||||||
git -C $repo checkout $rev2 -b dev
|
git -C $repo checkout $rev2 -b dev
|
||||||
echo dev > $repo/hello
|
echo dev > $repo/hello
|
||||||
|
|
||||||
# File URI uses dirty tree unless specified otherwise
|
# File URI uses dirty tree unless specified otherwise
|
||||||
path2=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath")
|
path2=$(nix eval --impure --raw --expr "(builtins.fetchGit \"file://$repo\").outPath")
|
||||||
[ $(cat $path2/hello) = dev ]
|
[ $(cat $path2/hello) = dev ]
|
||||||
|
|
||||||
# Using local path with branch other than 'master' should work when clean or dirty
|
# Using local path with branch other than 'master' should work when clean or dirty
|
||||||
|
|
|
@ -40,24 +40,24 @@ initGitRepo $rootRepo
|
||||||
git -C $rootRepo submodule init
|
git -C $rootRepo submodule init
|
||||||
git -C $rootRepo submodule add $subRepo sub
|
git -C $rootRepo submodule add $subRepo sub
|
||||||
git -C $rootRepo add sub
|
git -C $rootRepo add sub
|
||||||
r0=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = file://$rootRepo; }).outPath")
|
r0=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; }).outPath")
|
||||||
git -C $rootRepo commit -m "Add submodule"
|
git -C $rootRepo commit -m "Add submodule"
|
||||||
|
|
||||||
rev=$(git -C $rootRepo rev-parse HEAD)
|
rev=$(git -C $rootRepo rev-parse HEAD)
|
||||||
|
|
||||||
r1=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; }).outPath")
|
r1=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; rev = \"$rev\"; }).outPath")
|
||||||
r2=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; submodules = false; }).outPath")
|
r2=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; rev = \"$rev\"; submodules = false; }).outPath")
|
||||||
r3=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; submodules = true; }).outPath")
|
r3=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; rev = \"$rev\"; submodules = true; }).outPath")
|
||||||
|
|
||||||
[[ $r0 == $r1 ]] # verify that unfetched submodules result in empty directories in dirty mode too
|
[[ $r0 == $r1 ]] # verify that unfetched submodules result in empty directories in dirty mode too
|
||||||
[[ $r1 == $r2 ]]
|
[[ $r1 == $r2 ]]
|
||||||
[[ $r2 != $r3 ]]
|
[[ $r2 != $r3 ]]
|
||||||
|
|
||||||
r4=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; ref = \"master\"; rev = \"$rev\"; }).outPath")
|
r4=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; ref = \"master\"; rev = \"$rev\"; }).outPath")
|
||||||
r5=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; ref = \"master\"; rev = \"$rev\"; submodules = false; }).outPath")
|
r5=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; ref = \"master\"; rev = \"$rev\"; submodules = false; }).outPath")
|
||||||
r6=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; ref = \"master\"; rev = \"$rev\"; submodules = true; }).outPath")
|
r6=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; ref = \"master\"; rev = \"$rev\"; submodules = true; }).outPath")
|
||||||
r7=$(nix eval --raw --expr "(builtins.fetchGit { url = $rootRepo; ref = \"master\"; rev = \"$rev\"; submodules = true; }).outPath")
|
r7=$(nix eval --raw --expr "(builtins.fetchGit { url = \"$rootRepo\"; ref = \"master\"; rev = \"$rev\"; submodules = true; }).outPath")
|
||||||
r8=$(nix eval --raw --expr "(builtins.fetchGit { url = $rootRepo; rev = \"$rev\"; submodules = true; }).outPath")
|
r8=$(nix eval --raw --expr "(builtins.fetchGit { url = \"$rootRepo\"; rev = \"$rev\"; submodules = true; }).outPath")
|
||||||
|
|
||||||
[[ $r1 == $r4 ]]
|
[[ $r1 == $r4 ]]
|
||||||
[[ $r4 == $r5 ]]
|
[[ $r4 == $r5 ]]
|
||||||
|
@ -65,19 +65,19 @@ r8=$(nix eval --raw --expr "(builtins.fetchGit { url = $rootRepo; rev = \"$rev\"
|
||||||
[[ $r6 == $r7 ]]
|
[[ $r6 == $r7 ]]
|
||||||
[[ $r7 == $r8 ]]
|
[[ $r7 == $r8 ]]
|
||||||
|
|
||||||
have_submodules=$(nix eval --expr "(builtins.fetchGit { url = $rootRepo; rev = \"$rev\"; }).submodules")
|
have_submodules=$(nix eval --expr "(builtins.fetchGit { url = \"$rootRepo\"; rev = \"$rev\"; }).submodules")
|
||||||
[[ $have_submodules == false ]]
|
[[ $have_submodules == false ]]
|
||||||
|
|
||||||
have_submodules=$(nix eval --expr "(builtins.fetchGit { url = $rootRepo; rev = \"$rev\"; submodules = false; }).submodules")
|
have_submodules=$(nix eval --expr "(builtins.fetchGit { url = \"$rootRepo\"; rev = \"$rev\"; submodules = false; }).submodules")
|
||||||
[[ $have_submodules == false ]]
|
[[ $have_submodules == false ]]
|
||||||
|
|
||||||
have_submodules=$(nix eval --expr "(builtins.fetchGit { url = $rootRepo; rev = \"$rev\"; submodules = true; }).submodules")
|
have_submodules=$(nix eval --expr "(builtins.fetchGit { url = \"$rootRepo\"; rev = \"$rev\"; submodules = true; }).submodules")
|
||||||
[[ $have_submodules == true ]]
|
[[ $have_submodules == true ]]
|
||||||
|
|
||||||
pathWithoutSubmodules=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; }).outPath")
|
pathWithoutSubmodules=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; rev = \"$rev\"; }).outPath")
|
||||||
pathWithSubmodules=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; submodules = true; }).outPath")
|
pathWithSubmodules=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; rev = \"$rev\"; submodules = true; }).outPath")
|
||||||
pathWithSubmodulesAgain=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; submodules = true; }).outPath")
|
pathWithSubmodulesAgain=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; rev = \"$rev\"; submodules = true; }).outPath")
|
||||||
pathWithSubmodulesAgainWithRef=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; ref = \"master\"; rev = \"$rev\"; submodules = true; }).outPath")
|
pathWithSubmodulesAgainWithRef=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; ref = \"master\"; rev = \"$rev\"; submodules = true; }).outPath")
|
||||||
|
|
||||||
# The resulting store path cannot be the same.
|
# The resulting store path cannot be the same.
|
||||||
[[ $pathWithoutSubmodules != $pathWithSubmodules ]]
|
[[ $pathWithoutSubmodules != $pathWithSubmodules ]]
|
||||||
|
@ -99,8 +99,8 @@ test "$(find "$pathWithSubmodules" -name .git)" = ""
|
||||||
|
|
||||||
# Git repos without submodules can be fetched with submodules = true.
|
# Git repos without submodules can be fetched with submodules = true.
|
||||||
subRev=$(git -C $subRepo rev-parse HEAD)
|
subRev=$(git -C $subRepo rev-parse HEAD)
|
||||||
noSubmoduleRepoBaseline=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$subRepo; rev = \"$subRev\"; }).outPath")
|
noSubmoduleRepoBaseline=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$subRepo\"; rev = \"$subRev\"; }).outPath")
|
||||||
noSubmoduleRepo=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$subRepo; rev = \"$subRev\"; submodules = true; }).outPath")
|
noSubmoduleRepo=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$subRepo\"; rev = \"$subRev\"; submodules = true; }).outPath")
|
||||||
|
|
||||||
[[ $noSubmoduleRepoBaseline == $noSubmoduleRepo ]]
|
[[ $noSubmoduleRepoBaseline == $noSubmoduleRepo ]]
|
||||||
|
|
||||||
|
@ -111,14 +111,14 @@ initGitRepo $rootRepo
|
||||||
git -C $rootRepo submodule add ../gitSubmodulesSub sub
|
git -C $rootRepo submodule add ../gitSubmodulesSub sub
|
||||||
git -C $rootRepo commit -m "Add submodule"
|
git -C $rootRepo commit -m "Add submodule"
|
||||||
rev2=$(git -C $rootRepo rev-parse HEAD)
|
rev2=$(git -C $rootRepo rev-parse HEAD)
|
||||||
pathWithRelative=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev2\"; submodules = true; }).outPath")
|
pathWithRelative=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$rootRepo\"; rev = \"$rev2\"; submodules = true; }).outPath")
|
||||||
diff -r -x .gitmodules $pathWithSubmodules $pathWithRelative
|
diff -r -x .gitmodules $pathWithSubmodules $pathWithRelative
|
||||||
|
|
||||||
# Test clones that have an upstream with relative submodule URLs.
|
# Test clones that have an upstream with relative submodule URLs.
|
||||||
rm $TEST_HOME/.cache/nix/fetcher-cache*
|
rm $TEST_HOME/.cache/nix/fetcher-cache*
|
||||||
cloneRepo=$TEST_ROOT/a/b/gitSubmodulesClone # NB /a/b to make the relative path not work relative to $cloneRepo
|
cloneRepo=$TEST_ROOT/a/b/gitSubmodulesClone # NB /a/b to make the relative path not work relative to $cloneRepo
|
||||||
git clone $rootRepo $cloneRepo
|
git clone $rootRepo $cloneRepo
|
||||||
pathIndirect=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$cloneRepo; rev = \"$rev2\"; submodules = true; }).outPath")
|
pathIndirect=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$cloneRepo\"; rev = \"$rev2\"; submodules = true; }).outPath")
|
||||||
[[ $pathIndirect = $pathWithRelative ]]
|
[[ $pathIndirect = $pathWithRelative ]]
|
||||||
|
|
||||||
# Test that if the clone has the submodule already, we're not fetching
|
# Test that if the clone has the submodule already, we're not fetching
|
||||||
|
@ -126,5 +126,5 @@ pathIndirect=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$cloneRe
|
||||||
git -C $cloneRepo submodule update --init
|
git -C $cloneRepo submodule update --init
|
||||||
rm $TEST_HOME/.cache/nix/fetcher-cache*
|
rm $TEST_HOME/.cache/nix/fetcher-cache*
|
||||||
rm -rf $subRepo
|
rm -rf $subRepo
|
||||||
pathSubmoduleGone=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$cloneRepo; rev = \"$rev2\"; submodules = true; }).outPath")
|
pathSubmoduleGone=$(nix eval --raw --expr "(builtins.fetchGit { url = \"file://$cloneRepo\"; rev = \"$rev2\"; submodules = true; }).outPath")
|
||||||
[[ $pathSubmoduleGone = $pathWithRelative ]]
|
[[ $pathSubmoduleGone = $pathWithRelative ]]
|
||||||
|
|
|
@ -29,48 +29,48 @@ rev2=$(hg log --cwd $repo -r tip --template '{node}')
|
||||||
|
|
||||||
# Fetch an unclean branch.
|
# Fetch an unclean branch.
|
||||||
echo unclean > $repo/hello
|
echo unclean > $repo/hello
|
||||||
path=$(nix eval --impure --raw --expr "(builtins.fetchMercurial file://$repo).outPath")
|
path=$(nix eval --impure --raw --expr "(builtins.fetchMercurial \"file://$repo\").outPath")
|
||||||
[[ $(cat $path/hello) = unclean ]]
|
[[ $(cat $path/hello) = unclean ]]
|
||||||
hg revert --cwd $repo --all
|
hg revert --cwd $repo --all
|
||||||
|
|
||||||
# Fetch the default branch.
|
# Fetch the default branch.
|
||||||
path=$(nix eval --impure --raw --expr "(builtins.fetchMercurial file://$repo).outPath")
|
path=$(nix eval --impure --raw --expr "(builtins.fetchMercurial \"file://$repo\").outPath")
|
||||||
[[ $(cat $path/hello) = world ]]
|
[[ $(cat $path/hello) = world ]]
|
||||||
|
|
||||||
# In pure eval mode, fetchGit without a revision should fail.
|
# In pure eval mode, fetchGit without a revision should fail.
|
||||||
[[ $(nix eval --impure --raw --expr "(builtins.readFile (fetchMercurial file://$repo + \"/hello\"))") = world ]]
|
[[ $(nix eval --impure --raw --expr "(builtins.readFile (fetchMercurial \"file://$repo\" + \"/hello\"))") = world ]]
|
||||||
(! nix eval --raw --expr "builtins.readFile (fetchMercurial file://$repo + \"/hello\")")
|
(! nix eval --raw --expr "builtins.readFile (fetchMercurial \"file://$repo\" + \"/hello\")")
|
||||||
|
|
||||||
# Fetch using an explicit revision hash.
|
# Fetch using an explicit revision hash.
|
||||||
path2=$(nix eval --impure --raw --expr "(builtins.fetchMercurial { url = file://$repo; rev = \"$rev2\"; }).outPath")
|
path2=$(nix eval --impure --raw --expr "(builtins.fetchMercurial { url = \"file://$repo\"; rev = \"$rev2\"; }).outPath")
|
||||||
[[ $path = $path2 ]]
|
[[ $path = $path2 ]]
|
||||||
|
|
||||||
# In pure eval mode, fetchGit with a revision should succeed.
|
# In pure eval mode, fetchGit with a revision should succeed.
|
||||||
[[ $(nix eval --raw --expr "builtins.readFile (fetchMercurial { url = file://$repo; rev = \"$rev2\"; } + \"/hello\")") = world ]]
|
[[ $(nix eval --raw --expr "builtins.readFile (fetchMercurial { url = \"file://$repo\"; rev = \"$rev2\"; } + \"/hello\")") = world ]]
|
||||||
|
|
||||||
# Fetch again. This should be cached.
|
# Fetch again. This should be cached.
|
||||||
mv $repo ${repo}-tmp
|
mv $repo ${repo}-tmp
|
||||||
path2=$(nix eval --impure --raw --expr "(builtins.fetchMercurial file://$repo).outPath")
|
path2=$(nix eval --impure --raw --expr "(builtins.fetchMercurial \"file://$repo\").outPath")
|
||||||
[[ $path = $path2 ]]
|
[[ $path = $path2 ]]
|
||||||
|
|
||||||
[[ $(nix eval --impure --raw --expr "(builtins.fetchMercurial file://$repo).branch") = default ]]
|
[[ $(nix eval --impure --raw --expr "(builtins.fetchMercurial \"file://$repo\").branch") = default ]]
|
||||||
[[ $(nix eval --impure --expr "(builtins.fetchMercurial file://$repo).revCount") = 1 ]]
|
[[ $(nix eval --impure --expr "(builtins.fetchMercurial \"file://$repo\").revCount") = 1 ]]
|
||||||
[[ $(nix eval --impure --raw --expr "(builtins.fetchMercurial file://$repo).rev") = $rev2 ]]
|
[[ $(nix eval --impure --raw --expr "(builtins.fetchMercurial \"file://$repo\").rev") = $rev2 ]]
|
||||||
|
|
||||||
# But with TTL 0, it should fail.
|
# But with TTL 0, it should fail.
|
||||||
(! nix eval --impure --refresh --expr "builtins.fetchMercurial file://$repo")
|
(! nix eval --impure --refresh --expr "builtins.fetchMercurial \"file://$repo\"")
|
||||||
|
|
||||||
# Fetching with a explicit hash should succeed.
|
# Fetching with a explicit hash should succeed.
|
||||||
path2=$(nix eval --refresh --raw --expr "(builtins.fetchMercurial { url = file://$repo; rev = \"$rev2\"; }).outPath")
|
path2=$(nix eval --refresh --raw --expr "(builtins.fetchMercurial { url = \"file://$repo\"; rev = \"$rev2\"; }).outPath")
|
||||||
[[ $path = $path2 ]]
|
[[ $path = $path2 ]]
|
||||||
|
|
||||||
path2=$(nix eval --refresh --raw --expr "(builtins.fetchMercurial { url = file://$repo; rev = \"$rev1\"; }).outPath")
|
path2=$(nix eval --refresh --raw --expr "(builtins.fetchMercurial { url = \"file://$repo\"; rev = \"$rev1\"; }).outPath")
|
||||||
[[ $(cat $path2/hello) = utrecht ]]
|
[[ $(cat $path2/hello) = utrecht ]]
|
||||||
|
|
||||||
mv ${repo}-tmp $repo
|
mv ${repo}-tmp $repo
|
||||||
|
|
||||||
# Using a clean working tree should produce the same result.
|
# Using a clean working tree should produce the same result.
|
||||||
path2=$(nix eval --impure --raw --expr "(builtins.fetchMercurial $repo).outPath")
|
path2=$(nix eval --impure --raw --expr "(builtins.fetchMercurial \"$repo\").outPath")
|
||||||
[[ $path = $path2 ]]
|
[[ $path = $path2 ]]
|
||||||
|
|
||||||
# Using an unclean tree should yield the tracked but uncommitted changes.
|
# Using an unclean tree should yield the tracked but uncommitted changes.
|
||||||
|
@ -81,23 +81,23 @@ echo bar > $repo/dir2/bar
|
||||||
hg add --cwd $repo dir1/foo
|
hg add --cwd $repo dir1/foo
|
||||||
hg rm --cwd $repo hello
|
hg rm --cwd $repo hello
|
||||||
|
|
||||||
path2=$(nix eval --impure --raw --expr "(builtins.fetchMercurial $repo).outPath")
|
path2=$(nix eval --impure --raw --expr "(builtins.fetchMercurial \"$repo\").outPath")
|
||||||
[ ! -e $path2/hello ]
|
[ ! -e $path2/hello ]
|
||||||
[ ! -e $path2/bar ]
|
[ ! -e $path2/bar ]
|
||||||
[ ! -e $path2/dir2/bar ]
|
[ ! -e $path2/dir2/bar ]
|
||||||
[ ! -e $path2/.hg ]
|
[ ! -e $path2/.hg ]
|
||||||
[[ $(cat $path2/dir1/foo) = foo ]]
|
[[ $(cat $path2/dir1/foo) = foo ]]
|
||||||
|
|
||||||
[[ $(nix eval --impure --raw --expr "(builtins.fetchMercurial $repo).rev") = 0000000000000000000000000000000000000000 ]]
|
[[ $(nix eval --impure --raw --expr "(builtins.fetchMercurial \"$repo\").rev") = 0000000000000000000000000000000000000000 ]]
|
||||||
|
|
||||||
# ... unless we're using an explicit ref.
|
# ... unless we're using an explicit ref.
|
||||||
path3=$(nix eval --impure --raw --expr "(builtins.fetchMercurial { url = $repo; rev = \"default\"; }).outPath")
|
path3=$(nix eval --impure --raw --expr "(builtins.fetchMercurial { url = \"$repo\"; rev = \"default\"; }).outPath")
|
||||||
[[ $path = $path3 ]]
|
[[ $path = $path3 ]]
|
||||||
|
|
||||||
# Committing should not affect the store path.
|
# Committing should not affect the store path.
|
||||||
hg commit --cwd $repo -m 'Bla3'
|
hg commit --cwd $repo -m 'Bla3'
|
||||||
|
|
||||||
path4=$(nix eval --impure --refresh --raw --expr "(builtins.fetchMercurial file://$repo).outPath")
|
path4=$(nix eval --impure --refresh --raw --expr "(builtins.fetchMercurial \"file://$repo\").outPath")
|
||||||
[[ $path2 = $path4 ]]
|
[[ $path2 = $path4 ]]
|
||||||
|
|
||||||
echo paris > $repo/hello
|
echo paris > $repo/hello
|
||||||
|
|
|
@ -11,7 +11,7 @@ createGitRepo $flakeB
|
||||||
|
|
||||||
cat > $flakeA/flake.nix <<EOF
|
cat > $flakeA/flake.nix <<EOF
|
||||||
{
|
{
|
||||||
inputs.b.url = git+file://$flakeB;
|
inputs.b.url = "git+file://$flakeB";
|
||||||
inputs.b.inputs.a.follows = "/";
|
inputs.b.inputs.a.follows = "/";
|
||||||
|
|
||||||
outputs = { self, b }: {
|
outputs = { self, b }: {
|
||||||
|
@ -25,7 +25,7 @@ git -C $flakeA add flake.nix
|
||||||
|
|
||||||
cat > $flakeB/flake.nix <<EOF
|
cat > $flakeB/flake.nix <<EOF
|
||||||
{
|
{
|
||||||
inputs.a.url = git+file://$flakeA;
|
inputs.a.url = "git+file://$flakeA";
|
||||||
|
|
||||||
outputs = { self, a }: {
|
outputs = { self, a }: {
|
||||||
bar = 456 + a.xyzzy;
|
bar = 456 + a.xyzzy;
|
||||||
|
|
|
@ -235,11 +235,11 @@ cat > $flake3Dir/flake.nix <<EOF
|
||||||
flake1 = {};
|
flake1 = {};
|
||||||
flake2 = {};
|
flake2 = {};
|
||||||
nonFlake = {
|
nonFlake = {
|
||||||
url = git+file://$nonFlakeDir;
|
url = "git+file://$nonFlakeDir";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
nonFlakeFile = {
|
nonFlakeFile = {
|
||||||
url = path://$nonFlakeDir/README.md;
|
url = "path://$nonFlakeDir/README.md";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
nonFlakeFile2 = {
|
nonFlakeFile2 = {
|
||||||
|
@ -442,7 +442,7 @@ cat > $flake3Dir/flake.nix <<EOF
|
||||||
{
|
{
|
||||||
inputs.flake2.inputs.flake1 = {
|
inputs.flake2.inputs.flake1 = {
|
||||||
type = "git";
|
type = "git";
|
||||||
url = file://$flake7Dir;
|
url = "file://$flake7Dir";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, flake2 }: {
|
outputs = { self, flake2 }: {
|
||||||
|
@ -456,7 +456,7 @@ nix flake lock $flake3Dir
|
||||||
cat > $flake3Dir/flake.nix <<EOF
|
cat > $flake3Dir/flake.nix <<EOF
|
||||||
{
|
{
|
||||||
inputs.flake2.inputs.flake1.follows = "foo";
|
inputs.flake2.inputs.flake1.follows = "foo";
|
||||||
inputs.foo.url = git+file://$flake7Dir;
|
inputs.foo.url = "git+file://$flake7Dir";
|
||||||
|
|
||||||
outputs = { self, flake2 }: {
|
outputs = { self, flake2 }: {
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,7 +21,7 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
builder = /foo/bar;
|
builder = /foo/bar;
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2;
|
url = "http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2";
|
||||||
md5 = "a180c3fe91680389c210c99def54d9e0";
|
md5 = "a180c3fe91680389c210c99def54d9e0";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ echo "$missingImpureErrorMsg" | grepQuiet -- --impure || \
|
||||||
|
|
||||||
(! nix-instantiate --pure-eval ./simple.nix)
|
(! nix-instantiate --pure-eval ./simple.nix)
|
||||||
|
|
||||||
[[ $(nix eval --impure --expr "(import (builtins.fetchurl { url = file://$(pwd)/pure-eval.nix; })).x") == 123 ]]
|
[[ $(nix eval --impure --expr "(import (builtins.fetchurl { url = \"file://$(pwd)/pure-eval.nix\"; })).x") == 123 ]]
|
||||||
(! nix eval --expr "(import (builtins.fetchurl { url = file://$(pwd)/pure-eval.nix; })).x")
|
(! nix eval --expr "(import (builtins.fetchurl { url = \"file://$(pwd)/pure-eval.nix\"; })).x")
|
||||||
nix eval --expr "(import (builtins.fetchurl { url = file://$(pwd)/pure-eval.nix; sha256 = \"$(nix hash file pure-eval.nix --type sha256)\"; })).x"
|
nix eval --expr "(import (builtins.fetchurl { url = \"file://$(pwd)/pure-eval.nix\"; sha256 = \"$(nix hash file pure-eval.nix --type sha256)\"; })).x"
|
||||||
|
|
||||||
rm -rf $TEST_ROOT/eval-out
|
rm -rf $TEST_ROOT/eval-out
|
||||||
nix eval --store dummy:// --write-to $TEST_ROOT/eval-out --expr '{ x = "foo" + "bar"; y = { z = "bla"; }; }'
|
nix eval --store dummy:// --write-to $TEST_ROOT/eval-out --expr '{ x = "foo" + "bar"; y = { z = "bla"; }; }'
|
||||||
|
|
|
@ -17,18 +17,18 @@ nix-instantiate --restrict-eval --eval -E 'builtins.readDir ../../src/nix-channe
|
||||||
(! nix-instantiate --restrict-eval --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in <foo>')
|
(! nix-instantiate --restrict-eval --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in <foo>')
|
||||||
nix-instantiate --restrict-eval --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in <foo>' -I src=.
|
nix-instantiate --restrict-eval --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in <foo>' -I src=.
|
||||||
|
|
||||||
p=$(nix eval --raw --expr "builtins.fetchurl file://$(pwd)/restricted.sh" --impure --restrict-eval --allowed-uris "file://$(pwd)")
|
p=$(nix eval --raw --expr "builtins.fetchurl \"file://$(pwd)/restricted.sh\"" --impure --restrict-eval --allowed-uris "file://$(pwd)")
|
||||||
cmp $p restricted.sh
|
cmp $p restricted.sh
|
||||||
|
|
||||||
(! nix eval --raw --expr "builtins.fetchurl file://$(pwd)/restricted.sh" --impure --restrict-eval)
|
(! nix eval --raw --expr "builtins.fetchurl \"file://$(pwd)/restricted.sh\"" --impure --restrict-eval)
|
||||||
|
|
||||||
(! nix eval --raw --expr "builtins.fetchurl file://$(pwd)/restricted.sh" --impure --restrict-eval --allowed-uris "file://$(pwd)/restricted.sh/")
|
(! nix eval --raw --expr "builtins.fetchurl \"file://$(pwd)/restricted.sh\"" --impure --restrict-eval --allowed-uris "file://$(pwd)/restricted.sh/")
|
||||||
|
|
||||||
nix eval --raw --expr "builtins.fetchurl file://$(pwd)/restricted.sh" --impure --restrict-eval --allowed-uris "file://$(pwd)/restricted.sh"
|
nix eval --raw --expr "builtins.fetchurl \"file://$(pwd)/restricted.sh\"" --impure --restrict-eval --allowed-uris "file://$(pwd)/restricted.sh"
|
||||||
|
|
||||||
(! nix eval --raw --expr "builtins.fetchurl https://github.com/NixOS/patchelf/archive/master.tar.gz" --impure --restrict-eval)
|
(! nix eval --raw --expr "builtins.fetchurl \"https://github.com/NixOS/patchelf/archive/master.tar.gz\"" --impure --restrict-eval)
|
||||||
(! nix eval --raw --expr "builtins.fetchTarball https://github.com/NixOS/patchelf/archive/master.tar.gz" --impure --restrict-eval)
|
(! nix eval --raw --expr "builtins.fetchTarball \"https://github.com/NixOS/patchelf/archive/master.tar.gz\"" --impure --restrict-eval)
|
||||||
(! nix eval --raw --expr "fetchGit git://github.com/NixOS/patchelf.git" --impure --restrict-eval)
|
(! nix eval --raw --expr "fetchGit \"git://github.com/NixOS/patchelf.git\"" --impure --restrict-eval)
|
||||||
|
|
||||||
ln -sfn $(pwd)/restricted.nix $TEST_ROOT/restricted.nix
|
ln -sfn $(pwd)/restricted.nix $TEST_ROOT/restricted.nix
|
||||||
[[ $(nix-instantiate --eval $TEST_ROOT/restricted.nix) == 3 ]]
|
[[ $(nix-instantiate --eval $TEST_ROOT/restricted.nix) == 3 ]]
|
||||||
|
|
|
@ -26,21 +26,21 @@ test_tarball() {
|
||||||
|
|
||||||
nix-build -o $TEST_ROOT/result '<foo>' -I foo=file://$tarball
|
nix-build -o $TEST_ROOT/result '<foo>' -I foo=file://$tarball
|
||||||
|
|
||||||
nix-build -o $TEST_ROOT/result -E "import (fetchTarball file://$tarball)"
|
nix-build -o $TEST_ROOT/result -E "import (fetchTarball \"file://$tarball\")"
|
||||||
# Do not re-fetch paths already present
|
# Do not re-fetch paths already present
|
||||||
nix-build -o $TEST_ROOT/result -E "import (fetchTarball { url = file:///does-not-exist/must-remain-unused/$tarball; sha256 = \"$hash\"; })"
|
nix-build -o $TEST_ROOT/result -E "import (fetchTarball { url = \"file:///does-not-exist/must-remain-unused/$tarball\"; sha256 = \"$hash\"; })"
|
||||||
|
|
||||||
nix-build -o $TEST_ROOT/result -E "import (fetchTree file://$tarball)"
|
nix-build -o $TEST_ROOT/result -E "import (fetchTree \"file://$tarball\")"
|
||||||
nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = file://$tarball; })"
|
nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = \"file://$tarball\"; })"
|
||||||
nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = file://$tarball; narHash = \"$hash\"; })"
|
nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = \"file://$tarball\"; narHash = \"$hash\"; })"
|
||||||
# Do not re-fetch paths already present
|
# Do not re-fetch paths already present
|
||||||
nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = file:///does-not-exist/must-remain-unused/$tarball; narHash = \"$hash\"; })"
|
nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = \"file:///does-not-exist/must-remain-unused/$tarball\"; narHash = \"$hash\"; })"
|
||||||
expectStderr 102 nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = file://$tarball; narHash = \"sha256-xdKv2pq/IiwLSnBBJXW8hNowI4MrdZfW+SYqDQs7Tzc=\"; })" | grep 'NAR hash mismatch in input'
|
expectStderr 102 nix-build -o $TEST_ROOT/result -E "import (fetchTree { type = \"tarball\"; url = \"file://$tarball\"; narHash = \"sha256-xdKv2pq/IiwLSnBBJXW8hNowI4MrdZfW+SYqDQs7Tzc=\"; })" | grep 'NAR hash mismatch in input'
|
||||||
|
|
||||||
[[ $(nix eval --impure --expr "(fetchTree file://$tarball).lastModified") = 1000000000 ]]
|
[[ $(nix eval --impure --expr "(fetchTree \"file://$tarball\").lastModified") = 1000000000 ]]
|
||||||
|
|
||||||
nix-instantiate --strict --eval -E "!((import (fetchTree { type = \"tarball\"; url = file://$tarball; narHash = \"$hash\"; })) ? submodules)" >&2
|
nix-instantiate --strict --eval -E "!((import (fetchTree { type = \"tarball\"; url = \"file://$tarball\"; narHash = \"$hash\"; })) ? submodules)" >&2
|
||||||
nix-instantiate --strict --eval -E "!((import (fetchTree { type = \"tarball\"; url = file://$tarball; narHash = \"$hash\"; })) ? submodules)" 2>&1 | grep 'true'
|
nix-instantiate --strict --eval -E "!((import (fetchTree { type = \"tarball\"; url = \"file://$tarball\"; narHash = \"$hash\"; })) ? submodules)" 2>&1 | grep 'true'
|
||||||
|
|
||||||
nix-instantiate --eval -E '1 + 2' -I fnord=file://no-such-tarball.tar$ext
|
nix-instantiate --eval -E '1 + 2' -I fnord=file://no-such-tarball.tar$ext
|
||||||
nix-instantiate --eval -E 'with <fnord/xyzzy>; 1 + 2' -I fnord=file://no-such-tarball$ext
|
nix-instantiate --eval -E 'with <fnord/xyzzy>; 1 + 2' -I fnord=file://no-such-tarball$ext
|
||||||
|
@ -50,7 +50,7 @@ test_tarball() {
|
||||||
|
|
||||||
# Ensure that the `name` attribute isn’t accepted as that would mess
|
# Ensure that the `name` attribute isn’t accepted as that would mess
|
||||||
# with the content-addressing
|
# with the content-addressing
|
||||||
(! nix-instantiate --eval -E "fetchTree { type = \"tarball\"; url = file://$tarball; narHash = \"$hash\"; name = \"foo\"; }")
|
(! nix-instantiate --eval -E "fetchTree { type = \"tarball\"; url = \"file://$tarball\"; narHash = \"$hash\"; name = \"foo\"; }")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
# fetch the repo via nix
|
# fetch the repo via nix
|
||||||
fetched1 = client.succeed(f"""
|
fetched1 = client.succeed(f"""
|
||||||
nix eval --impure --raw --expr "(builtins.fetchGit {repo.remote}).outPath"
|
nix eval --impure --raw --expr "(builtins.fetchGit \\"{repo.remote}\\").outPath"
|
||||||
""")
|
""")
|
||||||
|
|
||||||
# check if the committed file is there
|
# check if the committed file is there
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
# check if the revision is the same
|
# check if the revision is the same
|
||||||
rev1_fetched = client.succeed(f"""
|
rev1_fetched = client.succeed(f"""
|
||||||
nix eval --impure --raw --expr "(builtins.fetchGit {repo.remote}).rev"
|
nix eval --impure --raw --expr "(builtins.fetchGit \\"{repo.remote}\\").rev"
|
||||||
""").strip()
|
""").strip()
|
||||||
assert rev1 == rev1_fetched, f"rev1: {rev1} != rev1_fetched: {rev1_fetched}"
|
assert rev1 == rev1_fetched, f"rev1: {rev1} != rev1_fetched: {rev1_fetched}"
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in a new issue