mirror of
https://github.com/Noratrieb/cargo-bisect-rustc-service.git
synced 2026-01-14 08:15:01 +01:00
263 lines
6.5 KiB
HTML
263 lines
6.5 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>
|
|
|
|
<div>
|
|
Made by Nilstrieb
|
|
<a href="https://github.com/Nilstrieb/cargo-bisect-rustc-service"
|
|
>Github</a
|
|
>
|
|
</div>
|
|
|
|
<script>
|
|
let BASE_URL = `${document.location}`.split("?")[0];
|
|
if (!BASE_URL.endsWith("/")) {
|
|
// ugh, i hate url paths and their subtle interactions with things
|
|
BASE_URL = `${BASE_URL}/`;
|
|
}
|
|
|
|
// The important HTML elements.
|
|
const htmlStatus = document.getElementById("status");
|
|
const htmlResult = document.getElementById("result");
|
|
const htmlCode = document.getElementById("code");
|
|
|
|
// A list of all ongoing fetches in fetchAndUpdate.
|
|
const fetches = [];
|
|
|
|
let bisecting = false;
|
|
|
|
initialLoad();
|
|
|
|
document.getElementById("bisect-form").addEventListener("submit", (e) => {
|
|
e.preventDefault();
|
|
submitForm();
|
|
});
|
|
|
|
async function initialLoad() {
|
|
const params = document.location.search;
|
|
const urlParams = new URLSearchParams(params);
|
|
const bisection = urlParams.get("bisection");
|
|
|
|
if (bisection) {
|
|
const response = await fetchAndUpdate(bisection);
|
|
if (!response) {
|
|
fatal(`Bisection with ID \`${bisection}\` not found.`);
|
|
return;
|
|
}
|
|
code.value = response.code;
|
|
}
|
|
}
|
|
|
|
// Report a fatal error to the console and screen.
|
|
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);
|
|
}
|
|
|
|
async function bisect(options) {
|
|
if (bisecting) {
|
|
return;
|
|
}
|
|
|
|
fetches.forEach((fetchId) => clearTimeout(fetchId));
|
|
|
|
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;
|
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
urlParams.set("bisection", jobId);
|
|
window.location.search = urlParams;
|
|
|
|
if (!jobId) {
|
|
fatal("Received invalid response", data);
|
|
return;
|
|
}
|
|
} catch (err) {
|
|
fatal(err);
|
|
return;
|
|
}
|
|
|
|
fetchAndUpdate(jobId);
|
|
}
|
|
|
|
async function fetchAndUpdate(jobId) {
|
|
htmlStatus.innerHTML = `Waiting for result, job id=${jobId}`;
|
|
htmlStatus.classList.remove("hidden");
|
|
|
|
let response;
|
|
try {
|
|
const fetched = await fetch(`${BASE_URL}bisect/${jobId}`);
|
|
if (!fetched.ok) {
|
|
fatal("Failed to fetch bisection.", fetched);
|
|
return;
|
|
}
|
|
response = await fetched.json();
|
|
} catch (e) {
|
|
fatal(e);
|
|
return;
|
|
}
|
|
|
|
if (!response) {
|
|
console.log("Waiting for bisection", response.status.status);
|
|
const timeout = setTimeout(() => fetchAndUpdate(jobId), 3000);
|
|
fetches.push(timeout);
|
|
return response;
|
|
}
|
|
|
|
const status = response.status;
|
|
|
|
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);
|
|
const timeout = setTimeout(() => fetchAndUpdate(jobId), 3000);
|
|
fetches.push(timeout);
|
|
}
|
|
|
|
return response;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|