diff --git a/build.gradle b/build.gradle index 5a99f1eacb6..43dc1ca0107 100644 --- a/build.gradle +++ b/build.gradle @@ -116,16 +116,7 @@ allprojects { spotless { java { // This path needs to be relative to each project - target fileTree('.') { - include '**/src/*/java/**/*.java' - exclude '**/generalstate/GeneralStateReferenceTest*.java' - exclude '**/generalstate/GeneralStateRegressionReferenceTest*.java' - exclude '**/generalstate/LegacyGeneralStateReferenceTest*.java' - exclude '**/blockchain/BlockchainReferenceTest*.java' - exclude '**/blockchain/LegacyBlockchainReferenceTest*.java' - exclude '**/reference-test/resources/docker_interop/**' - exclude '**/.gradle/**' - } + target '**/src/*/java/**/*.java' removeUnusedImports() googleJavaFormat('1.10.0') importOrder 'org.hyperledger', 'java', '' @@ -137,20 +128,10 @@ allprojects { greclipse().configFile(rootProject.file('gradle/formatter.properties')) endWithNewline() } - // Below this line are currently only license header tasks format 'groovy', { target '**/src/*/grovy/**/*.groovy' } - - // Currently disabled due to referencetest issues - // format 'bash', { - // target fileTree('.') { - // include '**/*.sh' - // exclude '**/ansible/**' - // } - // } - // format 'sol', { - // target fileTree('.') { include '**/*.sol' } - // } + format 'bash', { target '**/*.sh' } + format 'sol', { target '**/*.sol' } } tasks.withType(JavaCompile) { diff --git a/ethereum/core/build.gradle b/ethereum/core/build.gradle index 0bca2aafe28..e2ea513c038 100644 --- a/ethereum/core/build.gradle +++ b/ethereum/core/build.gradle @@ -27,6 +27,16 @@ jar { } } +sourceSets { + test { + java { + compileClasspath += main.output + runtimeClasspath += main.output + srcDirs += file('./build/generated/sources/referencetests/java/test') + } + } +} + dependencies { annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess' @@ -115,6 +125,7 @@ test { } def generateTestFiles(FileTree jsonPath, File templateFile, String pathstrip, String destination, String namePrefix, String ... excludedPath) { + mkdir(destination) def referenceTestTemplate = templateFile.text // This is how many json files to include in each test file @@ -143,63 +154,79 @@ def generateTestFiles(FileTree jsonPath, File templateFile, String pathstrip, St } task blockchainReferenceTestsSetup { + inputs.files fileTree('../referencetests/src/test/resources/BlockchainTests') + outputs.files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/blockchain" generateTestFiles( fileTree('../referencetests/src/test/resources/BlockchainTests'), file("./src/test/resources/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTest.java.template"), "BlockchainTests", - "./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain", + "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/blockchain", "BlockchainReferenceTest", ("BlockchainTests/InvalidBlocks/bcExpectSection") // exclude test for test filling tool ) } task legacyBlockchainReferenceTestsSetup { + inputs.files fileTree('../referencetests/src/test/resources/LegacyTests/Constantinople/BlockchainTests') + outputs.files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/blockchain" generateTestFiles( fileTree('../referencetests/src/test/resources/LegacyTests/Constantinople/BlockchainTests'), file("./src/test/resources/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTest.java.template"), "LegacyTests", - "./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain", + "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/blockchain", "LegacyBlockchainReferenceTest", ("BlockchainTests/InvalidBlocks/bcExpectSection") // exclude test for test filling tool ) } task generalstateReferenceTestsSetup { + inputs.files fileTree("../referencetests/src/test/resources/GeneralStateTests") + outputs.files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate" generateTestFiles( fileTree("../referencetests/src/test/resources/GeneralStateTests"), file("./src/test/resources/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTest.java.template"), "GeneralStateTests", - "./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate", + "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate", "GeneralStateReferenceTest" ) } task legacyGeneralstateReferenceTestsSetup { + inputs.files fileTree('../referencetests/src/test/resources/LegacyTests/Constantinople/GeneralStateTests') + outputs.files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate" generateTestFiles( fileTree('../referencetests/src/test/resources/LegacyTests/Constantinople/GeneralStateTests'), file("./src/test/resources/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTest.java.template"), "LegacyTests", - "./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate", + "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate", "LegacyGeneralStateReferenceTest" ) } task generalstateRegressionReferenceTestsSetup { + inputs.files fileTree("./src/test/resources/regressions/generalstate") + outputs.files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate" generateTestFiles( fileTree("./src/test/resources/regressions/generalstate"), file("./src/test/resources/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTest.java.template"), "regressions", - "./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate", + "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate", "GeneralStateRegressionReferenceTest" ) } +//TODO delete in Jan 2022. This is left as a migration aid for reference tests moving to the build directory task cleanupReferenceTests(type: Delete) { delete fileTree("./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate/") { include("**/GeneralStateReferenceTest*.java") include("**/GeneralStateRegressionReferenceTest*.java") + include("**/LegacyGeneralStateReferenceTest*.java") + include("**/LegacyGeneralStateRegressionReferenceTest*.java") + } + delete fileTree("./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain/") { + include("**/BlockchainReferenceTest*.java") + include("**/LegacyBlockchainReferenceTest*.java") } - delete fileTree("./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain/") { include("**/BlockchainReferenceTest*.java") } } clean.dependsOn(cleanupReferenceTests) @@ -215,6 +242,8 @@ task referenceTests(type: Test, dependsOn: [ compileTestJava.mustRunAfter blockchainReferenceTestsSetup compileTestJava.mustRunAfter generalstateReferenceTestsSetup compileTestJava.mustRunAfter generalstateRegressionReferenceTestsSetup + compileTestJava.mustRunAfter legacyBlockchainReferenceTestsSetup + compileTestJava.mustRunAfter legacyGeneralstateReferenceTestsSetup doFirst { if (!file("../referencetests/src/test/resources/README.md").exists()) { throw new GradleException("ethereum/referencetests/src/test/resources/README.md missing: please clone submodules (git submodule update --init --recursive)") diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/blockchain/.keep b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/blockchain/.keep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/generalstate/.keep b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/generalstate/.keep deleted file mode 100644 index e69de29bb2d..00000000000