github.com/ethereum/go-ethereum@v1.16.1/cmd/evm/eest.go (about) 1 // Copyright 2024 The go-ethereum Authors 2 // This file is part of go-ethereum. 3 // 4 // go-ethereum is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // go-ethereum is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. 16 17 package main 18 19 import "regexp" 20 21 // testMetadata provides more granular access to the test information encoded 22 // within its filename by the execution spec test (EEST). 23 type testMetadata struct { 24 fork string 25 module string // which python module generated the test, e.g. eip7702 26 file string // exact file the test came from, e.g. test_gas.py 27 function string // func that created the test, e.g. test_valid_mcopy_operations 28 parameters string // the name of the parameters which were used to fill the test, e.g. zero_inputs 29 } 30 31 // parseTestMetadata reads a test name and parses out more specific information 32 // about the test. 33 func parseTestMetadata(s string) *testMetadata { 34 var ( 35 pattern = `tests\/([^\/]+)\/([^\/]+)\/([^:]+)::([^[]+)\[fork_([^-\]]+)-[^-]+-(.+)\]` 36 re = regexp.MustCompile(pattern) 37 ) 38 match := re.FindStringSubmatch(s) 39 if len(match) == 0 { 40 return nil 41 } 42 return &testMetadata{ 43 fork: match[5], 44 module: match[2], 45 file: match[3], 46 function: match[4], 47 parameters: match[6], 48 } 49 }