diff --git a/test/cmake/cmake.go b/test/cmake/cmake.go index 101add1..2cc17f6 100644 --- a/test/cmake/cmake.go +++ b/test/cmake/cmake.go @@ -191,6 +191,15 @@ func (cmake *Cmake) BuildTarget() ([]byte, []byte, error) { ) } +// Build runs cmake build "Name" target step. +func (cmake *Cmake) BuildWithTarget(target string) ([]byte, []byte, error) { + return cmakeExec(cmake.ConfDir, + "--build", cmake.BuildDir, + "--target", target, + // "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10), + ) +} + // Build runs cmake build step. func (cmake *Cmake) BuildDefaults() ([]byte, []byte, error) { return cmakeExec(cmake.ConfDir, @@ -208,6 +217,16 @@ func (cmake *Cmake) BuildDefaultsWithConfig(config string) ([]byte, []byte, erro ) } +// Build runs cmake default build step with config +func (cmake *Cmake) BuildTargetWithConfig(config, target string) ([]byte, []byte, error) { + return cmakeExec(cmake.ConfDir, + "--build", cmake.BuildDir, + "--config", config, + "--target", target, + // "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10), + ) +} + func CopyDir(cwd string, src string, dst string) ([]byte, []byte, error) { return cmakeExec(cwd, "-E", "copy_directory", src, dst) } diff --git a/test/integration/cmake/cmake_test.go b/test/integration/cmake/cmake_test.go index d876004..dd885b2 100644 --- a/test/integration/cmake/cmake_test.go +++ b/test/integration/cmake/cmake_test.go @@ -130,34 +130,34 @@ func TestCMakeProjects(t *testing.T) { if multiConfigBuild { configs := []string{"Release", "Debug"} for _, config := range configs { - if stdOut, stdErr, err := conf.Build(config, ""); err != nil { + if stdOut, stdErr, err := conf.BuildDefaultsWithConfig(config); err != nil { t.Fatalf("cmake build (configuration %s) failed: \n%s\n%s\n%s", config, stdOut, stdErr, err) } else { t.Logf("build (configuration %s) output:\n%s", config, string(stdOut)) } - if stdOut, stdErr, err := conf.Build(config, "clean"); err != nil { + if stdOut, stdErr, err := conf.BuildTargetWithConfig(config, "clean"); err != nil { t.Fatalf("cmake build clean (configuration %s) failed: \n%s\n%s\n%s", config, stdOut, stdErr, err) } else { t.Logf("clean (configuration %s) output:\n%s", config, string(stdOut)) } - if stdOut, stdErr, err := conf.Build(config, ""); err != nil { + if stdOut, stdErr, err := conf.BuildDefaultsWithConfig(config); err != nil { t.Fatalf("cmake build clean (configuration %s) failed: \n%s\n%s\n%s", config, stdOut, stdErr, err) } else { t.Logf("rebuild (configuration %s) output:\n%s", config, string(stdOut)) } } } else { - if stdOut, stdErr, err := conf.Build("", ""); err != nil { + if stdOut, stdErr, err := conf.BuildDefaults(); err != nil { t.Fatalf("cmake build failed: \n%s\n%s\n%s", stdOut, stdErr, err) } else { t.Logf("build output:\n%s", string(stdOut)) } - if stdOut, stdErr, err := conf.Build("", "clean"); err != nil { + if stdOut, stdErr, err := conf.BuildWithTarget("clean"); err != nil { t.Fatalf("cmake build clean failed: \n%s\n%s\n%s", stdOut, stdErr, err) } else { t.Logf("clean output:\n%s", string(stdOut)) } - if stdOut, stdErr, err := conf.Build("", ""); err != nil { + if stdOut, stdErr, err := conf.BuildDefaults(); err != nil { t.Fatalf("cmake build clean failed: \n%s\n%s\n%s", stdOut, stdErr, err) } else { t.Logf("rebuild output:\n%s", string(stdOut)) @@ -170,14 +170,14 @@ func TestCMakeProjects(t *testing.T) { if multiConfigBuild { configs := []string{"Release", "Debug"} for _, config := range configs { - if stdOut, stdErr, err := conf.Build(config, ""); err != nil { + if stdOut, stdErr, err := conf.BuildDefaultsWithConfig(config); err != nil { t.Fatalf("cmake build after update (configuration %s) failed: \n%s\n%s\n%s", config, stdOut, stdErr, err) } else { t.Logf("build after update (configuration %s) output:\n%s", config, string(stdOut)) } } } else { - if stdOut, stdErr, err := conf.Build("", ""); err != nil { + if stdOut, stdErr, err := conf.BuildDefaults(); err != nil { t.Fatalf("cmake build after update failed: \n%s\n%s\n%s", stdOut, stdErr, err) } else { t.Logf("build after update output:\n%s", string(stdOut))