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

fuzzer with reducer + web frontend #26

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.zig text=auto eol=lf
* text=auto eol=lf
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/zig-out
/zig-cache
/saved_logs
/repos
zig-out
zig-cache
.zig-cache
saved_logs
repos
node_modules
/.env
.env
d_*.log
41 changes: 16 additions & 25 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
const zig_lsp = b.dependency("zig-lsp", .{}).module("zig-lsp");

const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const block_len = b.option(
u8,
"block-len",
"how many bytes to consider when predicting the next character. " ++
"defaults to 8. " ++
"note: this may affect performance.",
) orelse 8;

const options = b.addOptions();
options.addOption(u8, "block_len", block_len);

const lsp_module = b.dependency("lsp-codegen", .{}).module("lsp");

const exe = b.addExecutable(.{
.name = "sus",
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zig-lsp", zig_lsp);
b.installArtifact(exe);
exe.root_module.addImport("lsp", lsp_module);
exe.root_module.addOptions("build_options", options);

const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
Expand All @@ -23,25 +35,4 @@ pub fn build(b: *std.Build) void {

const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);

const build_exe_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = .Debug,
});
const run_exe_tests = b.addRunArtifact(build_exe_tests);

const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_exe_tests.step);

const block_len = b.option(
u8,
"block-len",
"how many bytes to consider when predicting the next character. " ++
"defaults to 8. " ++
"note: this may affect performance.",
) orelse 8;
const options = b.addOptions();
options.addOption(u8, "block_len", block_len);
exe.root_module.addOptions("build_options", options);
}
6 changes: 3 additions & 3 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
.name = "sus",
.version = "0.1.0",
.dependencies = .{
.@"zig-lsp" = .{
.url = "https://github.com/ziglibs/zig-lsp/archive/1c18c0c64b076e79385e525214a7acc4fdf7d398.tar.gz",
.hash = "12208c1385f4c1adca29fd17cc93397a60e54d5987bb27b9f961cb1945a96fc4a7e1",
.@"lsp-codegen" = .{
.url = "git+https://github.com/zigtools/zig-lsp-codegen.git#13d1d9e44e1c602953437438b163950298ff8d85",
.hash = "1220518fd5cefa481497bb3484ffab48a42e69c31088e37f52ea361f9ce884d2131c",
},
},
.paths = .{
Expand Down
113 changes: 113 additions & 0 deletions server/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sus</title>

<style>
:root {
--bg: hsl(0, 0%, 10%);
--fg: hsl(0, 0%, 90%);
}

html, body {
margin: 0;
padding: 0;

color: var(--fg);
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
background-color: var(--bg);
}

main {
padding: 2rem;
}

h1 {
margin: 0;
}

table, th, td {
border: 1px solid var(--fg);
border-collapse: collapse;
}

th, td {
padding: 0.45rem 0.3rem;
}

#entries {
list-style: none;
margin: 0;
padding: 0;
}

#entries>li {
margin-top: 1rem;

border: 1.5px solid var(--fg);
border-radius: 5px;
}

header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem;
font-size: 14pt;
cursor: pointer;
}
</style>
</head>
<body>
<main>
<h1>Zig Language Server Fuzzer</h1>

<p>Note that results are not expected to be long-lasting. When documenting a result, copy the reproduction steps.</p>

<ul id="entries">
<% for (const entry of entries) { %>
<li>
<article>
<header>
<code><%= entry.stderr.slice(0, entry.stderr.indexOf("\n")) %></code>
<time datetime="<%= new Date(entry.created_at).toISOString() %>"></time>
</header>
</article>
</li>
<% } %>
</ul>
</main>

<script>
const units = [
{unit: "year", ms: 31536000000},
{unit: "month", ms: 2628000000},
{unit: "day", ms: 86400000},
{unit: "hour", ms: 3600000},
{unit: "minute", ms: 60000},
{unit: "second", ms: 1000},
];
const rtf = new Intl.RelativeTimeFormat("en", {numeric: "auto"});

function relativeTimeFromDates(relative, pivot = new Date()) {
if (!relative) return "";
const elapsed = relative.getTime() - pivot.getTime();
return relativeTimeFromElapsed(elapsed);
}

function relativeTimeFromElapsed(elapsed) {
for (const {unit, ms} of units) {
if (Math.abs(elapsed) >= ms || unit === "second") {
return rtf.format(Math.round(elapsed / ms), unit);
}
}
return "";
}


[...document.querySelectorAll("time")].map(_ => _.innerText = relativeTimeFromDates(new Date(_.dateTime)));
</script>
</body>
</html>
Loading
Loading