11/*
2- © Copyright IBM Corporation 2017, 2023
2+ © Copyright IBM Corporation 2017, 2024
33
44Licensed under the Apache License, Version 2.0 (the "License");
55you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ import (
3434 "time"
3535
3636 ce "github.com/ibm-messaging/mq-container/test/container/containerengine"
37+ "github.com/ibm-messaging/mq-container/test/container/pathutils"
3738)
3839
3940func imageName () string {
@@ -129,7 +130,7 @@ func coverage() bool {
129130
130131// coverageDir returns the host directory to use for code coverage data
131132func coverageDir (t * testing.T , unixStylePath bool ) string {
132- return filepath . Join (getCwd (t , unixStylePath ), "coverage" )
133+ return pathutils . CleanPath (getCwd (t , unixStylePath ), "coverage" )
133134}
134135
135136// coverageBind returns a string to use to add a bind-mounted directory for code coverage data
@@ -213,7 +214,7 @@ func cleanContainer(t *testing.T, cli ce.ContainerInterface, ID string) {
213214 t .Log ("Container stopped" )
214215
215216 // If a code coverage file has been generated, then rename it to match the test name
216- os .Rename (filepath . Join (coverageDir (t , true ), "container.cov" ), filepath . Join (coverageDir (t , true ), t .Name ()+ ".cov" ))
217+ os .Rename (pathutils . CleanPath (coverageDir (t , true ), "container.cov" ), pathutils . CleanPath (coverageDir (t , true ), t .Name ()+ ".cov" ))
217218 // Log the container output for any container we're about to delete
218219 t .Logf ("Console log from container %v:\n %v" , ID , inspectTextLogs (t , cli , ID ))
219220
@@ -497,7 +498,7 @@ func getExitCodeFilename(t *testing.T) string {
497498}
498499
499500func getCoverageExitCode (t * testing.T , orig int64 ) int64 {
500- f := filepath . Join (coverageDir (t , true ), getExitCodeFilename (t ))
501+ f := pathutils . CleanPath (coverageDir (t , true ), getExitCodeFilename (t ))
501502 _ , err := os .Stat (f )
502503 if err != nil {
503504 t .Log (err )
@@ -689,7 +690,7 @@ func createImage(t *testing.T, cli ce.ContainerInterface, files []struct{ Name,
689690 //Write files to temp directory
690691 for _ , file := range files {
691692 //Add tag to file name to allow parallel testing
692- f , err := os .Create (filepath . Join (tmpDir , file .Name ))
693+ f , err := os .Create (pathutils . CleanPath (tmpDir , file .Name ))
693694 if err != nil {
694695 t .Fatal (err )
695696 }
@@ -701,7 +702,7 @@ func createImage(t *testing.T, cli ce.ContainerInterface, files []struct{ Name,
701702 t .Fatal (err )
702703 }
703704 }
704- _ , err = cli .ImageBuild (r , tag , filepath . Join (tmpDir , files [0 ].Name ))
705+ _ , err = cli .ImageBuild (r , tag , pathutils . CleanPath (tmpDir , files [0 ].Name ))
705706 if err != nil {
706707 t .Fatal (err )
707708 }
@@ -866,5 +867,5 @@ func waitForMessageCountInLog(t *testing.T, cli ce.ContainerInterface, id string
866867
867868// Returns fully qualified path
868869func tlsDirDN (t * testing.T , unixPath bool , certPath string ) string {
869- return filepath .Join (getCwd (t , unixPath ), certPath )
870+ return pathutils . CleanPath ( filepath .Dir (getCwd (t , unixPath ) ), certPath )
870871}
0 commit comments