Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the new format for the test262 representation #3364

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions dev/bench/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
Expand All @@ -8,9 +8,20 @@
/>
<style>
html {
font-family: BlinkMacSystemFont, -apple-system, "Segoe UI", Roboto,
Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue",
Helvetica, Arial, sans-serif;
font-family:
BlinkMacSystemFont,
-apple-system,
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
"Fira Sans",
"Droid Sans",
"Helvetica Neue",
Helvetica,
Arial,
sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 16px;
}
Expand Down Expand Up @@ -286,7 +297,7 @@
.sort(
(a, b) =>
arr.filter((v) => v === a).length -
arr.filter((v) => v === b).length
arr.filter((v) => v === b).length,
)
.pop();
}
Expand Down Expand Up @@ -335,7 +346,7 @@

// Render header
document.getElementById("last-update").textContent = new Date(
data.lastUpdate
data.lastUpdate,
).toString();
const repoLink = document.getElementById("repository-link");
repoLink.href = data.repoUrl;
Expand Down Expand Up @@ -470,7 +481,7 @@
for (const [benchName, benches] of benchSet.entries()) {
const benchUnit = unit.get(benchName);
charts.push(
renderGraph(graphsElem, benchName, benchUnit, benches)
renderGraph(graphsElem, benchName, benchUnit, benches),
);
}
return charts;
Expand All @@ -483,10 +494,10 @@
}

const darkModeCheckbox = document.querySelector(
".dark-mode-toggle input[type=checkbox]"
".dark-mode-toggle input[type=checkbox]",
);
const darkModeHandle = document.querySelector(
".dark-mode-toggle .handle"
".dark-mode-toggle .handle",
);
darkModeCheckbox.addEventListener("change", async (e) => {
document.body.classList.toggle("dark");
Expand Down
27 changes: 25 additions & 2 deletions playground/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<!doctype html><html><head><meta charset="utf-8"/><title>Boa Playground</title><link href="assets/bootstrap.min.css" rel="stylesheet"/><meta name="viewport" content="width=device-width,initial-scale=1"/><script defer="defer" src="app.js"></script></head><style>header {
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Boa Playground</title>
<link href="assets/bootstrap.min.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<script defer="defer" src="app.js"></script></head
><style>
header {
display: flex;
align-items: center;
}
Expand Down Expand Up @@ -50,4 +59,18 @@
.output {
min-height: 100px;
}
}</style><body><div class="container"><header><img class="demo__img" src="./assets/logo.svg"/><h1>Boa Playground</h1></header><div class="demo__repl"><div class="textbox"></div><p data-testid="output" class="output"></p></div></div></body></html>
}
</style>
<body>
<div class="container">
<header>
<img class="demo__img" src="./assets/logo.svg" />
<h1>Boa Playground</h1>
</header>
<div class="demo__repl">
<div class="textbox"></div>
<p data-testid="output" class="output"></p>
</div>
</div>
</body>
</html>
255 changes: 255 additions & 0 deletions test262/fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
import json
import os


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

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

if "t" in suite.keys():
for testName in suite["t"].keys():
test = suite["t"][testName]

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(suite):
res = {}

if "s" in suite.keys():
for subSuite in suite["s"].values():
versions = version_conformance(subSuite)
for key in versions.keys():
if key not in res.keys():
res[key] = {
"t": 0,
"o": 0,
"i": 0,
"p": 0
}

res[key]["t"] += versions[key]["t"]
res[key]["o"] += versions[key]["o"]
res[key]["i"] += versions[key]["i"]
res[key]["p"] += versions[key]["p"]

if "t" in suite.keys():
for testName in suite["t"].keys():
test = suite["t"][testName]

if "v" in test.keys():
version = test["v"]
if version != 255:
key = str(version)
if key not in res.keys():
res[key] = {
"t": 0,
"o": 0,
"i": 0,
"p": 0
}

res[key]["t"] += 1
if "s" in test.keys() and "r" in test.keys():
if test["s"] == "O" and test["r"] == "O":
res[key]["o"] += 1
elif test["s"] == "I" and test["r"] == "I":
res[key]["i"] += 1
elif test["s"] == "P" or test["r"] == "P":
res[key]["p"] += 1
elif "s" in test.keys():
if test["s"] == "O":
res[key]["o"] += 1
elif test["s"] == "I":
res[key]["i"] += 1
elif test["s"] == "P":
res[key]["p"] += 1
else:
if test["r"] == "O":
res[key]["o"] += 1
elif test["r"] == "I":
res[key]["i"] += 1
elif test["r"] == "P":
res[key]["p"] += 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"])

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

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

return fixed


def fix_all(latest):
fixed = {
"c": latest["c"],
"u": latest["u"],
"r": fix_suite(latest["r"]["s"]),
"a": {
"t": 0,
"o": 0,
"i": 0,
"p": 0
},
"v": {},
}

for suite in fixed["r"].values():
fixed["a"]["t"] += suite["a"]["t"]
fixed["a"]["o"] += suite["a"]["o"]
fixed["a"]["i"] += suite["a"]["i"]
fixed["a"]["p"] += suite["a"]["p"]

for key in suite["v"].keys():
if key not in fixed["v"].keys():
fixed["v"][key] = {
"t": 0,
"o": 0,
"i": 0,
"p": 0
}

fixed["v"][key]["t"] += suite["v"][key]["t"]
fixed["v"][key]["o"] += suite["v"][key]["o"]
fixed["v"][key]["i"] += suite["v"][key]["i"]
fixed["v"][key]["p"] += suite["v"][key]["p"]

return fixed


def fix_file(file_name):
with open(file_name) as latest_f:
latest = json.load(latest_f)
fixed_latest = fix_all(latest)

with open(file_name, 'w') as latest_of:
json.dump(fixed_latest, latest_of, separators=(
',', ':'), ensure_ascii=False)

return fixed_latest


def clean_main(latest):
with open("./refs/heads/main/results.json") as results_f:
results = json.load(results_f)
fixed_results = []
for result in results:
fixed_results.append({
"c": result["c"],
"u": result["u"],
"a": result["a"],
})

fixed_results[-1] = {
"c": latest["c"],
"u": latest["u"],
"a": latest["a"],
}

with open("./refs/heads/main/results.json", 'w') as results_of:
json.dump(fixed_results, results_of, separators=(
',', ':'), ensure_ascii=False)


def clean_old(file_name, results):
fixed_results = [{
"c": results["c"],
"u": results["u"],
"a": results["a"],
}]

with open(file_name, 'w') as results_of:
json.dump(fixed_results, results_of, separators=(
',', ':'), ensure_ascii=False)


for top, dirs, files in os.walk("./refs/tags"):
for dir in dirs:
print("Fixing " + dir)
results = fix_file("./refs/tags/" + dir + "/latest.json")
clean_old("./refs/tags/" + dir + "/results.json", results)

if os.path.exists("./refs/tags/" + dir + "/features.json"):
os.remove("./refs/tags/" + dir + "/features.json")

print("Fixing main branch")
results = fix_file("./refs/heads/main/latest.json")
clean_main(results)
if os.path.exists("./refs/heads/main/features.json"):
os.remove("./refs/heads/main/features.json")
Loading