diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/01-unit.t | 2 | ||||
-rwxr-xr-x | t/05-upgrade.t | 4 | ||||
-rwxr-xr-x | t/11-git.t | 56 | ||||
-rwxr-xr-x | t/22-race.t | 2 | ||||
-rw-r--r-- | t/Test/Sbotools.pm | 6 |
5 files changed, 42 insertions, 28 deletions
diff --git a/t/01-unit.t b/t/01-unit.t index ea5bb33..d94fd9b 100755 --- a/t/01-unit.t +++ b/t/01-unit.t @@ -152,7 +152,7 @@ SKIP: { my $out = capture_merged { $res = SBO::Lib::rsync_sbo_tree('/foo-bar'); }; ok (!$res, q"rsync_sbo_tree('/foo-bar') returned false"); - like ($out, qr!rsync: change_dir "/foo-bar" failed!, q"rsync_sbo_tree('/foo-bar') gave correct output"); + like ($out, qr!rsync: (.*)change_dir "/foo-bar" failed!, q"rsync_sbo_tree('/foo-bar') gave correct output"); } # 28-37: test git_sbo_tree(), check_git_remote(), generate_slackbuilds_txt(), and pull_sbo_tree(); diff --git a/t/05-upgrade.t b/t/05-upgrade.t index 1d7d541..b976d8c 100755 --- a/t/05-upgrade.t +++ b/t/05-upgrade.t @@ -119,9 +119,7 @@ sboupgrade qw/ -f nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr # 13-16: sbosnap + sboupgrade --all my $temp = tempdir(CLEANUP => 1); set_repo("file://$temp"); -capture_merged { system <<"END"; }; -cd $temp; git init; -END +capture_merged { system("cd $temp; git init;"); }; sbosnap 'fetch', { expected => qr/Pulling SlackBuilds tree[.][.][.]/ }; install( 'LO2', 'nonexistentslackbuild' ); my @sbos = glob("/var/log/packages/*_SBo"); @@ -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 { diff --git a/t/22-race.t b/t/22-race.t index 335ef7c..8323a75 100755 --- a/t/22-race.t +++ b/t/22-race.t @@ -94,7 +94,7 @@ GIT $out = capture_merged { $res = SBO::Lib::git_sbo_tree("file://$tempdir"); }; is ($res, 0, 'git_sbo_tree() returned 0'); - is ($out, "fatal: Not a git repository (or any of the parent directories): .git\n", 'git_sbo_tree() gave correct output'); + is ($out, "fatal: not a git repository (or any of the parent directories): .git\n", 'git_sbo_tree() gave correct output'); chdir $cwd; system('rm', '-rf', $repo); diff --git a/t/Test/Sbotools.pm b/t/Test/Sbotools.pm index 7c6d98b..8be5536 100644 --- a/t/Test/Sbotools.pm +++ b/t/Test/Sbotools.pm @@ -62,11 +62,11 @@ sub set_repo { _set_config('REPO', @_); if (-e "/usr/sbo/repo" and not $repo) { $repo = 1; - rename '/usr/sbo/repo', "$RealBin/repo.backup"; + system('mv', '/usr/sbo/repo', "/tmp/repo.backup"); # if $sbt is true, the SLACKBUILDS.TXT has been created by # make_slackbuilds_txt and should not be backed up - if ($sbt) { system('rm', "$RealBin/repo.backup/SLACKBUILDS.TXT"); } + if ($sbt) { system('rm', "/tmp/repo.backup/SLACKBUILDS.TXT"); } } } @@ -142,7 +142,7 @@ END { } if ($repo) { system(qw! rm -rf /usr/sbo/repo !); - rename "$RealBin/repo.backup", "/usr/sbo/repo"; + system('mv', "/tmp/repo.backup", '/usr/sbo/repo'); } if ($tags) { system(qw!rm -rf !, $tags_txt); |