File tree Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change 6868# @go modules --imported
6969
7070declare __go_module_name
71+ declare __go_module_file
7172declare __go_loaded_module
7273
7374for __go_module_name in " $@ " ; do
@@ -77,17 +78,28 @@ for __go_module_name in "$@"; do
7778 fi
7879 done
7980
80- # Prevent self- and circular importing.
81+ # Prevent self- and circular importing by registering name before sourcing .
8182 _GO_IMPORTED_MODULES+=(" $__go_module_name " )
83+ __go_module_file=" $_GO_CORE_DIR /lib/$__go_module_name "
8284
83- # Convert <plugin>/<module> to _GO_SCRIPTS_DIR/plugins/<plugin>/lib/<module>
84- if ! . " $_GO_CORE_DIR /lib/$__go_module_name " 2> /dev/null &&
85- ! . " $_GO_SCRIPTS_DIR /plugins/${__go_module_name/ \/ // lib/ } " 2> /dev/null &&
86- ! . " $_GO_SCRIPTS_DIR /lib/$__go_module_name " 2> /dev/null; then
85+ if [[ ! -f " $__go_module_file " ]]; then
86+ # Convert <plugin>/<module> to plugins/<plugin>/lib/<module>
87+ __go_module_file=" $_GO_SCRIPTS_DIR /plugins/${__go_module_name/ \/ // lib/ } "
88+ fi
89+ if [[ ! -f " $__go_module_file " ]]; then
90+ __go_module_file=" $_GO_SCRIPTS_DIR /lib/$__go_module_name "
91+ fi
92+ if [[ ! -f " $__go_module_file " ]]; then
8793 @go.printf " ERROR: Unknown module: $__go_module_name " >&2
8894 exit 1
8995 fi
96+
97+ if ! . " $__go_module_file " ; then
98+ @go.printf " ERROR: Module contains errors: $__go_module_file " >&2
99+ exit 1
100+ fi
90101done
91102
92103unset __go_loaded_module
104+ unset __go_module_file
93105unset __go_module_name
Original file line number Diff line number Diff line change @@ -71,3 +71,14 @@ teardown() {
7171 local IFS=$' \n '
7272 assert_success " ${EXPECTED[*]} "
7373}
74+
75+ @test " $SUITE : error if module contains errors" {
76+ echo " This is a totally broken module." >> " ${TEST_MODULES[1]} "
77+ run " $TEST_GO_SCRIPT " " ${IMPORTS[@]} "
78+
79+ local expected=(" ${IMPORTS[0]##*/ } loaded"
80+ " ${TEST_MODULES[1]} : line 2: This: command not found"
81+ " ERROR: Module contains errors: ${TEST_MODULES[1]} " )
82+ local IFS=$' \n '
83+ assert_failure " ${expected[*]} "
84+ }
You can’t perform that action at this time.
0 commit comments