Skip to content

Commit

Permalink
test/integration/cmake: added clean and rebuild runs
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-obx committed Aug 15, 2024
1 parent 58686d2 commit 7ed25ee
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 deletions.
19 changes: 19 additions & 0 deletions test/cmake/cmake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
}
Expand Down
44 changes: 32 additions & 12 deletions test/integration/cmake/cmake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7ed25ee

Please sign in to comment.