diff options
Diffstat (limited to 't/11-git.t')
-rwxr-xr-x | t/11-git.t | 56 |
1 files changed, 36 insertions, 20 deletions
@@ -16,13 +16,13 @@ if ($ENV{TEST_INSTALL}) { } sub cleanup { - capture_merged { - system(qw!rm -rf !, "$RealBin/gitrepo"); - if (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true') { - system(qw!userdel test!); - system(qw!groupdel test!); - } - }; + capture_merged { + system(qw!rm -rf !, "/tmp/gitrepo"); + if (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true') { + system(qw!userdel test!); + system(qw!groupdel test!); + } + }; } sub slurp { @@ -37,22 +37,35 @@ cleanup(); # initialise repo capture_merged { system(<<"END"); }; -cd "$RealBin"; rm -rf gitrepo; mkdir gitrepo; cd gitrepo; +rm -fr /tmp/gitrepo; +mkdir -p /tmp/gitrepo; +cd /tmp/gitrepo; + git init; -echo "echo Hello" > test; git add test; git commit -m 'initial'; -git checkout -b b1; echo 'echo "Hello World."' > test; git commit -am 'branch commit'; -git checkout master; echo 'echo "Hello World"' > test; git commit -am 'master commit'; +echo -n "Hello" > test; +git add test; +git commit -m 'initial'; + +git checkout -b b1; +echo -n "Hello World." > test; +git commit -am 'branch commit'; + +git checkout master; +echo -n "Hello World" > test; +git commit -am 'master commit'; END if (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true') { capture_merged { system(<<"END"); }; groupadd -g 199 test useradd -u 199 -g 199 -d /tmp test -chown -R 199:199 $RealBin/gitrepo +chown -R 199:199 /tmp/gitrepo + +git config --system --add safe.directory /tmp/gitrepo/.git END } -set_repo("$RealBin/gitrepo/"); +set_repo("/tmp/gitrepo/"); # 1: sbosnap get initial repo sbosnap 'fetch', { expected => qr!Pulling SlackBuilds tree.*Cloning into '/usr/sbo/repo'!s }; @@ -61,25 +74,28 @@ sbosnap 'fetch', { expected => qr!Pulling SlackBuilds tree.*Cloning into '/usr/s SKIP: { skip "Only run under Travis CI", 2 unless defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true'; - my @fnames = glob "$RealBin/gitrepo/.git/objects/*/*"; + my @fnames = glob "/tmp/gitrepo/.git/objects/*/*"; my @stat = stat shift @fnames; - is ($stat[4], 199, "Correct owner uid for $RealBin/gitrepo"); - is ($stat[5], 199, "Correct owner gid for $RealBin/gitrepo"); + is ($stat[4], 199, "Correct owner uid for /tmp/gitrepo"); + is ($stat[5], 199, "Correct owner gid for /tmp/gitrepo"); } # make a conflict capture_merged { system(<<"END"); }; -cd "$RealBin"; cd gitrepo; git reset --hard b1 +cd /tmp/gitrepo +if find /tmp/gitrepo . -maxdepth 0 -user test; then + sudo -u test git reset --hard b1 +else + git reset --hard b1 +fi END # 4: sbosnap update through merge conflict sbosnap 'update', { expected => qr!Updating SlackBuilds tree.*master.*->.*origin/master.*forced update.*HEAD is now at!s }; # 5: make sure test repo is merged correctly -is (slurp('/usr/sbo/repo/test'), <<"END", 'repo test file updated correctly'); -echo "Hello World." -END +is (slurp('/usr/sbo/repo/test'), 'Hello World.', 'repo test file updated correctly'); # Cleanup END { |