#!/usr/bin/env perl use 5.16.0; use strict; use warnings FATAL => 'all'; use Test::More; use Capture::Tiny qw/ capture_merged /; use FindBin '$RealBin'; use lib $RealBin; use Test::Sbotools qw/ sbosnap set_gpg_verify set_repo set_sbo_home /; use File::Temp 'tempdir'; plan tests => 4; my $usage = <<'SBOSNAP'; Usage: sbosnap [options|command] Options: -h|--help: this screen. -v|--version: version information. Commands: fetch: initialize a local copy of the slackbuilds.org tree. import-key [path or url]: import GPG for verifying the slackbuilds.org tree. Defaults to the key shipped with sbotools2. update: update an existing local copy of the slackbuilds.org tree. (generally, you may prefer "sbocheck" over "sbosnap update") SBOSNAP # 1: sbosnap errors without arguments sbosnap { exit => 1, expected => $usage }; # 2: sbosnap invalid errors sbosnap 'invalid', { exit => 1, expected => $usage }; # 3: sbosnap update when /usr/sbo/repo is empty my $tmp = tempdir(CLEANUP => 1); set_gpg_verify('FALSE'); set_repo("file://$tmp"); capture_merged { system <<"END"; }; cd $tmp git init mkdir test cp -a $RealBin/LO/nonexistentslackbuild test git add test git commit -m 'test' END sbosnap 'update', { expected => qr/Pulling SlackBuilds tree[.][.][.]/ }; # 4-5: sbosnap when SBO_HOME is set my $tmphome = tempdir(CLEANUP => 1); set_sbo_home($tmphome); sbosnap 'fetch', { test => 0, note => 1 }; note scalar `ls -R $tmphome`; ok (-e "$tmphome/repo/test/nonexistentslackbuild/nonexistentslackbuild.info", 'SBo tree pulled to correct location');