From 72bf6b265d0e87be8198ce2ef2af17d445922eec Mon Sep 17 00:00:00 2001 From: lyyyuna Date: Fri, 17 Jul 2020 14:27:00 +0800 Subject: [PATCH] update run e2e test case --- pkg/build/run.go | 2 -- tests/build.bats | 4 ++-- tests/run-ci-actions.sh | 2 +- tests/run-in-local.sh | 2 +- tests/{gocrun.bats => run.bats} | 20 +++++++++----------- 5 files changed, 13 insertions(+), 17 deletions(-) rename tests/{gocrun.bats => run.bats} (70%) diff --git a/pkg/build/run.go b/pkg/build/run.go index 43ca1a4..1a59219 100644 --- a/pkg/build/run.go +++ b/pkg/build/run.go @@ -39,12 +39,10 @@ func (b *Build) Run() error { cmd.Stderr = os.Stderr err := cmd.Start() if err != nil { - log.Errorf("Fail to start command: %v. The error is: %v", cmd.Args, err) return fmt.Errorf("fail to execute: %v, err: %w", cmd.Args, err) } if err = cmd.Wait(); err != nil { - log.Errorf("Fail to go run: %v. The error is: %v", cmd.Args, err) return fmt.Errorf("fail to execute: %v, err: %w", cmd.Args, err) } diff --git a/tests/build.bats b/tests/build.bats index 8390fc0..c9698ea 100755 --- a/tests/build.bats +++ b/tests/build.bats @@ -31,7 +31,7 @@ teardown_file() { @test "test basic goc build command" { cd samples/run_for_several_seconds - wait_profile_backend "build" + wait_profile_backend "build1" run gocc build --debug --debugcisyncfile ci-sync.bak; info build output: $output [ "$status" -eq 0 ] @@ -39,7 +39,7 @@ teardown_file() { @test "test goc build command without debug" { cd samples/run_for_several_seconds - wait_profile_backend "build" + wait_profile_backend "build2" run gocc build --debugcisyncfile ci-sync.bak; info build output: $output [ "$status" -eq 0 ] diff --git a/tests/run-ci-actions.sh b/tests/run-ci-actions.sh index 8d1e0cf..c8840d2 100755 --- a/tests/run-ci-actions.sh +++ b/tests/run-ci-actions.sh @@ -19,7 +19,7 @@ echo "test start" bats -t server.bats -bats -t gocrun.bats +bats -t run.bats bats -t version.bats diff --git a/tests/run-in-local.sh b/tests/run-in-local.sh index 8a8fad3..33fafdc 100755 --- a/tests/run-in-local.sh +++ b/tests/run-in-local.sh @@ -17,4 +17,4 @@ set -ex echo "test start" -bats -t profile.bats \ No newline at end of file +bats -t run.bats \ No newline at end of file diff --git a/tests/gocrun.bats b/tests/run.bats similarity index 70% rename from tests/gocrun.bats rename to tests/run.bats index 19d3735..026a64f 100755 --- a/tests/gocrun.bats +++ b/tests/run.bats @@ -22,24 +22,22 @@ setup_file() { sleep 2 goc init - # run covered goc run - WORKDIR=$PWD - cd samples/run_for_several_seconds - ls -al - gocc run --debug . 3>&- & - GOCC_PID=$! - sleep 2 info "goc gocc server started" } teardown_file() { - cd $WORKDIR - # collect from center - goc profile --debug -o filtered-run.cov kill -9 $GOC_PID - kill -9 $GOCC_PID } @test "test basic goc run" { + info $PWD + export GOPATH=$PWD/samples/simple_gopath_project + export GO111MODULE=off + cd samples/simple_gopath_project/src/qiniu.com/simple_gopath_project + wait_profile_backend "run1" + run gocc run . --debug --debugcisyncfile ci-sync.bak; + info run output: $output + [ "$status" -eq 0 ] + [[ "$output" == *"hello, world."* ]] } \ No newline at end of file