Skip to content

Commit 2068c96

Browse files
committed
modules: Change name only when _GO_PLUGINS_DIR set
The test that first caught this was `modules/main: --imported`. Added the new `modules/use: import builtin module` test case to cover any regression in a more obvious way.
1 parent 529f97c commit 2068c96

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/internal/use

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ for __go_module_name in "$@"; do
147147
# namespace itself is flat, this might lead to hard-to-debug collisions if
148148
# functions and variables get redefined. Keeping a flat module name namespace
149149
# allows us to detect such potential collisions and issue a warning below.
150-
if [[ "$__go_module_file" =~ ^$_GO_PLUGINS_DIR ]]; then
150+
if [[ -n "$_GO_PLUGINS_DIR" &&
151+
"$__go_module_file" =~ ^$_GO_PLUGINS_DIR ]]; then
151152
__go_module_name="${__go_module_file##*/plugins/}"
152153
__go_module_name="${__go_module_name/\/bin\///}"
153154
__go_module_name="${__go_module_name/\/lib\///}"

tests/modules/use.bats

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ teardown() {
8383
assert_success ''
8484
}
8585

86+
@test "$SUITE: import builtin module" {
87+
run "$TEST_GO_SCRIPT" 'complete'
88+
assert_success 'module: complete' \
89+
"source: $_GO_CORE_DIR/lib/complete" \
90+
"caller: $TEST_GO_SCRIPT:3 main"
91+
}
92+
8693
@test "$SUITE: error if nonexistent module specified" {
8794
run "$TEST_GO_SCRIPT" 'bogus-test-module'
8895

0 commit comments

Comments
 (0)