From 982916a05ab73f8ca113d45a6ddabcd09f481de5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 11 Feb 2019 22:22:43 +0300 Subject: Implement git repository working tree fix up for package checkout on Windows --- tests/common/git/init | 96 ++++++++++++++++ tests/common/git/pack | 1 + tests/common/git/state0/libbar.tar | Bin 81920 -> 81920 bytes tests/common/git/state0/libfoo.tar | Bin 327680 -> 327680 bytes tests/common/git/state0/libfox.tar | Bin 143360 -> 143360 bytes tests/common/git/state0/links.tar | Bin 0 -> 276480 bytes tests/common/git/state0/style-basic.tar | Bin 71680 -> 71680 bytes tests/common/git/state0/style.tar | Bin 143360 -> 143360 bytes tests/common/git/state1/libbaz.tar | Bin 61440 -> 61440 bytes tests/common/git/state1/libfoo.tar | Bin 409600 -> 409600 bytes tests/common/git/state1/libfox.tar | Bin 143360 -> 143360 bytes tests/common/git/state1/style-basic.tar | Bin 71680 -> 71680 bytes tests/common/git/state1/style.tar | Bin 143360 -> 143360 bytes tests/pkg-checkout.testscript | 196 +++++++++++++++++++++++++------- tests/pkg-checkout/git/links.tar | 1 + tests/pkg-checkout/git/style.tar | 1 + 16 files changed, 253 insertions(+), 42 deletions(-) create mode 100644 tests/common/git/state0/links.tar create mode 120000 tests/pkg-checkout/git/links.tar create mode 120000 tests/pkg-checkout/git/style.tar (limited to 'tests') diff --git a/tests/common/git/init b/tests/common/git/init index 4fac21e..5153175 100755 --- a/tests/common/git/init +++ b/tests/common/git/init @@ -42,6 +42,18 @@ fi # cd state0 +rm -f -r links.git/.git +rm -f links.git/.gitmodules +rm -f links.git/bl +rm -f links.git/lc +rm -f links.git/pg +rm -f links.git/bs +rm -f links.git/bf +rm -f links.git/tl +rm -f links.git/td +rm -f links.git/ts +rm -f -r links.git/doc/style + rm -f -r libfoo.git/.git rm -f libfoo.git/.gitmodules rm -f libfoo.git/README @@ -156,6 +168,86 @@ git -C libfox.git submodule add ../libbar.git libbar git -C libfox.git submodule update --init --recursive # Recursive for safety. git -C libfox.git commit -am 'Create' +# Create master branch for links.git, adding style.git as a submodule. +# +git -C links.git init + +cat <links.git/manifest +: 1 +name: links +version: 0.0.1 +summary: links +license: MIT +url: http://example.org +email: pkg@example.org +EOF + +git -C links.git add '*' +git -C links.git submodule add ../style.git doc/style +git -C links.git submodule update --init --recursive # Updates doc/style/basic. +git -C links.git commit -am 'Create' +git -C links.git tag -a 'v0.0.1' -m 'Tag version 0.0.1' + +# Increase links version and add symlinks. +# +cat <links.git/manifest +: 1 +name: links +version: 1.0.0-a.0.z +summary: links +license: MIT +url: http://example.org +email: pkg@example.org +EOF + +ln -s tests links.git/ts # Directory symlink. +ln -s ts/TODO links.git/td # File symlink via directory symlink. +ln -s td links.git/tl # Symlink symlink. +ln -s doc/style/buildfile links.git/bf # Submodule file symlink. +ln -s doc/style/basic links.git/bs # Submodule directory symlink. +ln -s bs/page.css links.git/pg # Symlink via submodule directory symlink. + +git -C links.git add '*' +git -C links.git commit -am 'Add symlinks' +git -C links.git tag -a 'v1.0.0-alpha' -m 'Tag version 1.0.0-alpha' + +# Increase links version and add dangling symlink. +# +cat <links.git/manifest +: 1 +name: links +version: 1.0.1 +summary: links +license: MIT +url: http://example.org +email: pkg@example.org +EOF + +ln -s lc links.git/bl # Dangling symlink. + +git -C links.git add '*' +git -C links.git commit -am 'Add dangling symlinks' +git -C links.git tag -a 'v1.0.1' -m 'Tag version 1.0.1' + +# Increase links version and add cyclic symlink. +# +cat <links.git/manifest +: 1 +name: links +version: 1.0.2 +summary: links +license: MIT +url: http://example.org +email: pkg@example.org +EOF + +ln -s bl links.git/lc # Cyclic symlink. + +git -C links.git add '*' +git -C links.git commit -am 'Add cyclic symlinks' +git -C links.git tag -a 'v1.0.2' -m 'Tag version 1.0.2' + + # Create the modified state of the repositories, replacing libbar.git submodule # of libfoo with the newly created libbaz.git repository. Also advance master # branches and tags for libfoo.git and it's submodule style.git. @@ -169,6 +261,10 @@ for d in ../state0/*.git; do cp -r $d . done +# Drop the links.git repository. +# +rm -f -r links.git/ + # Create libbaz.git repository. # rm -f -r libbaz.git/.git diff --git a/tests/common/git/pack b/tests/common/git/pack index f9d9772..fd0b49c 100755 --- a/tests/common/git/pack +++ b/tests/common/git/pack @@ -15,6 +15,7 @@ function error () { info "$*"; exit 1; } projects=(\ state0/libfoo state0/libfox state0/libbar state0/style state0/style-basic \ + state0/links \ state1/libfoo state1/libfox state1/libbaz state1/style state1/style-basic) for p in "${projects[@]}"; do diff --git a/tests/common/git/state0/libbar.tar b/tests/common/git/state0/libbar.tar index 2e1a3ad..027112c 100644 Binary files a/tests/common/git/state0/libbar.tar and b/tests/common/git/state0/libbar.tar differ diff --git a/tests/common/git/state0/libfoo.tar b/tests/common/git/state0/libfoo.tar index 6a0cc8a..96a9f5b 100644 Binary files a/tests/common/git/state0/libfoo.tar and b/tests/common/git/state0/libfoo.tar differ diff --git a/tests/common/git/state0/libfox.tar b/tests/common/git/state0/libfox.tar index a73f460..fc2c391 100644 Binary files a/tests/common/git/state0/libfox.tar and b/tests/common/git/state0/libfox.tar differ diff --git a/tests/common/git/state0/links.tar b/tests/common/git/state0/links.tar new file mode 100644 index 0000000..33c5dbf Binary files /dev/null and b/tests/common/git/state0/links.tar differ diff --git a/tests/common/git/state0/style-basic.tar b/tests/common/git/state0/style-basic.tar index 36d0dcd..8b57bd0 100644 Binary files a/tests/common/git/state0/style-basic.tar and b/tests/common/git/state0/style-basic.tar differ diff --git a/tests/common/git/state0/style.tar b/tests/common/git/state0/style.tar index 7b48a9d..56e29f0 100644 Binary files a/tests/common/git/state0/style.tar and b/tests/common/git/state0/style.tar differ diff --git a/tests/common/git/state1/libbaz.tar b/tests/common/git/state1/libbaz.tar index 1b35ec4..7acf277 100644 Binary files a/tests/common/git/state1/libbaz.tar and b/tests/common/git/state1/libbaz.tar differ diff --git a/tests/common/git/state1/libfoo.tar b/tests/common/git/state1/libfoo.tar index ab694f7..532e974 100644 Binary files a/tests/common/git/state1/libfoo.tar and b/tests/common/git/state1/libfoo.tar differ diff --git a/tests/common/git/state1/libfox.tar b/tests/common/git/state1/libfox.tar index a6ef40e..ec49a86 100644 Binary files a/tests/common/git/state1/libfox.tar and b/tests/common/git/state1/libfox.tar differ diff --git a/tests/common/git/state1/style-basic.tar b/tests/common/git/state1/style-basic.tar index 7b7a6c5..1946606 100644 Binary files a/tests/common/git/state1/style-basic.tar and b/tests/common/git/state1/style-basic.tar differ diff --git a/tests/common/git/state1/style.tar b/tests/common/git/state1/style.tar index e6243f4..769b6d5 100644 Binary files a/tests/common/git/state1/style.tar and b/tests/common/git/state1/style.tar differ diff --git a/tests/pkg-checkout.testscript b/tests/pkg-checkout.testscript index 148dcff..a284f6b 100644 --- a/tests/pkg-checkout.testscript +++ b/tests/pkg-checkout.testscript @@ -11,6 +11,8 @@ # |-- libbar.git -> style-basic.git (prerequisite) # `-- style-basic.git +posix = ($cxx.target.class != 'windows') + # Prepare repositories used by tests if running in the local mode. # +if ($remote != true) @@ -19,6 +21,11 @@ $git_extract $src/git/libbar.tar $git_extract $src/git/style-basic0.tar &$out_git/state0/*** $git_extract $src/git/style-basic1.tar &$out_git/state1/*** + + if $posix + $git_extract $src/git/style.tar + $git_extract $src/git/links.tar + end end : git-rep @@ -39,67 +46,172 @@ else pkg_purge += -d cfg 2>! pkg_status += -d cfg - test.cleanups += &cfg/.bpkg/repos/*/*** + test.cleanups += &?cfg/.bpkg/repos/*/*** : unconfigured-dependency : - $clone_root_cfg; - $rep_add "$rep/libbar.git#master"; - $rep_fetch; - - $* libmbar/1.0.0 2>>EOE != 0 - error: no configured package satisfies dependency on style-basic >= 1.0.0 - EOE + { + $clone_root_cfg; + $rep_add "$rep/libbar.git#master"; + $rep_fetch; + + $* libmbar/1.0.0 2>>EOE != 0 + error: no configured package satisfies dependency on style-basic >= 1.0.0 + warning: repository state is now broken + info: run 'bpkg rep-fetch' to repair + EOE + } : configured-dependency : - $clone_root_cfg; - $rep_add "$rep/libbar.git#master" && $rep_add "$rep/style-basic.git#master"; - $rep_fetch; + { + $clone_root_cfg; + $rep_add "$rep/libbar.git#master" && $rep_add "$rep/style-basic.git#master"; + $rep_fetch; - $pkg_status style-basic | sed -n -e 's/style-basic available \[.+\] ([^ ]+)/\1/p' | set v; + $pkg_status style-basic | sed -n -e 's/style-basic available \[.+\] ([^ ]+)/\1/p' | set v; - $* "style-basic/$v" 2>>"EOE"; - distributing style-basic/$v - checked out style-basic/$v - EOE + $* "style-basic/$v" 2>>"EOE"; + distributing style-basic/$v + checked out style-basic/$v + EOE - $pkg_configure style-basic; + $pkg_configure style-basic; - $* libmbar/1.0.0 2>>EOE; - distributing libmbar/1.0.0 - checked out libmbar/1.0.0 - EOE + $* libmbar/1.0.0 2>>EOE; + distributing libmbar/1.0.0 + checked out libmbar/1.0.0 + EOE - $pkg_disfigure style-basic; + $pkg_disfigure style-basic; - $pkg_purge libmbar; - $pkg_purge style-basic + $pkg_purge libmbar; + $pkg_purge style-basic + } : replacement : - # @@ Reduce to a single repository when multiple revisions can be specified - # in the repository URL fragment. - # - rep0 = "$rep_git/state0"; - rep1 = "$rep_git/state1"; + { + # @@ Reduce to a single repository when multiple revisions can be specified + # in the repository URL fragment. + # + rep0 = "$rep_git/state0"; + rep1 = "$rep_git/state1"; + + $clone_root_cfg; + $rep_add "$rep0/style-basic.git#master"; + $rep_add "$rep1/style-basic.git#stable"; + $rep_fetch; - $clone_root_cfg; - $rep_add "$rep0/style-basic.git#master"; - $rep_add "$rep1/style-basic.git#stable"; - $rep_fetch; + $pkg_status style-basic | \ + sed -n -e 's/style-basic available ([^ ]+) +([^ ]+)/\1 \2/p' | set vs; - $pkg_status style-basic | \ - sed -n -e 's/style-basic available ([^ ]+) +([^ ]+)/\1 \2/p' | set vs; + echo "$vs" | sed -e 's/([^ ]+).+/\1/' | set v0; + echo "$vs" | sed -e 's/([^ ]+) +([^ ]+)/\2/' | set v1; - echo "$vs" | sed -e 's/([^ ]+).+/\1/' | set v0; - echo "$vs" | sed -e 's/([^ ]+) +([^ ]+)/\2/' | set v1; + $* "style-basic/$v0" 2>!; + $pkg_status style-basic >~"/style-basic unpacked $v0/"; - $* "style-basic/$v0" 2>!; - $pkg_status style-basic >~"/style-basic unpacked $v0/"; + $* --replace "style-basic/$v1" 2>!; + $pkg_status style-basic >~"/style-basic unpacked $v1 .+/"; - $* --replace "style-basic/$v1" 2>!; - $pkg_status style-basic >~"/style-basic unpacked $v1 .+/"; + $pkg_purge style-basic + } - $pkg_purge style-basic + : links + : + if ($remote == true || $posix) + { + $clone_root_cfg; + + $rep_fetch "$rep/links.git#v1.0.0-alpha"; + + $pkg_status links | sed -n -e 's/links available (.+)/\1/p' | set v; + + $* "links/$v" 2>>~%EOE%; + %.* + %checking out links/1.0.0-a.0.[^.]+.[^.]+%d + %.* + %distributing links/1.0.0-a.0.[^.]+.[^.]+%d + %checked out links/1.0.0-a.0.[^.]+.[^.]+%d + EOE + + d = "cfg/links-$v"; + + # See common/git/init script for the symlinks descriptions. + # + test -d $d/bs; + test -d $d/ts; + + cat $d/pg >'h1 {font-size: 3em;}'; + cat $d/bs/page.css >'h1 {font-size: 3em;}'; + cat $d/bf >'./: file{manifest}'; + cat $d/td >'@@'; + cat $d/tl >'@@'; + cat $d/ts/TODO >'@@'; + + $pkg_purge links; + $rep_fetch "$rep/links.git#v0.0.1"; + + $* links/0.0.1 2>>~%EOE%; + checking out links/0.0.1 + distributing links/0.0.1 + checked out links/0.0.1 + EOE + + d = cfg/links-0.0.1; + + test -d $d/bs == 1; + test -d $d/ts == 1; + test -f $d/pg == 1; + test -f $d/bf == 1; + test -f $d/td == 1; + test -f $d/tl == 1; + + $pkg_purge links; + + # Dangling symlink in the repository. + # + $rep_fetch "$rep/links.git#v1.0.1"; + + if $posix + $* links/1.0.1 2>>~%EOE% + checking out links/1.0.1 + distributing links/1.0.1 + checked out links/1.0.1 + EOE + + $pkg_purge links + else + $* links/1.0.1 2>>~%EOE% != 0 + checking out links/1.0.1 + error: target 'bl' for symlink 'lc' does not exist + info: re-run with -v for more information + warning: repository state is now broken + info: run 'bpkg rep-fetch' to repair + EOE + end; + + # Cyclic symlinks in the repository. + # + if $posix + $rep_fetch "$rep/links.git#v1.0.2" 2>>~%EOE% != 0 + %.* + %error: unable to iterate over .+% + warning: repository state is now broken and will be cleaned up + info: run 'bpkg rep-fetch' to update + EOE + else + $rep_fetch "$rep/links.git#v1.0.2" + + $* links/1.0.2 2>>~%EOE% != 0 + checking out links/1.0.2 + %.* + %error: target '..' for symlink '..' does not exist% + info: re-run with -v for more information + warning: repository state is now broken + info: run 'bpkg rep-fetch' to repair + EOE + end + } } diff --git a/tests/pkg-checkout/git/links.tar b/tests/pkg-checkout/git/links.tar new file mode 120000 index 0000000..63545fe --- /dev/null +++ b/tests/pkg-checkout/git/links.tar @@ -0,0 +1 @@ +../../common/git/state0/links.tar \ No newline at end of file diff --git a/tests/pkg-checkout/git/style.tar b/tests/pkg-checkout/git/style.tar new file mode 120000 index 0000000..948d152 --- /dev/null +++ b/tests/pkg-checkout/git/style.tar @@ -0,0 +1 @@ +../../common/git/state0/style.tar \ No newline at end of file -- cgit v1.1