This is an automated email from the ASF dual-hosted git repository.

altay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new e9d3ce2  Fix ptest runner selection.
     new 0091b3c  Merge pull request #7608 from lostluck/fixptest
e9d3ce2 is described below

commit e9d3ce2bbac7d65d8e19ad946eb149599559c62a
Author: Robert Burke <[email protected]>
AuthorDate: Wed Jan 23 19:25:42 2019 +0000

    Fix ptest runner selection.
---
 sdks/go/pkg/beam/testing/ptest/ptest.go | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/sdks/go/pkg/beam/testing/ptest/ptest.go 
b/sdks/go/pkg/beam/testing/ptest/ptest.go
index 008591b..fe23f6c 100644
--- a/sdks/go/pkg/beam/testing/ptest/ptest.go
+++ b/sdks/go/pkg/beam/testing/ptest/ptest.go
@@ -62,11 +62,17 @@ func CreateList2(a, b interface{}) (*beam.Pipeline, 
beam.Scope, beam.PCollection
 //
 // The test file must have a TestMain that calls Main or MainWithDefault
 // to function.
-var Runner = flag.String("runner", "direct", "Pipeline runner.")
+var (
+       Runner        = flag.String("runner", "", "Pipeline runner.")
+       defaultRunner = "direct"
+)
 
 // Run runs a pipeline for testing. The semantics of the pipeline is expected
 // to be verified through passert.
 func Run(p *beam.Pipeline) error {
+       if *Runner == "" {
+               *Runner = defaultRunner
+       }
        return beam.Run(context.Background(), *Runner, p)
 }
 
@@ -87,13 +93,10 @@ func Main(m *testing.M) {
 // pipelines on runners other than the direct runner, while setting the default
 // runner to use.
 func MainWithDefault(m *testing.M, runner string) {
+       defaultRunner = runner
        if !flag.Parsed() {
                flag.Parse()
        }
-       // Override if not otherwise set.
-       if *Runner == "direct" {
-               *Runner = runner
-       }
        beam.Init()
        os.Exit(m.Run())
 }

Reply via email to