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 6080b6f..dd885b2 100644 --- a/test/integration/cmake/cmake_test.go +++ b/test/integration/cmake/cmake_test.go @@ -126,21 +126,41 @@ func TestCMakeProjects(t *testing.T) { t.Fatalf("cmake configuration failed: \n%s\n%s\n%s", stdOut, stdErr, err) } else { t.Logf("configuration output:\n%s", string(stdOut)) - if multiConfigBuild { - configs := []string{"Release", "Debug"} - for _, config := range configs { - 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 multiConfigBuild { + configs := []string{"Release", "Debug"} + for _, config := range configs { + 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)) } - } else { - if stdOut, stdErr, err := conf.BuildDefaults(); err != nil { - t.Fatalf("cmake build failed: \n%s\n%s\n%s", stdOut, stdErr, err) + 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("build output:\n%s", string(stdOut)) + t.Logf("clean (configuration %s) output:\n%s", config, string(stdOut)) } + 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.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.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.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)) } } // Test updating for just "cpp-flat" using content from "update-cpp-flat" folder.