make preparations for the static-linking plugins in testAll.sh

This commit is contained in:
gengbing
2022-11-05 23:24:17 +08:00
parent 0a1af82010
commit 268bbecbf3
2 changed files with 15 additions and 13 deletions

View File

@@ -1,13 +1,13 @@
package hotswap_test
import (
"fmt"
"os"
"path/filepath"
"testing"
"github.com/edwingeng/hotswap"
"github.com/edwingeng/hotswap/cli/hotswap/trial"
"github.com/edwingeng/hotswap/internal/hutils"
"github.com/edwingeng/slog"
)
@@ -18,19 +18,14 @@ func prepareEnv(t *testing.T, env string) {
}
}
func prepareStaticPlugins(t *testing.T, pluginNames ...string) {
t.Helper()
const exe = "cli/hotswap/hotswap"
const homeDir = "cli/hotswap/trial"
for _, pName := range pluginNames {
pluginDir := filepath.Join(homeDir, pName)
hutils.BuildPlugin(t, exe, pluginDir, homeDir, "--staticLinking")
}
}
func TestWithStaticPlugins(t *testing.T) {
pluginNames := []string{"arya", "snow", "stubborn"}
prepareStaticPlugins(t, pluginNames...)
for _, pName := range pluginNames {
file := filepath.Join("cli/hotswap/trial", fmt.Sprintf("hotswap.staticPluginInit.%s.go", pName))
if _, err := os.Stat(file); err != nil {
t.SkipNow()
}
}
log := slog.NewScavenger()
swapper := hotswap.NewPluginManagerSwapper("",

View File

@@ -37,4 +37,11 @@ printImportantMessage "It takes minutes to finish the tests."
go build -o cli/hotswap/hotswap github.com/edwingeng/hotswap/cli/hotswap
[[ $? -ne 0 ]] && exit 1
go test -trimpath "$@"
cli/hotswap/hotswap build --staticLinking cli/hotswap/trial/arya cli/hotswap/trial
[[ $? -ne 0 ]] && exit 1
cli/hotswap/hotswap build --staticLinking cli/hotswap/trial/snow cli/hotswap/trial
[[ $? -ne 0 ]] && exit 1
cli/hotswap/hotswap build --staticLinking cli/hotswap/trial/stubborn cli/hotswap/trial
[[ $? -ne 0 ]] && exit 1
go test -trimpath -v "$@"