diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-08-28 18:34:17 +0200 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-08-28 18:34:17 +0200 |
commit | e77acc913f47bce50ad00fddf484faf6baf92df9 (patch) | |
tree | db4581d1fc0d4053b98aa71ca21cacf46840b9e1 /t/02.1-unit-args.t | |
parent | 9eb86ec4cf83a23cac36adf5289bd65bef1b5b37 (diff) | |
download | sbotools2-e77acc913f47bce50ad00fddf484faf6baf92df9.tar.xz |
02*.t: add another unit test file with new tests
Diffstat (limited to 't/02.1-unit-args.t')
-rwxr-xr-x | t/02.1-unit-args.t | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/t/02.1-unit-args.t b/t/02.1-unit-args.t new file mode 100755 index 0000000..bb70939 --- /dev/null +++ b/t/02.1-unit-args.t @@ -0,0 +1,60 @@ +#!/usr/bin/env perl + +# This should probably replace 01-test.t once it's thorough enough + +use strict; +use warnings; +use Test::More; +use Test::Exit; +use FindBin '$RealBin'; +use lib "$RealBin/../SBO-Lib/lib"; +use SBO::Lib; +use Capture::Tiny qw/ capture_merged /; + +plan tests => 60; + +sub test_args { + my $sub = shift; + my @args = @_; + subtest "Testing $sub exit status when called with too few arguments", sub { + plan tests => 2; + + my $exit; + my $out = capture_merged { $exit = exit_code { SBO::Lib->can("SBO::Lib::$sub")->(@args); }; }; + + is ($exit, 2, "$sub(@args) exited with 2"); + like ($out, qr!\QA fatal script error has occurred:\E\n\Q$sub\E.*\nExiting\.\n!, "$sub(@args) gave correct output"); + } +} + +test_args $_ for qw/ + rsync_sbo_tree git_sbo_tree check_git_remote get_installed_packages get_inst_names + get_sbo_location get_sbo_locations is_local get_orig_location get_orig_version + get_sbo_from_loc get_from_info get_sbo_version get_download_info get_sbo_downloads + get_filename_from_link verify_distfile get_distfile get_symlink_from_filename + check_x32 rewrite_slackbuild revert_slackbuild check_distfiles create_symlinks + get_src_dir get_tmp_extfn perform_sbo do_convertpkg do_slackbuild make_clean + make_distclean do_upgradepkg get_build_queue merge_queues get_readme_contents + get_user_group ask_user_group get_opts ask_opts user_prompt +/; + +test_args 'get_from_info', LOCATION => 1; +test_args 'get_from_info', GET => 1; +test_args 'get_sbo_downloads', LOCATION => $0; +test_args 'compute_md5sum', $RealBin; +test_args 'get_symlink_from_filename', $RealBin, 0; +test_args 'perform_sbo', LOCATION => 1; +test_args 'perform_sbo', ARCH => 1; +test_args 'make_clean', SBO => 1; +test_args 'make_clean', SRC => 1; +test_args 'make_clean', VERSION => 1; +test_args 'make_clean', SBO => 1, SRC => 1; +test_args 'make_clean', SBO => 1, VERSION => 1; +test_args 'make_clean', SRC => 1, VERSION => 1; +test_args 'make_distclean', SRC => 1; +test_args 'make_distclean', VERSION => 1; +test_args 'make_distclean', LOCATION => 1; +test_args 'make_distclean', SRC => 1, VERSION => 1; +test_args 'make_distclean', SRC => 1, LOCATION => 1; +test_args 'make_distclean', VERSION => 1, LOCATION => 1; +test_args 'process_sbos', TODO => []; |