test_shellm_source.bats
1 load data 2 3 @test "shellm source fails with no arguments" { 4 run shellm source 5 assert_failure 6 assert_line -n 0 "usage: shellm source [-hf] <LIBRARY>" 7 } 8 9 @test "shellm source sources a library only once" { 10 double_source() { 11 shellm source some_lib 12 shellm source some_lib 13 } 14 15 run double_source 16 assert_success 17 assert_output "I've been sourced!" 18 } 19 20 @test "shellm source fails to source inexistant library" { 21 run shellm source inexistent 22 assert_failure 23 assert_output "shellm: source: no such file in LIBPATH: 'inexistent'" 24 } 25 26 @test "shellm source return error code from failing library" { 27 run shellm source failing_lib 28 assert_failure 45 29 assert_output "shellm: source: error while sourcing '${BATS_TEST_DIRNAME}/fixtures/lib/failing_lib'" 30 } 31 32 @test "shellm source prints help with -h option" { 33 skip "not ready" 34 run shellm source -h 35 assert_success 36 assert_output "" 37 } 38 39 @test "shellm source forces re-sourcing of library with -f option" { 40 double_source() { 41 shellm source some_lib 42 shellm source -f some_lib 43 } 44 45 run double_source 46 assert_success 47 assert_line -n 0 "I've been sourced!" 48 assert_line -n 1 "I've been sourced!" 49 } 50 51 @test "shellm source with directory sources files in lib subdir" { 52 run shellm source some_dir_lib 53 assert_success 54 assert_line -n 0 "file 1" 55 assert_line -n 1 "file 2" 56 }