mirror of
https://github.com/Noratrieb/cargo-bisect-rustc-service.git
synced 2026-01-14 16:25:01 +01:00
208 lines
4.9 KiB
HTML
208 lines
4.9 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;
|
|
}
|
|
|
|
.error {
|
|
color: red;
|
|
}
|
|
|
|
.bisect-btn {
|
|
width: 200px;
|
|
height: 50px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Bisect rustc</h1>
|
|
|
|
<form name="bisect" id="bisect-form">
|
|
<label for="code">Code</label>
|
|
<br />
|
|
<textarea
|
|
id="code"
|
|
rows="30"
|
|
cols="80"
|
|
placeholder="// Rust code goes here..."
|
|
name="code"
|
|
>
|
|
struct Struct<T>(T);
|
|
|
|
impl<T> Struct<T> {
|
|
const CONST: fn() = || {
|
|
struct _Obligation where T:;
|
|
};
|
|
}
|
|
</textarea
|
|
>
|
|
<br />
|
|
<label for="start">Start</label>
|
|
<input id="start" value="2022-01-01" name="start" />
|
|
|
|
<label for="end">End (optional)</label>
|
|
<input id="end" value="2022-06-01" name="end" />
|
|
|
|
<label for="kind">Regression Kind</label>
|
|
<select id="kind" name="select">
|
|
<option>error</option>
|
|
<option>success</option>
|
|
<option selected="selected">ice</option>
|
|
<option>non-ice</option>
|
|
<option>non-error</option>
|
|
</select>
|
|
|
|
<br />
|
|
<br />
|
|
<input type="submit" class="bisect-btn" value="Bisect!" />
|
|
</form>
|
|
|
|
<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 htmlStatus = document.getElementById("status");
|
|
const htmlResult = document.getElementById("result");
|
|
|
|
let bisecting = false;
|
|
|
|
function fatal(err, ...extra) {
|
|
console.error(err, ...(extra || []));
|
|
htmlStatus.innerHTML = `ERROR: ${err}`;
|
|
htmlStatus.classList.remove("hidden");
|
|
htmlStatus.classList.add("error");
|
|
bisecting = false;
|
|
}
|
|
|
|
function submitForm() {
|
|
const form = document.forms.bisect;
|
|
const options = {
|
|
code: form.code.value,
|
|
start: form.start.value?.trim(),
|
|
end: form.end.value?.trim(),
|
|
kind: form.kind.value,
|
|
};
|
|
console.log("Options", options);
|
|
|
|
if (!options.start) {
|
|
fatal("Must provide a start");
|
|
return;
|
|
}
|
|
|
|
bisect(options);
|
|
}
|
|
|
|
document.getElementById("bisect-form").addEventListener("submit", (e) => {
|
|
e.preventDefault();
|
|
submitForm();
|
|
});
|
|
|
|
async function bisect(options) {
|
|
if (bisecting) {
|
|
return;
|
|
}
|
|
|
|
bisecting = true;
|
|
|
|
htmlStatus.classList.remove("error");
|
|
htmlStatus.classList.remove("hidden");
|
|
htmlResult.classList.add("hidden");
|
|
htmlStatus.innerText = "Sending request...";
|
|
|
|
const params = new URLSearchParams();
|
|
|
|
params.append("start", options.start);
|
|
params.append("kind", options.kind);
|
|
|
|
if (options.end) {
|
|
params.append("end", options.end);
|
|
}
|
|
|
|
const body = options.code;
|
|
|
|
let jobId;
|
|
try {
|
|
const fetched = await fetch(`${BASE_URL}bisect?${params}`, {
|
|
method: "POST",
|
|
body,
|
|
headers: {
|
|
"Content-Type": "application/text",
|
|
},
|
|
});
|
|
if (!fetched.ok) {
|
|
console.error(fetched);
|
|
fatal("Failed to fetch", fetched);
|
|
return;
|
|
}
|
|
const data = await fetched.json();
|
|
jobId = data?.job_id;
|
|
if (!jobId) {
|
|
fatal("Received invalid response", data);
|
|
return;
|
|
}
|
|
} catch (err) {
|
|
fatal(err);
|
|
return;
|
|
}
|
|
|
|
async function tryFetch() {
|
|
let response;
|
|
try {
|
|
const fetched = await fetch(`${BASE_URL}bisect/${jobId}`);
|
|
if (!fetched.ok) {
|
|
fatal("Failed to fetch", fetched);
|
|
return;
|
|
}
|
|
response = await fetched.json();
|
|
} catch (e) {
|
|
fatal(e);
|
|
return;
|
|
}
|
|
|
|
if (response.status.status !== "InProgress") {
|
|
bisecting = false;
|
|
console.log(response.status.output);
|
|
|
|
htmlStatus.classList.add("hidden");
|
|
htmlResult.classList.remove("hidden");
|
|
|
|
htmlResult.value = response.status.output;
|
|
htmlStatus.innerHTML = `Bisected job ${jobId}`;
|
|
} else {
|
|
console.log("Waiting for bisection", response.status.status);
|
|
setTimeout(tryFetch, 3000);
|
|
}
|
|
}
|
|
|
|
tryFetch();
|
|
|
|
htmlStatus.innerHTML = `Waiting for result, job id=${jobId}`;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|