Skip to content

Commit

Permalink
internal: run tests in parallel (#30381)
Browse files Browse the repository at this point in the history
Continuation of #28546
  • Loading branch information
estensen committed Sep 16, 2024
1 parent ae70744 commit 4c4f212
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 9 deletions.
5 changes: 5 additions & 0 deletions internal/era/e2store/e2store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
)

func TestEncode(t *testing.T) {
t.Parallel()

for _, test := range []struct {
entries []Entry
want string
Expand Down Expand Up @@ -53,6 +55,7 @@ func TestEncode(t *testing.T) {
tt := test
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

var (
b = bytes.NewBuffer(nil)
w = NewWriter(b)
Expand Down Expand Up @@ -83,6 +86,8 @@ func TestEncode(t *testing.T) {
}

func TestDecode(t *testing.T) {
t.Parallel()

for i, tt := range []struct {
have string
err error
Expand Down
4 changes: 4 additions & 0 deletions internal/era/era_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type testchain struct {
}

func TestEra1Builder(t *testing.T) {
t.Parallel()

// Get temp directory.
f, err := os.CreateTemp("", "era1-test")
if err != nil {
Expand Down Expand Up @@ -125,6 +127,8 @@ func TestEra1Builder(t *testing.T) {
}

func TestEraFilename(t *testing.T) {
t.Parallel()

for i, tt := range []struct {
network string
epoch int
Expand Down
7 changes: 6 additions & 1 deletion internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import (
)

func testTransactionMarshal(t *testing.T, tests []txData, config *params.ChainConfig) {
t.Parallel()
var (
signer = types.LatestSigner(config)
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
Expand Down Expand Up @@ -98,6 +97,8 @@ func testTransactionMarshal(t *testing.T, tests []txData, config *params.ChainCo
}

func TestTransaction_RoundTripRpcJSON(t *testing.T) {
t.Parallel()

var (
config = params.AllEthashProtocolChanges
tests = allTransactionTypes(common.Address{0xde, 0xad}, config)
Expand All @@ -106,6 +107,8 @@ func TestTransaction_RoundTripRpcJSON(t *testing.T) {
}

func TestTransactionBlobTx(t *testing.T) {
t.Parallel()

config := *params.TestChainConfig
config.ShanghaiTime = new(uint64)
config.CancunTime = new(uint64)
Expand Down Expand Up @@ -2460,6 +2463,8 @@ func TestFillBlobTransaction(t *testing.T) {
}
for _, tc := range suite {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

res, err := api.FillTransaction(context.Background(), tc.args)
if len(tc.err) > 0 {
if err == nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/ethapi/transaction_args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import (

// TestSetFeeDefaults tests the logic for filling in default fee values works as expected.
func TestSetFeeDefaults(t *testing.T) {
t.Parallel()

type test struct {
name string
fork string // options: legacy, london, cancun
Expand Down
14 changes: 10 additions & 4 deletions internal/flags/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
)

func TestPathExpansion(t *testing.T) {
t.Parallel()

user, _ := user.Current()
var tests map[string]string

Expand Down Expand Up @@ -53,9 +55,13 @@ func TestPathExpansion(t *testing.T) {

os.Setenv(`DDDXXX`, `/tmp`)
for test, expected := range tests {
got := expandPath(test)
if got != expected {
t.Errorf(`test %s, got %s, expected %s\n`, test, got, expected)
}
t.Run(test, func(t *testing.T) {
t.Parallel()

got := expandPath(test)
if got != expected {
t.Errorf(`test %s, got %s, expected %s\n`, test, got, expected)
}
})
}
}
2 changes: 2 additions & 0 deletions internal/guide/guide_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import (

// Tests that the account management snippets work correctly.
func TestAccountManagement(t *testing.T) {
t.Parallel()

// Create a temporary folder to work with
workdir := t.TempDir()

Expand Down
14 changes: 10 additions & 4 deletions internal/jsre/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
)

func TestCompleteKeywords(t *testing.T) {
t.Parallel()

re := New("", os.Stdout)
re.Run(`
function theClass() {
Expand Down Expand Up @@ -85,9 +87,13 @@ func TestCompleteKeywords(t *testing.T) {
},
}
for _, test := range tests {
cs := re.CompleteKeywords(test.input)
if !reflect.DeepEqual(cs, test.want) {
t.Errorf("wrong completions for %q\ngot %v\nwant %v", test.input, cs, test.want)
}
t.Run(test.input, func(t *testing.T) {
t.Parallel()

cs := re.CompleteKeywords(test.input)
if !reflect.DeepEqual(cs, test.want) {
t.Errorf("wrong completions for %q\ngot %v\nwant %v", test.input, cs, test.want)
}
})
}
}
8 changes: 8 additions & 0 deletions internal/jsre/jsre_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func newWithTestJS(t *testing.T, testjs string) *JSRE {
}

func TestExec(t *testing.T) {
t.Parallel()

jsre := newWithTestJS(t, `msg = "testMsg"`)

err := jsre.Exec("test.js")
Expand All @@ -73,6 +75,8 @@ func TestExec(t *testing.T) {
}

func TestNatto(t *testing.T) {
t.Parallel()

jsre := newWithTestJS(t, `setTimeout(function(){msg = "testMsg"}, 1);`)

err := jsre.Exec("test.js")
Expand All @@ -96,6 +100,8 @@ func TestNatto(t *testing.T) {
}

func TestBind(t *testing.T) {
t.Parallel()

jsre := New("", os.Stdout)
defer jsre.Stop(false)

Expand All @@ -108,6 +114,8 @@ func TestBind(t *testing.T) {
}

func TestLoadScript(t *testing.T) {
t.Parallel()

jsre := newWithTestJS(t, `msg = "testMsg"`)

_, err := jsre.Run(`loadScript("test.js")`)
Expand Down
6 changes: 6 additions & 0 deletions internal/utesting/utesting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
)

func TestTest(t *testing.T) {
t.Parallel()

tests := []Test{
{
Name: "successful test",
Expand Down Expand Up @@ -90,6 +92,8 @@ var outputTests = []Test{
}

func TestOutput(t *testing.T) {
t.Parallel()

var buf bytes.Buffer
RunTests(outputTests, &buf)

Expand All @@ -116,6 +120,8 @@ $`[1:])
}

func TestOutputTAP(t *testing.T) {
t.Parallel()

var buf bytes.Buffer
RunTAP(outputTests, &buf)

Expand Down

0 comments on commit 4c4f212

Please sign in to comment.