2023-05-02 14:19:22 +00:00
|
|
|
package spectest
|
|
|
|
|
|
|
|
import (
|
2023-06-11 21:50:02 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cl/transition/machine"
|
2023-05-02 14:19:22 +00:00
|
|
|
"io/fs"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"gfx.cafe/util/go/generic"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2023-06-11 21:50:02 +00:00
|
|
|
func RunCases(t *testing.T, app Appendix, machineImpl machine.Interface, root fs.FS) {
|
2023-05-02 14:19:22 +00:00
|
|
|
cases, err := ReadTestCases(root)
|
|
|
|
require.Nil(t, err, "reading cases")
|
|
|
|
// prepare for gore.....
|
|
|
|
type (
|
|
|
|
K1 = string
|
|
|
|
K2 = string
|
|
|
|
K3 = string
|
|
|
|
K4 = string
|
|
|
|
K5 = string
|
|
|
|
V = TestCase
|
|
|
|
)
|
|
|
|
// welcome to hell
|
|
|
|
cases.tree.Range0(func(s string, m *generic.Map5[K1, K2, K3, K4, K5, V]) bool {
|
|
|
|
t.Run(s, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
m.Range0(func(s string, m *generic.Map4[K1, K2, K3, K4, V]) bool {
|
|
|
|
t.Run(s, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
m.Range0(func(s string, m *generic.Map3[K1, K2, K3, V]) bool {
|
|
|
|
t.Run(s, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
m.Range0(func(s string, m *generic.Map2[K1, K2, V]) bool {
|
|
|
|
t.Run(s, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
m.Range0(func(s string, m *generic.Map1[K1, V]) bool {
|
|
|
|
t.Run(s, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
m.Range0(func(key string, value TestCase) bool {
|
|
|
|
t.Run(key, func(t *testing.T) {
|
|
|
|
require.NotPanics(t, func() {
|
|
|
|
t.Parallel()
|
|
|
|
runner, ok := app[value.RunnerName]
|
|
|
|
if !ok {
|
|
|
|
t.Skipf("runner not found: %s", value.RunnerName)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
handler, err := runner.GetHandler(value.HandlerName)
|
|
|
|
if err != nil {
|
2023-05-04 13:18:42 +00:00
|
|
|
t.Skipf("handler not found: %s/%s", value.RunnerName, value.HandlerName)
|
2023-05-02 14:19:22 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
subfs, err := fs.Sub(root, filepath.Join(
|
|
|
|
value.ConfigName,
|
|
|
|
value.ForkPhaseName,
|
|
|
|
value.RunnerName,
|
|
|
|
value.HandlerName,
|
|
|
|
value.SuiteName,
|
|
|
|
value.CaseName,
|
|
|
|
))
|
2023-06-11 21:50:02 +00:00
|
|
|
value.Machine = machineImpl
|
2023-05-02 14:19:22 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
err = handler.Run(t, subfs, value)
|
|
|
|
require.NoError(t, err)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|