mirror of
https://github.com/edwingeng/hotswap.git
synced 2025-12-24 11:52:07 +08:00
make preparations for the static-linking plugins in testAll.sh
This commit is contained in:
@@ -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("",
|
||||
|
||||
@@ -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 "$@"
|
||||
|
||||
Reference in New Issue
Block a user