diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-04-13 23:38:12 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-04-19 19:39:55 +0300 |
commit | f2f08e0758243a820fe47128ffabaa474c0e86e7 (patch) | |
tree | 45563c74dbbf7a0f546443b469a23541c9ac9b00 /tests/rep-fetch-git-refname.test | |
parent | e958b63712f9a0ff4b523765d2fe12b58aa97fe0 (diff) |
Implement git repository handling transition (phase 0)
Diffstat (limited to 'tests/rep-fetch-git-refname.test')
-rw-r--r-- | tests/rep-fetch-git-refname.test | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/tests/rep-fetch-git-refname.test b/tests/rep-fetch-git-refname.test new file mode 100644 index 0000000..ca1e0ff --- /dev/null +++ b/tests/rep-fetch-git-refname.test @@ -0,0 +1,148 @@ +# file : tests/rep-fetch-git-refname.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: fetch +: +{ + $clone_root_cfg && $rep_add "$rep/state0/libfoo.git$fragment"; + + if ($git_protocol == 'https-dumb') + warn = "$warn_ref_hist$reason_dumb$warn_dumb" + end; + + $* 2>>~"%EOE%" + %fetching git:.+libfoo$fragment% + %querying .+libfoo\.git% + $warn + %fetching from .+libfoo\.git% + 1 package\(s\) in 1 repository\(s\) + EOE +} + +: re-fetch +: +{ + : unchanged + : + { + $clone_root_cfg && $rep_add "$rep/state0/libfoo.git$fragment"; + + $* 2>!; + + $* 2>>~"%EOE%" + %fetching git:.+libfoo$fragment% + %querying .+libfoo\.git% + 1 package\(s\) in 1 repository\(s\) + EOE + } + + : changed + : + { + g = git -C + u = "$rep_git/state1" + d = cfg/libfoo-1.0.0 + + $clone_root_cfg && $rep_add "$rep/state0/libfoo.git$fragment"; + + # Extract the repository path from the output line like this: + # + # fetching from <url> in 'cfg/.bpkg/tmp/4bde15f59461'... + # + $* --verbose 2 2>&1 | \ + sed -n -e "s/fetching from .+ in '\(.+\)'/\$1/p" | \ + sed -n -e 's%(.+[\\/])tmp([\\/].+)%$1repos$2%p' | \ + set r; + + # Note that the commit for doc/style/basic submodule is not at the branch + # tip and so is not advertised. + # + warn1 = '%.{0}'; + warn2 = '%.{0}'; + warn3 = '%.{0}'; + + if ($git_protocol == 'local' || \ + $git_protocol == 'https-smart' || \ + $git_protocol == 'git') + warn2 = "$warn_repo_hist for submodule 'doc/style/basic'$reason_unadv" + elif ($git_protocol == 'https-dumb') + warn1 = "$warn_ref_hist for submodule 'doc/style'$reason_dumb$warn_dumb" + warn2 = "$warn_repo_hist for submodule 'doc/style/basic'$reason_dumb$warn_dumb" + warn3 = "$warn_ref_hist for submodule 'libbar'$reason_dumb$warn_dumb" + end; + + $pkg_checkout libfoo/1.0.0 2>>~"%EOE%"; + checking out libfoo/1.0.0 + %querying .+style\.git%? + $warn1 + %fetching submodule 'doc/style' from .+style\.git% + %submodule path 'doc/style': checked out .+% + %querying .+style-basic\.git%? + $warn2 + %fetching submodule 'doc/style/basic' from .+style-basic\.git% + %submodule path 'doc/style/basic': checked out .+% + %querying .+libbar\.git%? + $warn3 + %fetching submodule 'libbar' from .+libbar\.git% + %submodule path 'libbar': checked out .+% + distributing libfoo/1.0.0 + checked out libfoo/1.0.0 + EOE + + $g "$r" config remote.origin.url "$u/libfoo.git"; + + # Preconditions. + # + test -f $d/tests/TODO; + test -f $d/libbar/libbar/manifest; + test -f $d/doc/style/README != 0; + test -d $d/libbaz != 0; + + if ($git_protocol == 'https-dumb') + warn = "$warn_ref_hist$reason_dumb$warn_dumb" + end; + + $* 2>>~"%EOE%" 1>&2; + %fetching git:.+libfoo$fragment% + %querying .+libfoo\.git% + $warn + %fetching from .+libfoo\.git% + %warning: unable to rmdir .?libbar.?: .+% + 1 package\(s\) in 1 repository\(s\) + EOE + + $pkg_drop libfoo; + + warn1 = '%.{0}'; + warn2 = '%.{0}'; + + if ($git_protocol == 'https-dumb') + warn1 = "$warn_ref_hist for submodule 'doc/style'$reason_dumb$warn_dumb" + warn2 = "$warn_ref_hist for submodule 'libbaz'$reason_dumb$warn_dumb" + end; + + $pkg_checkout libfoo/1.0.0 2>>~"%EOE%"; + checking out libfoo/1.0.0 + %querying .+style\.git%? + $warn1 + %fetching submodule 'doc/style' from .+style\.git% + %submodule path 'doc/style': checked out .+% + %querying .+libbaz\.git%? + $warn2 + %fetching submodule 'libbaz' from .+libbaz\.git% + %submodule path 'libbaz': checked out .+% + distributing libfoo/1.0.0 + checked out libfoo/1.0.0 + EOE + + # Postconditions. + # + test -d $d/tests != 0; + test -d $d/libbar != 0; + test -f $d/doc/style/README; + test -f $d/libbaz/manifest; + + $pkg_drop libfoo + } +} |