internal: run tests in parallel (#30381)

Continuation of https://github.com/ethereum/go-ethereum/pull/28546
This commit is contained in:
Håvard Anda Estensen 2024-09-16 08:44:47 +02:00 committed by GitHub
parent ae707445f5
commit 4c4f21293e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 53 additions and 9 deletions

@ -26,6 +26,8 @@ import (
)
func TestEncode(t *testing.T) {
t.Parallel()
for _, test := range []struct {
entries []Entry
want string
@ -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)
@ -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

@ -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 {
@ -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

@ -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")
@ -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)
@ -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)
@ -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 {

@ -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

@ -24,6 +24,8 @@ import (
)
func TestPathExpansion(t *testing.T) {
t.Parallel()
user, _ := user.Current()
var tests map[string]string
@ -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)
}
})
}
}

@ -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()

@ -23,6 +23,8 @@ import (
)
func TestCompleteKeywords(t *testing.T) {
t.Parallel()
re := New("", os.Stdout)
re.Run(`
function theClass() {
@ -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)
}
})
}
}

@ -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")
@ -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")
@ -96,6 +100,8 @@ func TestNatto(t *testing.T) {
}
func TestBind(t *testing.T) {
t.Parallel()
jsre := New("", os.Stdout)
defer jsre.Stop(false)
@ -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")`)

@ -24,6 +24,8 @@ import (
)
func TestTest(t *testing.T) {
t.Parallel()
tests := []Test{
{
Name: "successful test",
@ -90,6 +92,8 @@ var outputTests = []Test{
}
func TestOutput(t *testing.T) {
t.Parallel()
var buf bytes.Buffer
RunTests(outputTests, &buf)
@ -116,6 +120,8 @@ $`[1:])
}
func TestOutputTAP(t *testing.T) {
t.Parallel()
var buf bytes.Buffer
RunTAP(outputTests, &buf)