summaryrefslogtreecommitdiff
path: root/cli/tests
AgeCommit message (Collapse)Author
2023-08-26chore: update to Rust 1.72 (#20258)林炳权
<!-- Before submitting a PR, please read https://deno.com/manual/contributing 1. Give the PR a descriptive title. Examples of good title: - fix(std/http): Fix race condition in server - docs(console): Update docstrings - feat(doc): Handle nested reexports Examples of bad title: - fix #7123 - update docs - fix bugs 2. Ensure there is a related issue and it is referenced in the PR text. 3. Ensure there are tests that cover the changes. 4. Ensure `cargo test` passes. 5. Ensure `./tools/format.js` passes without changing files. 6. Ensure `./tools/lint.js` passes. 7. Open as a draft PR if your work is still in progress. The CI won't run all steps, but you can add '[ci]' to a commit message to force it to. 8. If you would like to run the benchmarks on the CI, add the 'ci-bench' label. --> As the title. --------- Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-08-26fix(kv) increase number of allowed mutations in atomic (#20126)Igor Zinkovsky
fixes #19741 Impose a limit on the total atomic payload size
2023-08-26fix(bench): explicit timers don't force high precision measurements (#20272)Nayeem Rahman
Disables `BenchContext::start()` and `BenchContext::end()` for low precision benchmarks (less than 0.01s per iteration). Prints a warning when they are used in such benchmarks, suggesting to remove them. ```ts Deno.bench("noop", { group: "noops" }, () => {}); Deno.bench("noop with start/end", { group: "noops" }, (b) => { b.start(); b.end(); }); ``` Before: ``` cpu: 12th Gen Intel(R) Core(TM) i9-12900K runtime: deno 1.36.2 (x86_64-unknown-linux-gnu) file:///home/nayeem/projects/deno/temp3.ts benchmark time (avg) iter/s (min … max) p75 p99 p995 ----------------------------------------------------------------------------- ----------------------------- noop 2.63 ns/iter 380,674,131.4 (2.45 ns … 27.78 ns) 2.55 ns 4.03 ns 5.33 ns noop with start and end 302.47 ns/iter 3,306,146.0 (200 ns … 151.2 µs) 300 ns 400 ns 400 ns summary noop 115.14x faster than noop with start and end ``` After: ``` cpu: 12th Gen Intel(R) Core(TM) i9-12900K runtime: deno 1.36.1 (x86_64-unknown-linux-gnu) file:///home/nayeem/projects/deno/temp3.ts benchmark time (avg) iter/s (min … max) p75 p99 p995 ----------------------------------------------------------------------------- ----------------------------- noop 3.01 ns/iter 332,565,561.7 (2.73 ns … 29.54 ns) 2.93 ns 5.29 ns 7.45 ns noop with start and end 7.73 ns/iter 129,291,091.5 (6.61 ns … 46.76 ns) 7.87 ns 13.12 ns 15.32 ns Warning start() and end() calls in "noop with start and end" are ignored because it averages less than 0.01s per iteration. Remove them for better results. summary noop 2.57x faster than noop with start and end ```
2023-08-26fix(node): propagate create cipher errors (#20280)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/19002
2023-08-26fix(lsp): implement deno.suggest.completeFunctionCalls (#20214)Nayeem Rahman
Fixes https://github.com/denoland/vscode_deno/issues/743. ```ts const items: string[] = ['foo', 'bar', 'baz']; items.map // -> items.map(callbackfn) // auto-completes with argument placeholders. ``` --- We have our own setting for `suggest.completeFunctionCalls`, which must be enabled: ```js { "deno.suggest.completeFunctionCalls": true, // Re-implementation of: // "javascript.suggest.completeFunctionCalls": true, // "typescript.suggest.completeFunctionCalls": true, } ``` But before this commit the actual implementation had been left as a TODO.
2023-08-26feat(cli/tools): add TAP test reporter (#14390) (#20073)Valentin Anger
This PR adds a test reporter for the [Test Anything Protocol](https://testanything.org). It makes the following implementation decisions: - No TODO pragma, as there is no such marker in `Deno.test` - SKIP pragma for `ignore`d tests - Test steps are treated as TAP14 subtests - Support for this in consumers seems spotty - Some consumers will incorrectly interpret these markers, resulting in unexpected output - Considering the lack of support, and to avoid implementation complexity, subtests are at most one level deep (all test steps are in the same subtest) - To accommodate consumers that use comments to indicate test-suites (unspecced) - The test module path is output as a comment - This is disabled for `--parallel` testing - Failure diagnostics are output as JSON, which is also valid YAML - The structure is not specified, so the format roughly follows the spec example: ``` --- message: "Failed with error 'hostname peebles.example.com not found'" severity: fail found: hostname: 'peebles.example.com' address: ~ wanted: hostname: 'peebles.example.com' address: '85.193.201.85' at: file: test/dns-resolve.c line: 142 ... ```
2023-08-25fix(lsp): test explorer panic on step result (#20289)Nayeem Rahman
Fixes https://github.com/denoland/vscode_deno/issues/843. Prevents step results from being reported twice. Refactors `LspTestReporter` to use a complete `(test_id, descriptor)` map instead of a brittle `LspTestReporter::stack`.
2023-08-23fix(ext/web): add stream tests to detect v8slice split bug (#20253)Matt Mastracci
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-08-22fix(ext/web): better handling of errors in resourceForReadableStream (#20238)Matt Mastracci
Improves error handling when the Resource is closed in various phases of the ReadableStream. Ensure that we send a consistent `cancel` reason.
2023-08-22fix(ext/node): simultaneous reads can leak into each other (#20223)Matt Mastracci
Reported in #20188 This was caused by re-use of a global buffer `BUF` during simultaneous async reads.
2023-08-22fix(cli): add timeout on inspector tests (#20225)Matt Mastracci
I believe this test locked up on this run below: https://github.com/denoland/deno/actions/runs/5928630684/job/16074661291
2023-08-22feat(ext/kv): connect to remote database (#20178)Heyang Zhou
This patch adds a `remote` backend for `ext/kv`. This supports connection to Deno Deploy and potentially other services compatible with the KV Connect protocol.
2023-08-21refactor: upgrade deno_ast 0.28 and deno_semver 0.4 (#20193)David Sherret
2023-08-21fix(ext/http): ensure request body resource lives as long as response is ↵Matt Mastracci
alive (#20206) Deno.serve's fast streaming implementation was not keeping the request body resource ID alive. We were taking the `Rc<Resource>` from the resource table during the response, so a hairpin duplex response that fed back the request body would work. However, if any JS code attempted to read from the request body (which requires the resource ID to be valid), the response would fail with a difficult-to-diagnose "EOF" error. This was affecting more complex duplex uses of `Deno.fetch` (though as far as I can tell was unreported). Simple test: ```ts const reader = request.body.getReader(); return new Response( new ReadableStream({ async pull(controller) { const { done, value } = await reader.read(); if (done) { controller.close(); } else { controller.enqueue(value); } }, }), ``` And then attempt to use the stream in duplex mode: ```ts async function testDuplex( reader: ReadableStreamDefaultReader<Uint8Array>, writable: WritableStreamDefaultWriter<Uint8Array>, ) { await writable.write(new Uint8Array([1])); const chunk1 = await reader.read(); assert(!chunk1.done); assertEquals(chunk1.value, new Uint8Array([1])); await writable.write(new Uint8Array([2])); const chunk2 = await reader.read(); assert(!chunk2.done); assertEquals(chunk2.value, new Uint8Array([2])); await writable.close(); const chunk3 = await reader.read(); assert(chunk3.done); } ``` In older versions of Deno, this would just lock up. I believe after 23ff0e722e3c4b0827940853c53c5ee2ede5ec9f, it started throwing a more explicit error: ``` httpServerStreamDuplexJavascript => ./cli/tests/unit/serve_test.ts:1339:6 error: TypeError: request or response body error: error reading a body from connection: Connection reset by peer (os error 54) at async Object.pull (ext:deno_web/06_streams.js:810:27) ```
2023-08-18ci: try to fix flaky stdio_streams_are_locked_in_permission_prompt (#20204)David Sherret
2023-08-18fix(node/http): emit error when addr in use (#20200)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/20186
2023-08-18feat(ext/kv): key expiration (#20091)Heyang Zhou
Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-08-17fix(test): JUnit reporter includes file, line and column attributes (#20174)Alexander Michaud
Closes #20156
2023-08-17fix(unstable): disable importing from the vendor directory (#20067)David Sherret
Some people might get think they need to import from this directory, which could cause confusion and duplicate dependencies. Additionally, the `vendor` directory has special behaviour in the language server, so importing from the folder will definitely cause confusion and issues there.
2023-08-17fix(npm): do not panic providing file url to require.resolve paths (#20182)David Sherret
Closes #19922
2023-08-17feat(ext/web): resourceForReadableStream (#20180)Matt Mastracci
Extracted from fast streams work. This is a resource wrapper for `ReadableStream`, allowing us to treat all `ReadableStream` instances as resources, and remove special paths in both `fetch` and `serve`. Performance with a ReadableStream response yields ~18% improvement: ``` return new Response(new ReadableStream({ start(controller) { controller.enqueue(new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100])); controller.close(); } }) ``` This patch: ``` 12:36 $ third_party/prebuilt/mac/wrk http://localhost:8080 Running 10s test @ http://localhost:8080 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 99.96us 100.03us 6.65ms 98.84% Req/Sec 47.73k 2.43k 51.02k 89.11% 959308 requests in 10.10s, 117.10MB read Requests/sec: 94978.71 Transfer/sec: 11.59MB ``` main: ``` Running 10s test @ http://localhost:8080 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 163.03us 685.51us 19.73ms 99.27% Req/Sec 39.50k 3.98k 66.11k 95.52% 789582 requests in 10.10s, 82.83MB read Requests/sec: 78182.65 Transfer/sec: 8.20MB ```
2023-08-17fix(ext/kv): retry transaction on `SQLITE_BUSY` errors (#20189)Heyang Zhou
Properly handle the `SQLITE_BUSY` error code by retrying the transaction. Also wraps database initialization logic in a transaction to protect against incomplete/concurrent initializations. Fixes https://github.com/denoland/deno/issues/20116.
2023-08-17perf(ext/event): optimize Event constructor (#20181)Marcos Casagrande
This PR optimizes `Event` constructor - ~Added a fast path for empty `eventInitDict`~ Removed `EventInit` dictionary converter - Don't make `isTrusted` a [LegacyUnforgeable](https://webidl.spec.whatwg.org/#LegacyUnforgeable) property. Doing so makes it non-spec compliant but calling `Object/Reflect.defineProperty` on the constructor is a big bottleneck. Node did the same a few months ago https://github.com/nodejs/node/pull/46974. In my opinion, the performance gains are worth deviating from the spec for a browser-related property. **This PR** ``` cpu: 13th Gen Intel(R) Core(TM) i9-13900H runtime: deno 1.36.1 (x86_64-unknown-linux-gnu) benchmark time (avg) iter/s (min … max) p75 p99 p995 ------------------------------------------------------------------------------- ----------------------------- event constructor no init 36.69 ns/iter 27,257,504.6 (33.36 ns … 42.45 ns) 37.71 ns 39.61 ns 40.07 ns event constructor 36.7 ns/iter 27,246,776.6 (33.35 ns … 56.03 ns) 37.73 ns 40.14 ns 41.74 ns ``` **main** ``` cpu: 13th Gen Intel(R) Core(TM) i9-13900H runtime: deno 1.36.1 (x86_64-unknown-linux-gnu) benchmark time (avg) iter/s (min … max) p75 p99 p995 ------------------------------------------------------------------------------- ----------------------------- event constructor no init 380.48 ns/iter 2,628,275.8 (366.66 ns … 399.39 ns) 384.58 ns 398.27 ns 399.39 ns event constructor 480.33 ns/iter 2,081,882.6 (466.67 ns … 503.47 ns) 484.27 ns 501.28 ns 503.47 ns ``` ```js Deno.bench("event constructor no init", () => { const event = new Event("foo"); }); Deno.bench("event constructor", () => { const event = new Event("foo", { bubbles: true, cancelable: false }); }); ``` towards https://github.com/denoland/deno/issues/20167
2023-08-16fix: release ReadeableStream in fetch (#17365)Leo Kettmeir
Fixes #16648 --------- Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
2023-08-16fix(ext/node): allow for the reassignment of userInfo() on Windows (#20165)Evan
The goal of this PR is to address issue #20106 where a `TypeError` occurs when the variables `uid` and `gid` from `userInfo()` in `node:os` are reassigned if the user is on Windows. Both `uid` and `gid` are marked as `const` therefore producing a `TypeError` when the two are reassigned. This PR achieves that goal by marking `uid` and `gid` as `let`
2023-08-15fix(runtime): use host header for inspector websocket URL (#20171)Matt Mastracci
If a `host` header is specified, use that for the generated websocket URLs. Fixes #20087
2023-08-15fix(runtime): navigator.userAgent in web worker (#20129)await-ovo
Fixes https://github.com/denoland/deno/issues/20079 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-08-15fix(ext/net): implement a graceful error on an invalid SSL certificate (#20157)Evan
The goal of this PR is to address issue #19520 where Deno panics when encountering an invalid SSL certificate. This PR achieves that goal by removing an `.expect()` statement and implementing a match statement on `tsl_config` (found in [/ext/net/ops_tsl.rs](https://github.com/denoland/deno/blob/e071382768fa57b5288a6a5ba90e73bf5870b169/ext/net/ops_tls.rs#L1058)) to check whether the desired configuration is valid --------- Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-08-12chore: deno_core -> 0.201.0 (#20135)Matt Mastracci
2023-08-11fix(node): implement TLSSocket._start (#20120)Divy Srivastava
Closes https://github.com/denoland/deno/issues/19983 Closes https://github.com/denoland/deno/issues/18303 Closes https://github.com/denoland/deno/issues/16681 Closes https://github.com/denoland/deno/issues/19978
2023-08-11fix(ext/node): support dictionary option in zlib init (#20035)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/19540
2023-08-11fix(node): object keys in publicEncrypt (#20128)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/19935
2023-08-10chore: upgrade fastwebsockets to 0.4.4 (#19089)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/19041
2023-08-10fix(ext/timers): some timers are not resolved (#20055)Bartek Iwańczuk
Fixes https://github.com/denoland/deno/issues/19866
2023-08-10fix(test): handle ASCII escape chars in test name (#20081)Bartek Iwańczuk
Handles ASCCI espace chars in test and bench name making test and bench reporting more reliable. This one is also tested in the fixture of "node:test" module.
2023-08-08refactor(cli): move `snapshot_from_lockfile` function to `deno_npm` (#20024)Yusuke Tanaka
This commit moves `snapshot_from_lockfile` function to [deno_npm crate](https://github.com/denoland/deno_npm). This allows this function to be called outside Deno CLI (in particular, Deno Deploy).
2023-08-06feat(unstable): rename `deno_modules` to `vendor` (#20065)David Sherret
Renames the unstable `deno_modules` directory and corresponding settings to `vendor` after feedback. Also causes the vendoring of the `node_modules` directory which can be disabled via `--node-modules-dir=false` or `"nodeModulesDir": false`.
2023-08-06fix(unstable): vendor cache should support adding files to hashed ↵David Sherret
directories (#20070) This changes the design of the manifest.json file to have a separate "folders" map for mapping hashed directories. This allows, for example, to add files in a folder like `http_localhost_8000/#testing_5de71/` and have them be resolved automatically as long as their remaining components are identity-mappable to the file system (not hashed). It also saves space in the manifest.json file by only including the hashed directory instead of each descendant file. ``` // manifest.json { "folders": { "https://localhost/NOT_MAPPABLE/": "localhost/#not_mappable_5cefgh" }, "modules": { "https://localhost/folder/file": { "headers": { "content-type": "application/javascript" } }, } } // folder structure localhost - folder - #file_2defn (note: I've made up the hashes in these examples) - #not_mappable_5cefgh - mod.ts - etc.ts - more_files.ts ```
2023-08-05chore: use zlib-ng for flate2 (#20059)Matt Mastracci
Extracted from PR #16011
2023-08-04fix(test): make test runner work when global setTimeout is replaced (#20052)Yoshiya Hinosawa
2023-08-04fix(node): polyfill process.title (#20044)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/19777
2023-08-04fix(node): repl._builtinLibs (#20046)Bartek Iwańczuk
Ref https://github.com/denoland/deno/issues/19733
2023-08-03feat(permissions): add "--deny-*" flags (#19070)Asher Gomez
This commit adds new "--deny-*" permission flags. These are complimentary to "--allow-*" flags. These flags can be used to restrict access to certain resources, even if they were granted using "--allow-*" flags or the "--allow-all" ("-A") flag. Eg. specifying "--allow-read --deny-read" will result in a permission error, while "--allow-read --deny-read=/etc" will allow read access to all FS but the "/etc" directory. Runtime permissions APIs ("Deno.permissions") were adjusted as well, mainly by adding, a new "PermissionStatus.partial" field. This field denotes that while permission might be granted to requested resource, it's only partial (ie. a "--deny-*" flag was specified that excludes some of the requested resources). Eg. specifying "--allow-read=foo/ --deny-read=foo/bar" and then querying for permissions like "Deno.permissions.query({ name: "read", path: "foo/" })" will return "PermissionStatus { state: "granted", onchange: null, partial: true }", denoting that some of the subpaths don't have read access. Closes #18804. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2023-08-02refactor: use '--reporter' and '--junit-path' flags for 'deno test' (#20031)Bartek Iwańczuk
This commit adds "--reporter" and "--junit-path" flags to "deno test" subcommand instead of using "--dot" and "--junit" flags.
2023-08-02feat(unstable/lsp): support navigating to deno_modules folder (#20030)David Sherret
Closes #20015 Closes https://github.com/denoland/vscode_deno/issues/850 (only for deno_modules, but I don't think this will be possible for the global cache)
2023-08-02feat(cli): Add dot test reporter (#19804)Bartek Iwańczuk
This commit adds a "dot" reporter to "deno test" subcommand, that can be activated using "--dot" flag. It provides a concise output using: - "." for passing test - "," for ignored test - "!" for failing test User output is silenced and not printed to the console. In non-TTY environments each result is printed on a separate line.
2023-08-02fix(node): node:test reports correct location (#20025)Bartek Iwańczuk
Also removed some noisy output that caused test flakiness.
2023-08-02fix: regression in workers using dynamic imports (#20006)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/19903
2023-08-02feat(unstable): optional `deno_modules` directory (#19977)David Sherret
Closes #15633
2023-08-01feat(bench): print iter/s in the report (#19994)Bartek Iwańczuk
This commit adds "iter/s" column to the console report generated by "deno bench" subcommand.