aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-05-18 22:37:10 +0000
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-05-18 22:37:10 +0000
commit0adc7d4b9034c15558916522e31aa2750f729592 (patch)
tree21daf03f54c968e805b68de493ba4c0bd6c74c9f
parent3b9b37a153bd1a8bc75c94e146d00b329deed137 (diff)
downloadsbotools2-0adc7d4b9034c15558916522e31aa2750f729592.tar.xz
11-git.t: rewrite to use Test::Sbotools
-rwxr-xr-xt/11-git.t30
1 files changed, 4 insertions, 26 deletions
diff --git a/t/11-git.t b/t/11-git.t
index cc75e31..f1f9ebe 100755
--- a/t/11-git.t
+++ b/t/11-git.t
@@ -7,8 +7,7 @@ use Test::More;
use Capture::Tiny qw/ capture_merged /;
use FindBin '$RealBin';
use lib $RealBin;
-use lib "$RealBin/../SBO-Lib/lib";
-use Test::Execute;
+use Test::Sbotools qw/ set_repo sbosnap /;
if ($ENV{TEST_INSTALL}) {
plan tests => 3;
@@ -16,32 +15,12 @@ if ($ENV{TEST_INSTALL}) {
plan skip_all => 'Only run these tests if TEST_INSTALL=1';
}
-$path = "$RealBin/../";
-
sub cleanup {
capture_merged {
system(qw!rm -rf !, "$RealBin/gitrepo");
};
}
-sub set_repo {
- state $set = 0;
- state $orig;
- if ($_[0]) {
- if ($set) {
- capture_merged { system(qw!rm -rf /usr/sbo/repo!); system('mv', "$RealBin/repo.backup", "/usr/sbo/repo"); } if -e "$RealBin/repo.backup";
- script (qw/ sboconfig -r /, $orig, { test => 0 });
- }
- } else {
- ($orig) = script (qw/ sboconfig -l /, { expected => qr/REPO=(.*)/, test => 0 });
- $orig //= 'FALSE';
- note "Saving original value of REPO: $orig";
- $set = 1;
- script (qw/ sboconfig -r /, "file://$RealBin/gitrepo/", { test => 0 });
- capture_merged { system(qw! mv /usr/sbo/repo !, "$RealBin/repo.backup"); } if -e "/usr/sbo/repo";
- }
-}
-
sub slurp {
my $file = shift;
local $/;
@@ -61,10 +40,10 @@ git checkout -b b1; echo 'echo "Hello World."' > test; git commit -am 'branch co
git checkout master; echo 'echo "Hello World"' > test; git commit -am 'master commit';
END
-set_repo();
+set_repo("file://$RealBin/gitrepo/");
# 1: sbosnap get initial repo
-script (qw/ sbosnap fetch /, { expected => qr!Pulling SlackBuilds tree.*Cloning into '/usr/sbo/repo'!s });
+sbosnap 'fetch', { expected => qr!Pulling SlackBuilds tree.*Cloning into '/usr/sbo/repo'!s };
# make a conflict
capture_merged { system(<<"END"); };
@@ -72,7 +51,7 @@ cd "$RealBin"; cd gitrepo; git reset --hard b1
END
# 2: sbosnap update through merge conflict
-script (qw/ sbosnap update /, { expected => qr!Updating SlackBuilds tree.*master.*->.*origin/master.*forced update.*HEAD is now at!s });
+sbosnap 'update', { expected => qr!Updating SlackBuilds tree.*master.*->.*origin/master.*forced update.*HEAD is now at!s };
# 3: make sure test repo is merged correctly
is (slurp('/usr/sbo/repo/test'), <<"END", 'repo test file updated correctly');
@@ -81,6 +60,5 @@ END
# Cleanup
END {
- set_repo('delete');
cleanup();
}