Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp committed Aug 30, 2023
1 parent dfdd658 commit 4c6ef61
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
14 changes: 0 additions & 14 deletions common/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"
"sync/atomic"

"github.com/docker/docker/pkg/reexec"
cmap "github.com/orcaman/concurrent-map"
)

Expand Down Expand Up @@ -69,19 +68,6 @@ func (c *Cmd) runCmd() {
}
}

func (c *Cmd) runApp() {
fmt.Println("cmd:", append([]string{c.name}, c.args...))
if atomic.CompareAndSwapUint64(&c.isRunning, 0, 1) {
c.cmd = &exec.Cmd{
Path: reexec.Self(),
Args: append([]string{c.name}, c.args...),
Stderr: c,
Stdout: c,
}
c.ErrChan <- c.cmd.Run()
}
}

// RunCmd parallel running when parallel is true.
func (c *Cmd) RunCmd(parallel bool) {
if parallel {
Expand Down
18 changes: 18 additions & 0 deletions common/cmd/cmd_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package cmd
import (
"fmt"
"os"
"os/exec"
"strings"
"sync/atomic"
"testing"
"time"

"github.com/docker/docker/pkg/reexec"
"github.com/stretchr/testify/assert"
)

Expand All @@ -16,6 +18,19 @@ func (c *Cmd) IsRunning() bool {
return atomic.LoadUint64(&c.isRunning) == 1
}

func (c *Cmd) runApp() {
fmt.Println("cmd:", append([]string{c.name}, c.args...))
if atomic.CompareAndSwapUint64(&c.isRunning, 0, 1) {
c.cmd = &exec.Cmd{
Path: reexec.Self(),
Args: append([]string{c.name}, c.args...),
Stderr: c,
Stdout: c,
}
c.ErrChan <- c.cmd.Run()
}
}

// RunApp exec's the current binary using name as argv[0] which will trigger the
// reexec init function for that name (e.g. "geth-test" in cmd/geth/run_test.go)
func (c *Cmd) RunApp(waitResult func() bool) {
Expand All @@ -31,6 +46,9 @@ func (c *Cmd) RunApp(waitResult func() bool) {

// WaitExit wait util process exit.
func (c *Cmd) WaitExit() {
if atomic.LoadUint64(&c.isRunning) == 0 {
return
}
// Wait all the check functions are finished, interrupt loop when appear error.
var err error
for err == nil && !c.checkFuncs.IsEmpty() {
Expand Down
3 changes: 3 additions & 0 deletions tests/integration-test/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"math/big"
"testing"
"time"

"github.com/scroll-tech/go-ethereum/accounts/abi/bind"
"github.com/scroll-tech/go-ethereum/common"
Expand All @@ -20,6 +21,8 @@ var (

func TestERC20(t *testing.T) {
base.RunL2Geth(t)
time.Sleep(time.Second * 3)

l2Cli, err := base.L2Client()
assert.Nil(t, err)

Expand Down

0 comments on commit 4c6ef61

Please sign in to comment.