]> arthur.barton.de Git - bup.git/blobdiff - test/ext/test-misc
test-misc: be independent of user's git defaultBranch
[bup.git] / test / ext / test-misc
index 5fb96be353e716116298ad69fd2e9923eadbb0e4..433d4f95b637d147dd6948b429648aa61fc2c89b 100755 (executable)
@@ -10,11 +10,14 @@ tmpdir="$(WVPASS wvmktempdir)" || exit $?
 export BUP_DIR="$tmpdir/bup"
 
 bup() { "$top/bup" "$@"; }
+sha1sum() { "$top/dev/checksum" -t sha1 "$@"; }
 
 WVPASS cd "$tmpdir"
 
 WVSTART "init"
 WVPASS bup init
+# Be independent of git defaults or a configured defaultBranch
+git --git-dir "$BUP_DIR" symbolic-ref HEAD refs/heads/main
 D=bupdata.tmp
 WVPASS force-delete $D
 WVPASS mkdir $D
@@ -50,7 +53,7 @@ WVSTART "save/git-fsck"
     #git repack -Ad
     #git prune
     WVPASS bup random 4k | WVPASS bup split -b
-    (WVPASS cd "$top/test/sampledata" && WVPASS bup save -vvn master /) || exit $?
+    (WVPASS cd "$top/test/sampledata" && WVPASS bup save -vvn main /) || exit $?
     result="$(LC_ALL=C git fsck --full --strict 2>&1)" || exit $?
     n=$(echo "$result" |
         WVFAIL egrep -v 'dangling (commit|tree|blob)' |
@@ -60,11 +63,28 @@ WVSTART "save/git-fsck"
 ) || exit $?
 
 
+WVSTART "pack name and idx same as git"
+(
+    # reuse packs from previous test
+    WVPASS cd "$BUP_DIR"/objects/pack/
+    WVPASS ls *.pack
+    for pack in *.pack ; do
+       bup_idx_sha=$(sha1sum $(basename $pack .pack).idx) || exit $?
+       gitname=$(git index-pack $pack) || exit $?
+       # make sure we named it correctly (like git)
+       WVPASSEQ pack-$gitname.pack $pack
+       # make sure we wrote the index correctly
+       git_idx_sha=$(sha1sum $(basename $pack .pack).idx) || exit $?
+       WVPASSEQ "$bup_idx_sha" "$git_idx_sha"
+    done
+) || exit $?
+
+
 WVSTART "ftp"
-WVPASS bup ftp "cat /master/latest/$tmpdir/$D/b" >$D/b.new
-WVPASS bup ftp "cat /master/latest/$tmpdir/$D/f" >$D/f.new
-WVPASS bup ftp "cat /master/latest/$tmpdir/$D/f"{,} >$D/f2.new
-WVPASS bup ftp "cat /master/latest/$tmpdir/$D/a" >$D/a.new
+WVPASS bup ftp "cat /main/latest/$tmpdir/$D/b" >$D/b.new
+WVPASS bup ftp "cat /main/latest/$tmpdir/$D/f" >$D/f.new
+WVPASS bup ftp "cat /main/latest/$tmpdir/$D/f"{,} >$D/f2.new
+WVPASS bup ftp "cat /main/latest/$tmpdir/$D/a" >$D/a.new
 WVPASSEQ "$(sha1sum <$D/b)" "$(sha1sum <$D/b.new)"
 WVPASSEQ "$(sha1sum <$D/f)" "$(sha1sum <$D/f.new)"
 WVPASSEQ "$(cat $D/f.new{,} | sha1sum)" "$(sha1sum <$D/f2.new)"
@@ -75,10 +95,10 @@ WVSTART "tag"
 WVFAIL bup tag -d v0.n 2>/dev/null
 WVFAIL bup tag v0.n non-existant 2>/dev/null
 WVPASSEQ "$(bup tag)" ""
-WVPASS bup tag v0.1 master
+WVPASS bup tag v0.1 main
 WVPASSEQ "$(bup tag)" "v0.1"
-WVFAIL bup tag v0.1 master
-WVPASS bup tag -f v0.1 master
+WVFAIL bup tag v0.1 main
+WVPASS bup tag -f v0.1 main
 WVPASS bup tag -d v0.1
 WVPASS bup tag -f -d v0.1
 WVFAIL bup tag -d v0.1
@@ -123,10 +143,18 @@ c/"
 
 
 WVSTART features
-expect_py_ver=$(LC_CTYPE=C "$top/config/bin/python" \
+expect_py_ver=$(LC_CTYPE=C "$top/dev/python" \
                         -c 'import platform; print(platform.python_version())') \
     || exit $?
 actual_py_ver=$(bup features | grep Python: | sed -Ee 's/ +Python: //') || exit $?
 WVPASSEQ "$expect_py_ver" "$actual_py_ver"
 
+
+WVSTART id-other-than
+result=$("$top/dev/id-other-than" --user 0) ||  exit $?
+WVPASS echo "$result" | WVPASS grep -qE '.*:[0-9]+$'
+result=$("$top/dev/id-other-than" --group 0) ||  exit $?
+WVPASS echo "$result" | WVPASS grep -qE '.*:[0-9]+$'
+
+
 WVPASS rm -rf "$tmpdir"