D
Deno

help

Coverage with subprocess

Rreed7/19/2023
One of my tests involves spawning a subprocess. Is there any way to get this subprocess to participate in the overall code coverage runs? By default it seems to not be included. I mean that lines executed by the subprocess don't get logged.
Bbartlomieju7/19/2023
You can use DENO_UNSTABLE_COVERAGE_DIR env var (though at your own risk since it's non public)
Rreed7/19/2023
And this should be set in the env property of the Deno.CommandOptions object I have? I tried this and I still couldn't generate coverage for my subprocess { args: ["run", "-A", "--unstable", name], env: { "DENO_UNSTABLE_COVERAGE_DIR": "cov", }, } is what i'm doing 🤷‍♂️
Bbartlomieju7/19/2023
Oh sorry... my bad. That env var is only supported in deno test subcommand. So it actually won't work. Feel free to open an issue about it. Should be quite a straightfoward fix
Rreed7/20/2023
thanks for the hint (via it only working for deno test) this gave me the confidence to look into rust for the first time. i eventually got it working. this was significantly complicated by the way i was writing my test in typescript: i wasn't properly shutting down the server from Deno.serve, which prevented anything after this block
.worker
.run_event_loop(maybe_coverage_collector.is_none())
.await?;
.worker
.run_event_loop(maybe_coverage_collector.is_none())
.await?;
from finishing (e.g. collecting coverage in the worker). after rearranging the tests (which allowed the worker to properly exit), then my first rust changed showed its effect <:party_deno:1035517691517218847> basically: serverProcess.kill("SIGTERM"); on the spawned subprocess is somehow too aggressive. instead of doing that after the test ends, i changed the way i launch the server to:
const ac = new AbortController();
start(manifest, {
signal: ac.signal,
});
setTimeout(() => ac.abort(), 10000);
const ac = new AbortController();
start(manifest, {
signal: ac.signal,
});
setTimeout(() => ac.abort(), 10000);
this has the downside of the test needing to finish in 10 seconds, but it at least allowed the coverage to complete. any explanation for this is appreciated. i will create a PR in the next few days for "allow DENO_UNSTABLE_COVERAGE_DIR in run subcommand"
Bbartlomieju7/20/2023
Ah great that it unblocked you. If you got it working for deno run make sure to open a PR 🙂
Rreed7/23/2023
cargo test is failing even without my changes. What's the right channel to get help with this? I'd love to move forward with the PR
Bbartlomieju7/23/2023
Is it failing locally or on CI? You can post in #dev
Rreed7/23/2023
Locally. I'll give it another shot tomorrow and then reach out to that channel. If I get my tests sorted should I add you to the PR?

Looking for more? Join the community!

Recommended Posts
How to exclude folder from deno lintI use WebStorm. How to exclude specific folder from deno lint? Is it possible in WebStorm? It is posTypeScript compiler type declarationsI'm using `import ts from "npm:typescript"` to work with the TypeScript compiler, but how do I get t[ignore] configuring botNothing to see here, ignore for now 🙂Reuse Deno.serve for other TCP connectionsHello, As a newcommer to Deno, I wrote a client for NNTP protocol (https://github.com/sntran/deno_ndeno coverage crashI run ``` deno test -A --coverage=tmp/coverageData src ``` then ``` deno coverage --include=src/ tmpIs there a way to copy an element and place it somewhere else?Link: https://stackoverflow.com/questions/76704496/is-there-a-way-to-copy-an-element-and-place-it-sonot sure why this code is erroring```typescript for (const number of genNumbers()) { const result = await fetchPages(number); if (Why doesn't POST response from serveTls support streaming chunks from a ReadableStream?We can POST a ReadableStream to a serveTls server, however when we respond with a ReadableStream theWhen I use npm: node: specifiers how can I specify the version?We know in Deno we can do `import { Client, Pool } from "https://deno.land/x/pg@v0.6.1/mod.ts";` I wFakeTime seems to break async testsI am attempting to use FakeTime similarly to in the Faking time example of https://deno.land/manual@How to serve HTTPS with the Deno.serve() APII used to start a dev server with TLS like so ```const server = Deno.listenTls({ port: 7000, trCustom console.log formatting for a class/objectIs there a way to change the way an object/class is printed in the console? For example, instead ofIs there a way to write to a file by replacing bytes?Like "I am a looong file" > write('Test') > 'Test a looong file'std/http/server: URI too long —how to avoid loading those?Using https://deno.land/std@0.194.0/http/server.ts, is there a way to reject long URIs before they aWorker: TS2304 [ERROR]: Cannot find name 'postMessage'When type-checking a worker script that uses the global `postMessage()` method, `deno check` gives aHow to recover from worker death? It terminates my main program…In the error message handler, I replace the dead worker with a new one, but it kills my program eithIs there anyone using kv with pentagon ORM and Zod ?I've tried using pentagon for Deno kv in a Fresh project, and it seems like it's not working.Prefix Kv keys with a base partCurrently I add `base()` to all keys: ``` kv.set([base(), "foo"], value) ``` Instead of manually adCaching old versionsWhy is deno caching old versions even tho the version is specifieddeno check: Module '"internal:///missing_dependency.d.ts"' has no exported member...The sequence of events: - Upgraded to Deno 1.35.0 - ran `deno check` on my code - got an error like