Skip to content

Commit

Permalink
Fixed latest.json result files for the new format (#3348)
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican committed Oct 8, 2023
1 parent d2caa9a commit 34615ec
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 17 deletions.
137 changes: 137 additions & 0 deletions test262/fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import json, os

def suite_conformance(suites):
res = {
"t": 0,
"o": 0,
"i": 0,
"p": 0
}

for suite in suites.values():
if "s" in suite.keys():
conformance = suite_conformance(suite["s"])
res["t"] += conformance["t"]
res["o"] += conformance["o"]
res["i"] += conformance["i"]
res["p"] += conformance["p"]

if "t" in suite.keys():
for test in suite["t"].values():
res["t"] += 1
if "s" in test.keys() and "r" in test.keys():
if test["s"] == "O" and test["r"] == "O":
res["o"] += 1
elif test["s"] == "I" and test["r"] == "I":
res["i"] += 1
elif test["s"] == "P" or test["r"] == "P":
res["p"] += 1
elif "s" in test.keys():
if test["s"] == "O":
res["o"] += 1
elif test["s"] == "I":
res["i"] += 1
elif test["s"] == "P":
res["p"] += 1
else:
if test["r"] == "O":
res["o"] += 1
elif test["r"] == "I":
res["i"] += 1
elif test["r"] == "P":
res["p"] += 1

return res

def version_conformance(suites):
res = {}

for suite in suites.values():
if "s" in suite.keys():
versions = version_conformance(suite["s"])
for key in versions.keys():
if key not in res.keys():
res[key] = 0

res[key] += versions[key]

if "t" in suite.keys():
for test in suite["t"].values():
if "v" in test.keys():
version = test["v"]
if version != 255:
key = str(version)
if key not in res.keys():
res[key] = 0

res[key] += 1

return res

def fix_tests(tests):
fixed = {}

for test in tests:
name = test["n"]
if test["n"] in fixed:
if test["s"]:
fixed[name]["s"] = test["r"]
else:
fixed[name]["r"] = test["r"]
else:
fixed[name] = {}

if "v" in test.keys():
fixed[name]["v"] = test["v"]

if "s" in test.keys():
if test["s"]:
fixed[name]["s"] = test["r"]
else:
fixed[name]["r"] = test["r"]
else:
fixed[name]["r"] = test["r"]

return fixed

def fix_suite(suites):
fixed = {}
for suite in suites:
name = suite["n"]
fixed[name] = {}

if "s" in suite.keys():
fixed[name]["s"] = fix_suite(suite["s"])
fixed[name]["a"] = suite_conformance(fixed[name]["s"])
fixed[name]["v"] = version_conformance(fixed[name]["s"])

if "t" in suite.keys():
fixed[name]["t"] = fix_tests(suite["t"])

return fixed

def fix_all(latest):
fixed = {
"c": latest["c"],
"u": latest["u"],
"n": latest["r"]["n"],
"r": fix_suite(latest["r"]["s"]),
}

fixed["a"] = suite_conformance(fixed["r"])
fixed["v"] = version_conformance(fixed["r"])

return fixed

for top, dirs, files in os.walk("./refs/tags"):
for dir in dirs:
print("Fixing " + dir)
with open("./refs/tags/" + dir + "/latest.json") as latest_f:
latest = json.load(latest_f)

latest_fixed = fix_all(latest)

with open("./refs/tags/" + dir + "/latest.json", 'w') as latest_of:
json.dump(latest_fixed, latest_of, separators=(',', ':'), ensure_ascii=False)


2 changes: 1 addition & 1 deletion test262/refs/tags/v0.10/latest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test262/refs/tags/v0.11/latest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test262/refs/tags/v0.12/latest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test262/refs/tags/v0.13/latest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test262/refs/tags/v0.14/latest.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test262/refs/tags/v0.15/features.json

This file was deleted.

2 changes: 1 addition & 1 deletion test262/refs/tags/v0.15/latest.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test262/refs/tags/v0.16/features.json

This file was deleted.

2 changes: 1 addition & 1 deletion test262/refs/tags/v0.16/latest.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test262/refs/tags/v0.17.1/features.json

This file was deleted.

2 changes: 1 addition & 1 deletion test262/refs/tags/v0.17.1/latest.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test262/refs/tags/v0.17.2/features.json

This file was deleted.

2 changes: 1 addition & 1 deletion test262/refs/tags/v0.17.2/latest.json

Large diffs are not rendered by default.

Loading

0 comments on commit 34615ec

Please sign in to comment.