MCPcopy Create free account
hub / github.com/celer-pkg/celer / TestClean

Function TestClean

cmds/cmd_clean_test.go:398–514  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

396}
397
398func TestClean(t *testing.T) {
399 celer := newInitializedCeler(t)
400
401 var (
402 windowsPlatform = expr.If(os.Getenv("GITHUB_ACTIONS") == "true", "x86_64-windows-msvc-enterprise-14", "x86_64-windows-msvc-community-14")
403 platform = expr.If(runtime.GOOS == "windows", windowsPlatform, "x86_64-linux-ubuntu-22.04-gcc-11.5.0")
404 project = "project_test_clean"
405 )
406
407 // Configure platform/project/build-type via `celer configure`, exactly as
408 // a user would. Each flag is its own command to obey configure's
409 // one-flag-group rule.
410 configBuildType := &configureCmd{}
411 if _, err := runCommand(t, configBuildType.Command(celer), "--build-type=Release"); err != nil {
412 t.Fatal(err)
413 }
414 configPlatform := &configureCmd{}
415 if _, err := runCommand(t, configPlatform.Command(celer), "--platform="+platform); err != nil {
416 t.Fatal(err)
417 }
418 configProject := &configureCmd{}
419 if _, err := runCommand(t, configProject.Command(celer), "--project="+project); err != nil {
420 t.Fatal(err)
421 }
422
423 check(t, celer.Deploy(true, false))
424
425 buildDir := func(nameVersion string, dev bool) string {
426 if dev {
427 hostPlatform := celer.Platform().GetHostName() + "-dev"
428 return fmt.Sprintf("%s/%s/%s", dirs.BuildtreesDir, nameVersion, hostPlatform)
429 }
430 return fmt.Sprintf("%s/%s/%s-%s-%s", dirs.BuildtreesDir, nameVersion, platform, project, celer.BuildType())
431 }
432
433 t.Run("clean port", func(t *testing.T) {
434 cmd := &cleanCmd{}
435 if _, err := runCommand(t, cmd.Command(celer), "x264@stable"); err != nil {
436 t.Fatal(err)
437 }
438 if fileio.PathExists(buildDir("x264@stable", false)) {
439 t.Fatal("x264@stable build dir should be removed")
440 }
441 })
442
443 t.Run("clean port for dev", func(t *testing.T) {
444 cmd := &cleanCmd{}
445 if _, err := runCommand(t, cmd.Command(celer), "m4@1.4.19", "--dev"); err != nil {
446 t.Fatal(err)
447 }
448 if fileio.PathExists(buildDir("m4@1.4.19", true)) {
449 t.Fatal("m4@1.4.19 build dir should be removed")
450 }
451 })
452
453 t.Run("clean recursive", func(t *testing.T) {
454 cmd := &cleanCmd{}
455 if _, err := runCommand(t, cmd.Command(celer), "automake@1.18", "--dev", "--recursive"); err != nil {

Callers

nothing calls this directly

Calls 13

CommandMethod · 0.95
CommandMethod · 0.95
IfFunction · 0.92
PathExistsFunction · 0.92
IsModifiedFunction · 0.92
newInitializedCelerFunction · 0.85
runCommandFunction · 0.85
checkFunction · 0.85
DeployMethod · 0.80
SprintfMethod · 0.80
GetHostNameMethod · 0.65
PlatformMethod · 0.65

Tested by

no test coverage detected