Auto loader for per-commit tests

This commit is contained in:
Faiz Khan 2015-03-06 11:09:30 -06:00
parent 1135db55b3
commit 2102792f23
3 changed files with 39 additions and 2 deletions

View File

@ -69,6 +69,7 @@ dependencies {
compile "com.google.code.findbugs:jsr305:3.0.0"
compile "com.fasterxml.jackson.core:jackson-databind:2.2.0"
compile "org.apache.commons:commons-collections4:4.0"
compile "commons-codec:commons-codec:1.10"
compile "org.springframework:spring-context:${springVersion}"
compile "org.springframework:spring-tx:${springVersion}"
compile "org.springframework:spring-orm:${springVersion}"

View File

@ -20,6 +20,8 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.codec.binary.Base64;
public class JSONReader {
public static String loadJSON(String filename) {
@ -71,6 +73,36 @@ public class JSONReader {
return result;
}
public static String getTestBlobForTreeSha(String shacommit, String testcase){
String result = getFromUrl("https://api.github.com/repos/ethereum/tests/git/trees/" + shacommit);
JSONParser parser = new JSONParser();
JSONObject testSuiteObj = null;
List<String> fileNames = new ArrayList<String>();
try {
testSuiteObj = (JSONObject) parser.parse(result);
JSONArray tree = (JSONArray)testSuiteObj.get("tree");
for (Object oEntry : tree) {
JSONObject entry = (JSONObject) oEntry;
String testName = (String) entry.get("path");
if ( testName.equals(testcase) ) {
String blobresult = getFromUrl( (String) entry.get("url") );
testSuiteObj = (JSONObject) parser.parse(blobresult);
String blob = (String) testSuiteObj.get("content");
byte[] valueDecoded= Base64.decodeBase64(blob.getBytes() );
//System.out.println("Decoded value is " + new String(valueDecoded));
return new String(valueDecoded);
}
}
} catch (ParseException e) {e.printStackTrace();}
return "";
}
public static List<String> getFileNamesForTreeSha(String sha){
String result = getFromUrl("https://api.github.com/repos/ethereum/tests/git/trees/" + sha);
@ -92,4 +124,4 @@ public class JSONReader {
return fileNames;
}
}
}

View File

@ -18,6 +18,10 @@ import static org.ethereum.jsontestsuite.JSONReader.getFileNamesForTreeSha;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class GitHubVMTest {
//SHACOMMIT of VMTESTS TREE (not main tree)
public String shacommit = "a713843af6e6274915bdbbc03d62dc5a0007548b";
public List<String> vmTestFiles = getFileNamesForTreeSha(shacommit);
@Test
public void runSingle() throws ParseException {
String json = JSONReader.loadJSON("VMTests/vmEnvironmentalInfoTest.json");
@ -29,7 +33,7 @@ public class GitHubVMTest {
Set<String> excluded = new HashSet<>();
excluded.add("addmod1_overflowDiff");
excluded.add("addmod1_overflow3");
String json = JSONReader.loadJSON("VMTests/vmArithmeticTest.json");
String json = JSONReader.getTestBlobForTreeSha(shacommit, "vmArithmeticTest.json");
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
}