Skip to content

Commit

Permalink
tmp: potential fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-obx committed Aug 15, 2024
1 parent fec6609 commit f3c95b3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 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
16 changes: 8 additions & 8 deletions test/integration/cmake/cmake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down

0 comments on commit f3c95b3

Please sign in to comment.