Merge pull request #10116 from glours/add-buildx-plugin-e2e

cleanup framework.go from uncessary debug logs
This commit is contained in:
Guillaume Lours 2022-12-21 21:39:23 +01:00 committed by GitHub
commit 0307c16daf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,9 +133,9 @@ func initializePlugins(t testing.TB, configDir string) {
require.NoError(t, os.MkdirAll(filepath.Join(configDir, "cli-plugins"), 0o755), require.NoError(t, os.MkdirAll(filepath.Join(configDir, "cli-plugins"), 0o755),
"Failed to create cli-plugins directory") "Failed to create cli-plugins directory")
composePlugin, err := findExecutable(t, DockerComposeExecutableName) composePlugin, err := findExecutable(DockerComposeExecutableName)
if err != nil { if os.IsNotExist(err) {
t.Errorf("WARNING: docker-compose cli-plugin not found %s", err.Error()) t.Logf("WARNING: docker-compose cli-plugin not found")
} }
if err == nil { if err == nil {
@ -160,24 +160,16 @@ func dirContents(dir string) []string {
return res return res
} }
func findExecutable(t testing.TB, executableName string) (string, error) { func findExecutable(executableName string) (string, error) {
filename, err := os.Getwd() _, filename, _, _ := runtime.Caller(0)
if err != nil { root := filepath.Join(filepath.Dir(filename), "..", "..")
return "", err
}
t.Logf("Current dir %s", filename)
root := filepath.Join(filepath.Dir(filename), "..")
t.Logf("Root dir %s", root)
buildPath := filepath.Join(root, "bin", "build") buildPath := filepath.Join(root, "bin", "build")
bin, err := filepath.Abs(filepath.Join(buildPath, executableName)) bin, err := filepath.Abs(filepath.Join(buildPath, executableName))
if err != nil { if err != nil {
t.Errorf("Error finding compose binary %s", err.Error())
return "", err return "", err
} }
t.Logf("binary path %s", bin)
if _, err := os.Stat(bin); err == nil { if _, err := os.Stat(bin); err == nil {
return bin, nil return bin, nil
} }
@ -204,28 +196,19 @@ func findPluginExecutable(pluginExecutableName string) (string, error) {
// CopyFile copies a file from a sourceFile to a destinationFile setting permissions to 0755 // CopyFile copies a file from a sourceFile to a destinationFile setting permissions to 0755
func CopyFile(t testing.TB, sourceFile string, destinationFile string) { func CopyFile(t testing.TB, sourceFile string, destinationFile string) {
t.Helper() t.Helper()
t.Logf("copy %s to %s", sourceFile, destinationFile)
src, err := os.Open(sourceFile) src, err := os.Open(sourceFile)
require.NoError(t, err, "Failed to open source file: %s") require.NoError(t, err, "Failed to open source file: %s")
//nolint:errcheck //nolint:errcheck
defer src.Close() defer src.Close()
t.Logf("Source file opened %s ", src.Name())
dst, err := os.OpenFile(destinationFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o755) dst, err := os.OpenFile(destinationFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o755)
require.NoError(t, err, "Failed to open destination file: %s", destinationFile) require.NoError(t, err, "Failed to open destination file: %s", destinationFile)
//nolint:errcheck //nolint:errcheck
defer dst.Close() defer dst.Close()
t.Logf("Destination file opened %s ", dst.Name())
_, err = io.Copy(dst, src) _, err = io.Copy(dst, src)
require.NoError(t, err, "Failed to copy file: %s", sourceFile) require.NoError(t, err, "Failed to copy file: %s", sourceFile)
t.Logf("File copied? %s ", err)
fileStat, err := dst.Stat()
if err != nil {
t.Logf("Can't get file stat %s ", err)
}
t.Logf("File stat: %+v", fileStat)
} }
// BaseEnvironment provides the minimal environment variables used across all // BaseEnvironment provides the minimal environment variables used across all
@ -346,7 +329,7 @@ func ComposeStandalonePath(t testing.TB) string {
if !composeStandaloneMode { if !composeStandaloneMode {
require.Fail(t, "Not running in standalone mode") require.Fail(t, "Not running in standalone mode")
} }
composeBinary, err := findExecutable(t, DockerComposeExecutableName) composeBinary, err := findExecutable(DockerComposeExecutableName)
require.NoError(t, err, "Could not find standalone Compose binary (%q)", require.NoError(t, err, "Could not find standalone Compose binary (%q)",
DockerComposeExecutableName) DockerComposeExecutableName)
return composeBinary return composeBinary