浏览代码

Fix the pipeline printed actions in tests

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
Vadim Markovtsev 6 年之前
父节点
当前提交
f90c2351dc
共有 3 个文件被更改,包括 5 次插入1 次删除
  1. 1 0
      internal/core/forks.go
  2. 0 1
      internal/core/pipeline.go
  3. 4 0
      internal/core/pipeline_test.go

+ 1 - 0
internal/core/forks.go

@@ -89,6 +89,7 @@ const (
 
 
 // planPrintFunc is used to print the execution plan in prepareRunPlan().
 // planPrintFunc is used to print the execution plan in prepareRunPlan().
 var planPrintFunc = func(args ...interface{}) {
 var planPrintFunc = func(args ...interface{}) {
+	fmt.Fprintln(os.Stderr)
 	fmt.Fprintln(os.Stderr, args...)
 	fmt.Fprintln(os.Stderr, args...)
 }
 }
 
 

+ 0 - 1
internal/core/pipeline.go

@@ -757,7 +757,6 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 			continue
 			continue
 		}
 		}
 		if pipeline.PrintActions {
 		if pipeline.PrintActions {
-			fmt.Fprintln(os.Stderr)
 			printAction(step)
 			printAction(step)
 		}
 		}
 		if index > 0 && index%100 == 0 && pipeline.HibernationDistance > 0 {
 		if index > 0 && index%100 == 0 && pipeline.HibernationDistance > 0 {

+ 4 - 0
internal/core/pipeline_test.go

@@ -537,9 +537,13 @@ func TestPipelineDumpPlanConfigure(t *testing.T) {
 	pipeline.Initialize(map[string]interface{}{ConfigPipelineDumpPlan: true})
 	pipeline.Initialize(map[string]interface{}{ConfigPipelineDumpPlan: true})
 	assert.True(t, pipeline.DumpPlan)
 	assert.True(t, pipeline.DumpPlan)
 	stream := &bytes.Buffer{}
 	stream := &bytes.Buffer{}
+	backupPlanPrintFunc := planPrintFunc
 	planPrintFunc = func(args ...interface{}) {
 	planPrintFunc = func(args ...interface{}) {
 		fmt.Fprintln(stream, args...)
 		fmt.Fprintln(stream, args...)
 	}
 	}
+	defer func() {
+		planPrintFunc = backupPlanPrintFunc
+	}()
 	commits := make([]*object.Commit, 1)
 	commits := make([]*object.Commit, 1)
 	commits[0], _ = test.Repository.CommitObject(plumbing.NewHash(
 	commits[0], _ = test.Repository.CommitObject(plumbing.NewHash(
 		"af9ddc0db70f09f3f27b4b98e415592a7485171c"))
 		"af9ddc0db70f09f3f27b4b98e415592a7485171c"))