@@ -54,6 +54,44 @@ teardown() {
5454 assert_success " $TEST_GO_PLUGINS_DIR /$module_path " ' foo/foo' ' bar/bar'
5555}
5656
57+ @test " $SUITE : @go plugins from own module shows plugin's own plugin" {
58+ @go.create_test_command_script " plugins/foo/lib/foo" " @go plugins --paths"
59+ @go.create_test_command_script ' plugins/foo/bin/plugins/bar/bin/bar' \
60+ " $PRINT_SOURCE "
61+
62+ run " $TEST_GO_SCRIPT " ' foo/foo'
63+ assert_success
64+
65+ # @go plugins will import additional modules, so only check the first
66+ assert_line_equals 0 ' bar bin/plugins/bar/bin/bar'
67+ assert_line_equals 1 ' foo/foo'
68+ }
69+
70+ @test " $SUITE : plugin's own module can execute own command script" {
71+ @go.create_test_command_script " plugins/foo/lib/foo" " @go bar"
72+ @go.create_test_command_script ' plugins/foo/bin/bar' " $PRINT_SOURCE "
73+
74+ run " $TEST_GO_SCRIPT " ' foo/foo'
75+ assert_success " $TEST_GO_PLUGINS_DIR /foo/bin/bar" ' foo/foo'
76+ }
77+
78+ @test " $SUITE : plugin's own module can execute own plugin script" {
79+ local plugin_path=' foo/bin/plugins/bar/bin/bar'
80+ @go.create_test_command_script " plugins/foo/lib/foo" " @go bar"
81+ @go.create_test_command_script " plugins/$plugin_path " " $PRINT_SOURCE "
82+
83+ run " $TEST_GO_SCRIPT " ' foo/foo'
84+ assert_success " $TEST_GO_PLUGINS_DIR /$plugin_path " ' foo/foo'
85+ }
86+
87+ @test " $SUITE : plugin's own module can execute top-level plugin script" {
88+ @go.create_test_command_script " plugins/foo/lib/foo" " @go bar"
89+ @go.create_test_command_script " plugins/bar/bin/bar" " $PRINT_SOURCE "
90+
91+ run " $TEST_GO_SCRIPT " ' foo/foo'
92+ assert_success " $TEST_GO_PLUGINS_DIR /bar/bin/bar" ' foo/foo'
93+ }
94+
5795@test " $SUITE : nested plugin imports own internal module" {
5896 local module_path=' foo/bin/plugins/bar/bin/lib/bar-2'
5997 @go.create_test_command_script ' plugins/foo/lib/foo' \
@@ -147,6 +185,71 @@ teardown() {
147185 ' foo/foo' ' bar/bar' ' baz/baz'
148186}
149187
188+ @test " $SUITE : @go plugins from own module shows nested plugin's plugins" {
189+ local plugin_path=' foo/bin/plugins/bar/bin/plugins/baz/bin/baz'
190+ @go.create_test_command_script ' plugins/foo/lib/foo' ' @go bar'
191+ @go.create_test_command_script ' plugins/foo/bin/foo' " $PRINT_SOURCE "
192+ @go.create_test_command_script ' plugins/foo/bin/plugins/bar/bin/bar' \
193+ ' . "$_GO_USE_MODULES" bar/bar'
194+ @go.create_test_command_script ' plugins/foo/bin/plugins/bar/lib/bar' \
195+ ' @go plugins --paths'
196+ @go.create_test_command_script " plugins/$plugin_path " " $PRINT_SOURCE "
197+
198+ run " $TEST_GO_SCRIPT " ' foo/foo'
199+
200+ # Note that the parent plugin command script is included in the output.
201+ # @go plugins will import additional modules, so only check the first.
202+ assert_success
203+ assert_line_equals 0 ' baz bin/plugins/baz/bin/baz'
204+ assert_line_equals 1 " foo $TEST_GO_PLUGINS_DIR /foo/bin/foo"
205+ assert_line_equals 2 ' foo/foo'
206+ assert_line_equals 3 ' bar/bar'
207+ }
208+
209+ @test " $SUITE : nested plugin's own module can execute own command script" {
210+ local plugin_path=' foo/bin/plugins/bar/bin/plugins/baz/bin/baz'
211+ @go.create_test_command_script ' plugins/foo/lib/foo' \
212+ ' . "$_GO_USE_MODULES" bar/bar'
213+ @go.create_test_command_script ' plugins/foo/bin/plugins/bar/lib/bar' ' @go baz'
214+ @go.create_test_command_script " plugins/foo/bin/plugins/bar/bin/baz" \
215+ " $PRINT_SOURCE "
216+
217+ run " $TEST_GO_SCRIPT " ' foo/foo'
218+ assert_success " $TEST_GO_PLUGINS_DIR /foo/bin/plugins/bar/bin/baz" \
219+ ' foo/foo' ' bar/bar'
220+ }
221+
222+ @test " $SUITE : nested plugin's own module can execute own plugin script" {
223+ local plugin_path=' foo/bin/plugins/bar/bin/plugins/baz/bin/baz'
224+ @go.create_test_command_script ' plugins/foo/lib/foo' \
225+ ' . "$_GO_USE_MODULES" bar/bar'
226+ @go.create_test_command_script ' plugins/foo/bin/plugins/bar/lib/bar' ' @go baz'
227+ @go.create_test_command_script " plugins/$plugin_path " " $PRINT_SOURCE "
228+
229+ run " $TEST_GO_SCRIPT " ' foo/foo'
230+ assert_success " $TEST_GO_PLUGINS_DIR /$plugin_path " ' foo/foo' ' bar/bar'
231+ }
232+
233+ @test " $SUITE : nested plugin's own module can execute parent command script" {
234+ @go.create_test_command_script ' plugins/foo/lib/foo' \
235+ ' . "$_GO_USE_MODULES" bar/bar'
236+ @go.create_test_command_script ' plugins/foo/bin/baz' " $PRINT_SOURCE "
237+ @go.create_test_command_script ' plugins/foo/bin/plugins/bar/lib/bar' ' @go baz'
238+
239+ run " $TEST_GO_SCRIPT " ' foo/foo'
240+ assert_success " $TEST_GO_PLUGINS_DIR /foo/bin/baz" ' foo/foo' ' bar/bar'
241+ }
242+
243+ @test " $SUITE : nested plugin's own module can execute top-level plugin script" {
244+ @go.create_test_command_script ' plugins/foo/lib/foo' \
245+ ' . "$_GO_USE_MODULES" bar/bar'
246+ @go.create_test_command_script ' plugins/foo/bin/plugins/bar/lib/bar' ' @go baz'
247+ @go.create_test_command_script " plugins/baz/bin/baz" " $PRINT_SOURCE "
248+
249+ run " $TEST_GO_SCRIPT " ' foo/foo'
250+ assert_success " $TEST_GO_PLUGINS_DIR /baz/bin/baz" ' foo/foo' ' bar/bar'
251+ }
252+
150253@test " $SUITE : module collision produces warning message, top level first" {
151254 local top_module_path=' baz/lib/baz'
152255 local nested_module_path=' foo/bin/plugins/bar/bin/plugins/baz/lib/baz'
0 commit comments