@@ -45,7 +45,11 @@ teardown() {
45
45
46
46
@test " $SUITE : error if nonexistent module specified" {
47
47
run " $TEST_GO_SCRIPT " ' bogus-test-module'
48
- assert_failure ' ERROR: Unknown module: bogus-test-module'
48
+
49
+ local expected=(' ERROR: Module bogus-test-module not found at:'
50
+ " $TEST_GO_SCRIPT :3 main" )
51
+ local IFS=$' \n '
52
+ assert_failure " ${expected[*]} "
49
53
}
50
54
51
55
@test " $SUITE : import modules successfully" {
@@ -73,12 +77,33 @@ teardown() {
73
77
}
74
78
75
79
@test " $SUITE : error if module contains errors" {
76
- echo " This is a totally broken module." >> " ${TEST_MODULES[1]} "
80
+ local module=" ${IMPORTS[1]} "
81
+ local module_file=" ${TEST_MODULES[2]} "
82
+
83
+ echo " This is a totally broken module." > " $module_file "
84
+ run " $TEST_GO_SCRIPT " " ${IMPORTS[@]} "
85
+
86
+ local expected=(" ${IMPORTS[0]##*/ } loaded"
87
+ " $module_file : line 1: This: command not found"
88
+ " ERROR: Failed to import $module module from $module_file at:"
89
+ " $TEST_GO_SCRIPT :3 main" )
90
+ local IFS=$' \n '
91
+ assert_failure " ${expected[*]} "
92
+ }
93
+
94
+ @test " $SUITE : error if module returns an error" {
95
+ local module=" ${IMPORTS[1]} "
96
+ local module_file=" ${TEST_MODULES[2]} "
97
+ local error_message=' These violent delights have violent ends...'
98
+
99
+ echo " echo '$error_message ' >&2" > " $module_file "
100
+ echo " return 1" >> " $module_file "
77
101
run " $TEST_GO_SCRIPT " " ${IMPORTS[@]} "
78
102
79
103
local expected=(" ${IMPORTS[0]##*/ } loaded"
80
- " ${TEST_MODULES[1]} : line 2: This: command not found"
81
- " ERROR: Module import failed for: ${TEST_MODULES[1]} " )
104
+ " $error_message "
105
+ " ERROR: Failed to import $module module from $module_file at:"
106
+ " $TEST_GO_SCRIPT :3 main" )
82
107
local IFS=$' \n '
83
108
assert_failure " ${expected[*]} "
84
109
}
0 commit comments