mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
test_gen: make default option more obvious on wasm debug page
This commit is contained in:
parent
acc83bde7c
commit
f526005249
1 changed files with 38 additions and 17 deletions
|
@ -31,6 +31,10 @@
|
|||
font-weight: bold;
|
||||
padding: 4px 12px;
|
||||
}
|
||||
select {
|
||||
font-size: 18px;
|
||||
padding: 4px 12px;
|
||||
}
|
||||
small {
|
||||
font-style: italic;
|
||||
}
|
||||
|
@ -69,7 +73,7 @@
|
|||
In <code>gen_wasm/src/lib.rs</code>, set
|
||||
<code>DEBUG_LOG_SETTINGS.keep_test_binary = true</code>
|
||||
</li>
|
||||
<li>Run <code>cargo test-gen-wasm -- my_test --nocapture</code></li>
|
||||
<li>Run <code>cargo test-gen-wasm my_test_function_name</code></li>
|
||||
<li>
|
||||
Look for the path written to the console for
|
||||
<code>final.wasm</code> and select it in the file picker below
|
||||
|
@ -79,45 +83,62 @@
|
|||
<small> Control+Shift+I or Command+Option+I or F12 </small>
|
||||
</li>
|
||||
<li>
|
||||
Click one of the buttons below, depending on what kind of test it is.
|
||||
<br />
|
||||
<small>
|
||||
Only one of them will work. The other will probably crash or
|
||||
something.
|
||||
</small>
|
||||
If your test is from <code>gen_refcount.rs</code>
|
||||
</li>
|
||||
<li>
|
||||
The debugger should pause just before entering the first Wasm call.
|
||||
Step into a couple of Wasm calls until you reach your test code in
|
||||
<code>$#UserApp_main_1</code>
|
||||
<code>$main</code>
|
||||
</li>
|
||||
<li>
|
||||
Chrome DevTools now has a Memory Inspector panel! In the debugger,
|
||||
Chrome DevTools has a handy Memory Inspector panel. In the debugger,
|
||||
find <code>Module -> memories -> $memory</code>. Right click and
|
||||
select "Reveal in Memory Inspector"
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="controls">
|
||||
<div class="row">
|
||||
<label>
|
||||
<input type="checkbox" id="refcount-test">
|
||||
Check box if test is from <code>gen_refcount.rs</code>
|
||||
</label>
|
||||
</div>
|
||||
<div class="row row-file">
|
||||
<label for="wasm-file">Select final.wasm</label>
|
||||
<input id="wasm-file" type="file" />
|
||||
</div>
|
||||
<div id="error" class="row"></div>
|
||||
<div class="row">
|
||||
<button id="button-expression">Run as Roc expression test</button>
|
||||
<button id="button-refcount">Run as reference counting test</button>
|
||||
<button id="button-run">RUN</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<script>
|
||||
const file_input = document.getElementById("wasm-file");
|
||||
const button_expression = document.getElementById("button-expression");
|
||||
const button_refcount = document.getElementById("button-refcount");
|
||||
const refcount_checkbox = document.getElementById("refcount-test");
|
||||
const button = document.getElementById("button-run");
|
||||
const error_box = document.getElementById("error");
|
||||
|
||||
button_expression.onclick = runExpressionTest;
|
||||
button_refcount.onclick = runRefcountTest;
|
||||
if (localStorage.getItem("refcount-test")) {
|
||||
refcount_checkbox.checked = true;
|
||||
}
|
||||
refcount_checkbox.onchange = function (ev) {
|
||||
if (ev.target.checked) {
|
||||
localStorage.setItem("refcount-test", "true");
|
||||
} else {
|
||||
localStorage.removeItem("refcount-test");
|
||||
}
|
||||
}
|
||||
|
||||
button.onclick = function () {
|
||||
if (refcount_checkbox.checked) {
|
||||
runRefcountTest();
|
||||
} else {
|
||||
runExpressionTest();
|
||||
}
|
||||
}
|
||||
|
||||
file_input.onchange = function () {
|
||||
error_box.innerHTML = "";
|
||||
};
|
||||
|
@ -126,7 +147,7 @@
|
|||
const file = getFile();
|
||||
const instance = await compileFileToInstance(file);
|
||||
|
||||
debugger; // Next call is Wasm! Step into test_wrapper, then $#UserApp_main_1
|
||||
debugger; // Next call is Wasm! Step into test_wrapper, then $main
|
||||
instance.exports.test_wrapper();
|
||||
}
|
||||
|
||||
|
@ -137,7 +158,7 @@
|
|||
const refcount_vector_addr =
|
||||
instance.exports.init_refcount_test(MAX_ALLOCATIONS);
|
||||
|
||||
debugger; // Next call is Wasm! Step into test_wrapper, then $#UserApp_main_1
|
||||
debugger; // Next call is Wasm! Step into test_wrapper, then $main
|
||||
instance.exports.test_wrapper();
|
||||
|
||||
const words = new Uint32Array(instance.exports.memory.buffer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue