Skip to content

Commit e3fd7d9

Browse files
committed
Add test
1 parent a98b014 commit e3fd7d9

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

tests/functional/flakes/common.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ writeSimpleFlake() {
3232
baseName = builtins.baseNameOf ./.;
3333
3434
root = ./.;
35+
36+
number = 123;
3537
};
3638
}
3739
EOF

tests/functional/flakes/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ suites += {
3636
'trace-ifd.sh',
3737
'build-time-flake-inputs.sh',
3838
'substitution.sh',
39+
'shallow.sh',
3940
],
4041
'workdir' : meson.current_source_dir(),
4142
}

tests/functional/flakes/shallow.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
export _NIX_FORCE_HTTP=1
4+
5+
source ./common.sh
6+
7+
requireGit
8+
9+
createFlake1
10+
11+
repoDir="$TEST_ROOT/repo"
12+
mkdir -p "$repoDir"
13+
echo "# foo" >> "$flake1Dir/flake.nix"
14+
git -C "$flake1Dir" commit -a -m bla
15+
16+
cat > "$repoDir"/flake.nix <<EOF
17+
{
18+
inputs.dep = {
19+
type = "git";
20+
url = "file://$flake1Dir";
21+
};
22+
outputs = inputs: rec {
23+
revs = assert inputs.dep.number == 123; inputs.dep.revCount;
24+
};
25+
}
26+
EOF
27+
28+
# This will do a non-shallow fetch.
29+
[[ $(nix eval "path:$repoDir#revs") = 2 ]]
30+
31+
# This should re-use the existing non-shallow clone.
32+
clearStore
33+
mv "$flake1Dir" "$flake1Dir.moved"
34+
[[ $(nix eval "path:$repoDir#revs") = 2 ]]

0 commit comments

Comments
 (0)