@@ -133,9 +133,9 @@ func initializePlugins(t testing.TB, configDir string) {
133
133
134
134
require .NoError (t , os .MkdirAll (filepath .Join (configDir , "cli-plugins" ), 0o755 ),
135
135
"Failed to create cli-plugins directory" )
136
- composePlugin , err := findExecutable (t , DockerComposeExecutableName )
137
- if err != nil {
138
- t .Errorf ("WARNING: docker-compose cli-plugin not found %s" , err . Error () )
136
+ composePlugin , err := findExecutable (DockerComposeExecutableName )
137
+ if os . IsNotExist ( err ) {
138
+ t .Logf ("WARNING: docker-compose cli-plugin not found" )
139
139
}
140
140
141
141
if err == nil {
@@ -160,24 +160,16 @@ func dirContents(dir string) []string {
160
160
return res
161
161
}
162
162
163
- func findExecutable (t testing.TB , executableName string ) (string , error ) {
164
- filename , err := os .Getwd ()
165
- if err != nil {
166
- return "" , err
167
- }
168
- t .Logf ("Current dir %s" , filename )
169
- root := filepath .Join (filepath .Dir (filename ), ".." )
170
- t .Logf ("Root dir %s" , root )
171
-
163
+ func findExecutable (executableName string ) (string , error ) {
164
+ _ , filename , _ , _ := runtime .Caller (0 )
165
+ root := filepath .Join (filepath .Dir (filename ), ".." , ".." )
172
166
buildPath := filepath .Join (root , "bin" , "build" )
173
167
174
168
bin , err := filepath .Abs (filepath .Join (buildPath , executableName ))
175
169
if err != nil {
176
- t .Errorf ("Error finding compose binary %s" , err .Error ())
177
170
return "" , err
178
171
}
179
172
180
- t .Logf ("binary path %s" , bin )
181
173
if _ , err := os .Stat (bin ); err == nil {
182
174
return bin , nil
183
175
}
@@ -204,28 +196,19 @@ func findPluginExecutable(pluginExecutableName string) (string, error) {
204
196
// CopyFile copies a file from a sourceFile to a destinationFile setting permissions to 0755
205
197
func CopyFile (t testing.TB , sourceFile string , destinationFile string ) {
206
198
t .Helper ()
207
- t .Logf ("copy %s to %s" , sourceFile , destinationFile )
208
199
209
200
src , err := os .Open (sourceFile )
210
201
require .NoError (t , err , "Failed to open source file: %s" )
211
202
//nolint:errcheck
212
203
defer src .Close ()
213
- t .Logf ("Source file opened %s " , src .Name ())
214
204
215
205
dst , err := os .OpenFile (destinationFile , os .O_RDWR | os .O_CREATE | os .O_TRUNC , 0o755 )
216
206
require .NoError (t , err , "Failed to open destination file: %s" , destinationFile )
217
207
//nolint:errcheck
218
208
defer dst .Close ()
219
- t .Logf ("Destination file opened %s " , dst .Name ())
220
209
221
210
_ , err = io .Copy (dst , src )
222
211
require .NoError (t , err , "Failed to copy file: %s" , sourceFile )
223
- t .Logf ("File copied? %s " , err )
224
- fileStat , err := dst .Stat ()
225
- if err != nil {
226
- t .Logf ("Can't get file stat %s " , err )
227
- }
228
- t .Logf ("File stat: %+v" , fileStat )
229
212
}
230
213
231
214
// BaseEnvironment provides the minimal environment variables used across all
@@ -346,7 +329,7 @@ func ComposeStandalonePath(t testing.TB) string {
346
329
if ! composeStandaloneMode {
347
330
require .Fail (t , "Not running in standalone mode" )
348
331
}
349
- composeBinary , err := findExecutable (t , DockerComposeExecutableName )
332
+ composeBinary , err := findExecutable (DockerComposeExecutableName )
350
333
require .NoError (t , err , "Could not find standalone Compose binary (%q)" ,
351
334
DockerComposeExecutableName )
352
335
return composeBinary
0 commit comments