File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -677,6 +677,44 @@ test_expect_success INTERACTIVE 'Interactive tests work' '
677
677
test "$var" = "yes"
678
678
'
679
679
680
+ test_expect_success ' loading of library functions works' '
681
+ # Act as if we have a new installation of sharness with a library of
682
+ # functions, then test that those functions are automatically loaded.
683
+ # Also check that the srcdir is automatically obtained in bash and zsh.
684
+ mkdir lib &&
685
+ (
686
+ cd lib &&
687
+ mkdir -p sharness/lib-sharness &&
688
+ cat >sharness/lib-sharness/functions.sh <<-EOF &&
689
+ test_true() {
690
+ true
691
+ }
692
+ EOF
693
+ ln -sf $SHARNESS_TEST_SRCDIR/sharness.sh sharness &&
694
+ cat >test-lib.t <<-\EOF &&
695
+ test_description="test sharness library"
696
+ . ./sharness/sharness.sh
697
+ test_expect_success "library functions are present" "
698
+ test_true
699
+ "
700
+ test_done
701
+ EOF
702
+ unset SHARNESS_TEST_DIRECTORY SHARNESS_TEST_SRCDIR &&
703
+ if test -z "${BASH_VERSION-}" -a -z "${ZSH_VERSION-}"; then
704
+ SHARNESS_TEST_SRCDIR=sharness &&
705
+ export SHARNESS_TEST_SRCDIR
706
+ fi &&
707
+ chmod +x ./test-lib.t &&
708
+ $SHELL_PATH ./test-lib.t >out 2>err &&
709
+ cat >expected <<-\EOF &&
710
+ ok 1 - library functions are present
711
+ # passed all 1 test(s)
712
+ 1..1
713
+ EOF
714
+ test_cmp expected out
715
+ )
716
+ '
717
+
680
718
test_done
681
719
682
720
# vi: set ft=sh.sharness :
You can’t perform that action at this time.
0 commit comments