allow user to select legacy or new test suite for GST and BCT

This commit is contained in:
andri lim 2020-02-19 21:26:16 +07:00 committed by zah
parent 2fbabd25a4
commit ed5710fa17
3 changed files with 18 additions and 3 deletions

View File

@ -672,6 +672,8 @@ proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus, debugMode = fal
if not fixtureTested: if not fixtureTested:
echo getConfiguration().testSubject, " not tested at all, wrong index?" echo getConfiguration().testSubject, " not tested at all, wrong index?"
if specifyIndex <= 0 or specifyIndex > node.len:
echo "Maximum subtest available: ", node.len
proc blockchainJsonMain*(debugMode = false) = proc blockchainJsonMain*(debugMode = false) =
if paramCount() == 0 or not debugMode: if paramCount() == 0 or not debugMode:
@ -687,7 +689,8 @@ proc blockchainJsonMain*(debugMode = false) =
echo "missing test subject" echo "missing test subject"
quit(QuitFailure) quit(QuitFailure)
let path = "tests" / "fixtures" / "newBlockChainTests" let folder = if config.legacy: "BlockchainTests" else: "newBlockChainTests"
let path = "tests" / "fixtures" / folder
let n = json.parseFile(path / config.testSubject) let n = json.parseFile(path / config.testSubject)
var testStatusIMPL: TestStatus var testStatusIMPL: TestStatus
testFixture(n, testStatusIMPL, debugMode = true, config.trace) testFixture(n, testStatusIMPL, debugMode = true, config.trace)

View File

@ -17,6 +17,7 @@ type
fork*: Fork fork*: Fork
index*: int index*: int
trace*: bool trace*: bool
legacy*: bool
var testConfig {.threadvar.}: Configuration var testConfig {.threadvar.}: Configuration
@ -46,6 +47,7 @@ proc processArguments*(msg: var string): ConfigStatus =
of "fork": config.fork = parseEnum[Fork](strip(value)) of "fork": config.fork = parseEnum[Fork](strip(value))
of "index": config.index = parseInt(value) of "index": config.index = parseInt(value)
of "trace": config.trace = parseBool(value) of "trace": config.trace = parseBool(value)
of "legacy": config.legacy = parseBool(value)
else: else:
msg = "Unknown option " & key msg = "Unknown option " & key
if value.len > 0: msg = msg & " : " & value if value.len > 0: msg = msg & " : " & value

View File

@ -153,8 +153,10 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
tester.debugMode = debugMode tester.debugMode = debugMode
let ftrans = fixture["transaction"] let ftrans = fixture["transaction"]
var testedInFork = false var testedInFork = false
var numIndex = -1
for fork in supportedForks: for fork in supportedForks:
if fixture["post"].hasKey(forkNames[fork]): if fixture["post"].hasKey(forkNames[fork]):
numIndex = fixture["post"][forkNames[fork]].len
for expectation in fixture["post"][forkNames[fork]]: for expectation in fixture["post"][forkNames[fork]]:
inc tester.index inc tester.index
if specifyIndex > 0 and tester.index != specifyIndex: if specifyIndex > 0 and tester.index != specifyIndex:
@ -173,7 +175,14 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
testFixtureIndexes(tester, testStatusIMPL) testFixtureIndexes(tester, testStatusIMPL)
if not testedInFork: if not testedInFork:
echo "test subject '", tester.name, "' not tested in any forks" echo "test subject '", tester.name, "' not tested in any forks/subtests"
if specifyIndex <= 0 or specifyIndex > numIndex:
echo "Maximum subtest available: ", numIndex
else:
echo "available forks in this test:"
for fork in test_helpers.supportedForks:
if fixture["post"].hasKey(forkNames[fork]):
echo fork
proc generalStateJsonMain*(debugMode = false) = proc generalStateJsonMain*(debugMode = false) =
if paramCount() == 0 or not debugMode: if paramCount() == 0 or not debugMode:
@ -189,7 +198,8 @@ proc generalStateJsonMain*(debugMode = false) =
echo "missing test subject" echo "missing test subject"
quit(QuitFailure) quit(QuitFailure)
let path = "tests" / "fixtures" / "newGeneralStateTests" let folder = if config.legacy: "GeneralStateTests" else: "newGeneralStateTests"
let path = "tests" / "fixtures" / folder
let n = json.parseFile(path / config.testSubject) let n = json.parseFile(path / config.testSubject)
var testStatusIMPL: TestStatus var testStatusIMPL: TestStatus
var forks: set[Fork] = {} var forks: set[Fork] = {}