@@ -773,6 +773,27 @@ func TestGoWorkspaceModulesSkipsGeneratedOfficialPluginAggregate(t *testing.T) {
773773 }
774774}
775775
776+ // TestGoWorkspaceModulesIncludesGoListOutputInErrors verifies CI failures keep
777+ // the Go command's actionable workspace diagnostic instead of only exit status.
778+ func TestGoWorkspaceModulesIncludesGoListOutputInErrors (t * testing.T ) {
779+ application := newApp (ioDiscard {}, ioDiscard {}, strings .NewReader ("" ))
780+ application .root = t .TempDir ()
781+ application .execCommand = func (_ context.Context , name string , args ... string ) * exec.Cmd {
782+ if name != "go" || strings .Join (args , " " ) != "list -m -f {{.Dir}}" {
783+ t .Fatalf ("unexpected module list command: %s %s" , name , strings .Join (args , " " ))
784+ }
785+ return exec .Command (os .Args [0 ], "-test.run=TestHelperPrintAndFail" , "--" )
786+ }
787+
788+ _ , err := goWorkspaceModules (context .Background (), application )
789+ if err == nil {
790+ t .Fatalf ("expected goWorkspaceModules to return an error" )
791+ }
792+ if ! strings .Contains (err .Error (), "workspace diagnostic from go list" ) {
793+ t .Fatalf ("expected go list output in error, got %v" , err )
794+ }
795+ }
796+
776797// TestDiscoverGoModuleDirsSkipsGeneratedAndDependencyDirs verifies tidy scans
777798// maintained source modules without entering generated or dependency trees.
778799func TestDiscoverGoModuleDirsSkipsGeneratedAndDependencyDirs (t * testing.T ) {
@@ -892,7 +913,6 @@ use (
892913use (
893914 ../apps/lina-core
894915 ../hack/tools/build-wasm
895- ./official-plugins
896916 ../apps/lina-plugins
897917 ../apps/lina-plugins/plugin-a
898918 ../apps/lina-plugins/plugin-b
@@ -901,6 +921,52 @@ use (
901921 if string (pluginContent ) != expected {
902922 t .Fatalf ("unexpected temporary plugin go.work:\n %s" , string (pluginContent ))
903923 }
924+ if dirExists (filepath .Join (root , "temp" , "official-plugins" )) {
925+ t .Fatalf ("expected existing official plugin root module to be reused without generated fallback" )
926+ }
927+ }
928+
929+ func TestPrepareOfficialPluginWorkspaceGeneratesFallbackAggregateModule (t * testing.T ) {
930+ root := t .TempDir ()
931+ content := `go 1.25.0
932+
933+ use (
934+ ./apps/lina-core
935+ ./hack/tools/build-wasm
936+ )
937+ `
938+ writeFile (t , filepath .Join (root , "go.work" ), content )
939+ pluginRoot := filepath .Join (root , "apps" , "lina-plugins" )
940+ writeFile (t , filepath .Join (pluginRoot , "plugin-b" , "go.mod" ), "module plugin-b\n " )
941+ writeFile (t , filepath .Join (pluginRoot , "plugin-b" , "plugin.yaml" ), "id: plugin-b\n " )
942+ writeFile (t , filepath .Join (pluginRoot , "plugin-a" , "go.mod" ), "module plugin-a\n " )
943+ writeFile (t , filepath .Join (pluginRoot , "plugin-a" , "plugin.yaml" ), "id: plugin-a\n " )
944+
945+ workspace , err := inspectOfficialPluginWorkspace (root )
946+ if err != nil {
947+ t .Fatalf ("inspectOfficialPluginWorkspace returned error: %v" , err )
948+ }
949+ workspacePath , err := prepareOfficialPluginWorkspace (root , true , workspace )
950+ if err != nil {
951+ t .Fatalf ("prepareOfficialPluginWorkspace returned error: %v" , err )
952+ }
953+ pluginContent , err := os .ReadFile (workspacePath )
954+ if err != nil {
955+ t .Fatalf ("read temporary plugin go.work: %v" , err )
956+ }
957+ expected := `go 1.25.0
958+
959+ use (
960+ ../apps/lina-core
961+ ../hack/tools/build-wasm
962+ ./official-plugins
963+ ../apps/lina-plugins/plugin-a
964+ ../apps/lina-plugins/plugin-b
965+ )
966+ `
967+ if string (pluginContent ) != expected {
968+ t .Fatalf ("unexpected fallback temporary plugin go.work:\n %s" , string (pluginContent ))
969+ }
904970 aggregateGoMod , err := os .ReadFile (filepath .Join (root , "temp" , "official-plugins" , "go.mod" ))
905971 if err != nil {
906972 t .Fatalf ("read aggregate go.mod: %v" , err )
@@ -965,6 +1031,16 @@ func TestHelperCommandFailure(t *testing.T) {
9651031 os .Exit (1 )
9661032}
9671033
1034+ // TestHelperPrintAndFail prints a deterministic diagnostic and exits with
1035+ // failure for command-output error tests.
1036+ func TestHelperPrintAndFail (t * testing.T ) {
1037+ if len (os .Args ) < 2 || os .Args [len (os .Args )- 1 ] != "--" {
1038+ return
1039+ }
1040+ fmt .Fprintln (os .Stderr , "workspace diagnostic from go list" )
1041+ os .Exit (1 )
1042+ }
1043+
9681044// TestHelperRecordWorkingDirectory records the child process working directory
9691045// for command execution tests.
9701046func TestHelperRecordWorkingDirectory (t * testing.T ) {
0 commit comments