cargo-bisect-rustc-service/index.html
2022-09-29 20:19:14 +02:00

151 lines
3.4 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bisect rustc</title>
<style>
html {
font-family: Arial, Helvetica, sans-serif;
}
#result {
font-family: monospace;
}
.hidden {
display: none;
}
#code {
columns: 100;
}
.bisect-btn {
width: 200px;
height: 50px;
}
</style>
</head>
<body>
<h1>Bisect rustc</h1>
<textarea
id="code"
rows="30"
cols="80"
placeholder="// Rust code goes here..."
>
struct Struct&lt;T&gt;(T);
impl&lt;T&gt; Struct&lt;T&gt; {
const CONST: fn() = || {
struct _Obligation where T:;
};
}
</textarea
>
<br />
<label for="start">Start</label>
<input id="start" value="2022-01-01" />
<label for="end">End (optional)</label>
<input id="end" value="2022-06-01" />
<label for="kind">Regression Kind</label>
<select id="kind">
<option>error</option>
<option>success</option>
<option selected="selected">ice</option>
<option>non-ice</option>
<option>non-error</option>
</select>
<br />
<br />
<button class="bisect-btn" onclick="bisect()">Bisect!</button>
<br />
<br />
<div id="status" class="hidden"></div>
<br />
<textarea
id="result"
class="hidden"
cols="80"
rows="20"
readonly
></textarea>
<script>
const BASE_URL = `${document.location}`;
const code = document.getElementById("code");
const status = document.getElementById("status");
const result = document.getElementById("result");
const start = document.getElementById("start");
const end = document.getElementById("end");
const kind = document.getElementById("kind");
let bisecting = false;
async function bisect() {
if (bisecting) {
return;
}
if (!start.value.trim()) {
alert("Must provide a start");
return;
}
bisecting = true;
status.classList.remove("hidden");
result.classList.add("hidden");
status.innerText = "Sending request...";
const params = new URLSearchParams();
params.append("start", start.value.trim());
params.append("kind", kind.value);
if (end.value.trim()) {
params.append("end", end.value.trim());
}
const body = code.value;
console.log("Bisecting", body);
const fetched = await fetch(`${BASE_URL}bisect?${params}`, {
method: "POST",
body,
headers: {
"Content-Type": "application/text",
},
});
const { job_id } = await fetched.json();
async function tryFetch() {
const fetched = await fetch(`${BASE_URL}bisect/${job_id}`);
const response = await fetched.json();
if (response.status.status !== "InProgress") {
bisecting = false;
console.log(response.status.output);
status.classList.add("hidden");
result.classList.remove("hidden");
result.value = response.status.output;
status.innerHTML = `Bisected job ${job_id}`;
} else {
console.log("Waiting for bisection", response.status.status);
setTimeout(tryFetch, 3000);
}
}
tryFetch();
status.innerHTML = `Waiting for result, job id=${job_id}`;
}
</script>
</body>
</html>