Commit graph

6104 commits

Author SHA1 Message Date
David Sherret 6f278e5c40
fix(lsp): improved cjs tracking (#23374)
Our cjs tracking was a bit broken. It was marking stuff as esm that was
actually cjs leading to type checking errors.
2024-04-15 17:50:52 -04:00
Matt Mastracci 7e4ee02e2e
fix(ext/io): Fix NUL termination error in windows named pipes (#23379)
Due to a terminating NUL that was placed in a `r#` string, we were not
actually NUL-terminating pipe names on Windows. While this has no
security implications due to the random nature of the prefix, it would
occasionally cause random failures when the trailing garbage would make
the pipe name invalid.
2024-04-15 14:10:09 -06:00
Bartek Iwańczuk a080acc1b4
refactor: move lifecycle events dispatch to Rust (#23358)
This commit moves logic of dispatching lifecycle events (
"load", "beforeunload", "unload") to be triggered from Rust.
Before that we were executing scripts from Rust, but now we
are storing references to functions from "99_main.js" and calling
them directly.

Prerequisite for https://github.com/denoland/deno/issues/23342
2024-04-15 20:08:33 +02:00
David Sherret 1835b4f061
fix(lsp): ensure project version is incremented when config changes (#23366)
I'm running into a node resolution bug in the lsp only and while
tracking it down I noticed this one.

Fixed by moving the project version out of `Documents`.
2024-04-15 00:07:04 +00:00
Nayeem Rahman 8f1a92f3c3
refactor(lsp): use fallback resolution in op_resolve() (#23329) 2024-04-14 22:42:58 +01:00
David Sherret e277490c82
perf: do not clone swc Program when transpiling (#23365) 2024-04-14 17:15:17 -04:00
David Sherret 76df7d7c9b
fix(publish): do not error for param with initializer before required parameter (#23356)
* https://github.com/denoland/deno_graph/pull/440

Closes https://github.com/denoland/deno/issues/23331
2024-04-13 22:20:58 -04:00
David Sherret 720e45d25b
fix(publish): handle definite assignment on ts private properties (#23345) 2024-04-12 19:56:29 -04:00
Nathan Whitaker 3dacba5057
perf(lsp): Only deserialize response from op_respond once (#23349)
Previously we were deserializing it twice - once to `serde_json::Value`,
and then again from the `serde_json::Value` to a concrete type
2024-04-12 16:04:54 -07:00
Divy Srivastava c56f2e0fc0
chore: upgrade deno_core to 0.274.0 (#23344)
Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-04-12 21:45:38 +02:00
youngwendy 84e198f0d0
chore: remove repetitive words (#23341)
Signed-off-by: youngwendy <clonefetch@outlook.com>
2024-04-12 08:33:43 -06:00
Luca Casonato 650db71e35
chore: update deno_graph (#23340) 2024-04-12 13:10:57 +00:00
denobot c92f118652
chore: forward v1.42.3 release commit to main (#23335)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
2024-04-12 04:19:46 +00:00
David Sherret 98077e4b3c
fix(publish): do not warn about excluded external modules in node_modules directory (#23173) 2024-04-11 23:52:35 +00:00
Bartek Iwańczuk f358ae6278
fix(inspector): don't panic if port is not free (#22745)
Closes https://github.com/denoland/deno/issues/22113
Closes https://github.com/denoland/deno/issues/23177
Closes https://github.com/denoland/deno/issues/22883
Closes https://github.com/denoland/deno/issues/22377
2024-04-12 01:17:10 +02:00
David Sherret ade0cd5e97
fix: upgrade deno_ast related crates (#23187)
Had to revert back swc due to
https://github.com/swc-project/swc/issues/8840

Fixes:

- https://github.com/denoland/deno_lint/pull/1262
- https://github.com/denoland/deno_doc/pull/538
- https://github.com/denoland/deno_doc/pull/537
- https://github.com/denoland/deno_graph/pull/430
- https://github.com/denoland/deno_graph/pull/425
- https://github.com/denoland/deno_graph/pull/432
2024-04-11 23:00:17 +00:00
Nayeem Rahman f1ea8ca358
perf(lsp): use a stub module in tsc for failed resolutions (#23313) 2024-04-11 21:55:27 +01:00
Bartek Iwańczuk 5758470ee4
Revert "refactor(ext/net): extract TLS key and certificate from inter… (#23325)
…faces (#23296)"

This reverts commit e190acbfa8.

Reverting because it broke stable API type declarations. We will reland
it for v1.43 with updated interfaces
2024-04-11 20:31:11 +00:00
Nathan Whitaker 4ab0215727
fix(lsp): Denormalize specifiers before calling $projectChanged (#23322)
Fixes the regression described in
https://github.com/denoland/deno/pull/23293#issuecomment-2049819724.
This affected jupyter notebooks, as the LSP was passing in already
denormalized specifiers, while the jupyter kernel was not. We need to
denormalize the specifiers to evict the proper keys from our caches.
2024-04-11 18:33:03 +00:00
David Sherret df73db671b
fix(npm): local nodeModulesDir was sometimes resolving duplicates of same package (#23320) 2024-04-11 13:18:19 -04:00
denobot ca7432b86b
chore: forward v1.42.2 release commit to main (#23315)
Co-authored-by: Satya Rohith <me@satyarohith.com>
2024-04-11 13:37:24 +05:30
Nayeem Rahman 34e1d0cdd4
perf(lsp): replace document registry source cache on update (#23311) 2024-04-11 02:57:22 +01:00
Nathan Whitaker 736f73b008
perf(lsp): Only evict caches on JS side when things actually change (#23293)
Currently we evict a lot of the caches on the JS side of things on every
request, namely script versions, script file names, and compiler
settings (as of #23283, it's not quite every request but it's still
unnecessarily often).

This PR reports changes to the JS side, so that it can evict exactly the
caches that it needs too. We might want to do some batching in the
future so as not to do 1 request per change.
2024-04-10 18:06:37 -07:00
林炳权 9304126be5
chore: update to Rust 1.77.2 (#23262)
update to Rust 1.77.2


---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-04-10 22:08:23 +00:00
Asher Gomez c6f1107e9c
chore: update references to deno_std to use JSR (#23239)
There are more uses of `deno.land/std` in the codebase, but for URL
parsing purposes rather than network calls or documentation.
2024-04-10 17:26:35 -04:00
Nayeem Rahman 7c5745a204
refactor(lsp): cleanup documents dependents calculation (#23295) 2024-04-10 19:58:49 +01:00
Asher Gomez 08f46ac446
fix(ext/fs): account for all ops in leak checks (#23300)
This is PR a smaller retry of #23066 that simply ensures all async
`ext/fs` ops are accounted for if left hanging in tests. This also sorts
the `OP_DETAILS` in alphabetical order for easy future reading.

When reviewing, it might be best to look at the commits in order for
better understanding.
2024-04-10 02:47:01 +00:00
Matt Mastracci e190acbfa8
refactor(ext/net): extract TLS key and certificate from interfaces (#23296)
Removes the certificate options from all the interfaces and replaces
them with a new `TlsCertifiedKeyOptions`. This allows us to centralize
the documentation for TLS key management for both client and server, and
will allow us to add key object support in the future.

Also adds an option `keyFormat` field to the cert/key that must be
omitted or set to `pem`. This will allow us to load other format keys in
the future `der`, `pfx`, etc.

In a future PR, we will add a way to load a certified key object, and we
will add another option to `TlsCertifiedKeyOptions` like so:

```ts
export interface TlsCertifiedKeyOptions =
    | TlsCertifiedKeyPem
    | TlsCertifiedKeyFromFile
    | TlsCertifiedKeyConnectTls
    | { key: Deno.CertifiedKey }
```
2024-04-09 16:23:22 -06:00
Nathan Whitaker f23155bca7
perf(lsp): More granular locking of FileSystemDocuments (#23291)
Previously we locked the entire `FileSystemDocuments` even for lookups,
causing contention. This was particularly bad because some of the hot
ops (namely `op_resolve`) can end up hitting that lock under contention.

This PR replaces the mutex with synchronization internal to
`FileSystemDocuments` (an `AtomicBool` for the dirty flag, and then a
`DashMap` for the actual documents).

I need to think a bit more about whether or not this introduces any
problematic race conditions.
2024-04-09 15:12:55 -07:00
Carlos Precioso ecfc6b6413
docs: Fix typo "discreet" to "discrete" (#23290)
Changes `discreet` in the documentation for `discrete`

"Discreet" means careful to avoid being noticed, "discrete" means
separate parts, and is what the documentation refers to.
2024-04-09 13:59:54 -06:00
Asher Gomez 6157c85634
refactor: use chrono::DateTime::from_timestamp (#23273)
`chrono::NaiveDateTime::from_timestamp_opt()` was deprecated in
https://github.com/chronotope/chrono/pull/1473.

Prerequisite for #23272.
2024-04-08 21:46:54 +00:00
Nayeem Rahman 214bfa37aa
perf(lsp): cache ts config in isolate until new project version (#23283) 2024-04-08 22:20:20 +01:00
Asher Gomez 3826598974
chore: update deprecation notices of APIs to be soft-removed (#23076) 2024-04-09 06:53:02 +10:00
Asher Gomez 03b84197a0
chore: update WPT (#23111)
Should fix some of the current issues with the `wpt_epoch` workflow.

See
https://github.com/denoland/deno/actions/runs/8460701853/job/23179358486

---------

Co-authored-by: crowlkats <crowlkats@toaxl.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-04-08 20:46:53 +02:00
Nayeem Rahman 3c346c8ea6
perf(lsp): don't pass remote modules as tsc roots (#23259) 2024-04-08 19:45:20 +01:00
Nayeem Rahman 9752a153ea
Revert "perf(lsp): Don't retain SourceFileObjects in sourceFileCache longer than necessary (#23258)" (#23285) 2024-04-08 18:57:25 +01:00
Nathan Whitaker b74a4f29f2
perf(lsp): Don't retain SourceFileObjects in sourceFileCache longer than necessary (#23258)
The TS language service requests source files via
[getSourceFile](7a25fd5ef0/cli/tsc/99_main_compiler.js (L560)).
In that function, we [unconditionally
add](7a25fd5ef0/cli/tsc/99_main_compiler.js (L613-L614))
the source file to our sourceFileCache. The issue is that we only remove
things from that cache if the source file [becomes out of
date](7a25fd5ef0/cli/tsc/99_main_compiler.js (L777-L783)).
For files that don't get changed, we keep them in the cache
indefinitely. So sometimes we keep SourceFile objects from being GC'ed
because they're retained in our cache, even though TS doesn't refer to
them any more. I see this in pretty much all of the heap snapshots I've
taken.

---

The fix here is pretty direct - just store weak references to the
sourcefiles in the cache. It doesn't really change our caching behavior,
it just prevents us from being the only retainer of a `SourceFile`. I
also split the `sourceFileCache` into a separate cache just for assets,
as we rely on those being alive.

The simpler fix is to only cache assets, but presumably that has a perf
impact.

---
In local testing, this PR reduced the size of the JS heap by about 1 GB
when using `deno lsp` in the Typescript repo.
2024-04-06 19:22:37 -07:00
Nayeem Rahman f9f37963b7
refactor(lsp): remove DocumentInner (#23251) 2024-04-06 15:36:43 +01:00
David Sherret 83f92474c5
perf(lsp): use lockfile to reduce npm pkg resolution time (#23247)
This functionality was broken. The series of events was:

1. Load the npm resolution from the lockfile.
2. Discover only a subset of the specifiers in the documents.
3. Clear the npm snapshot.
4. Redo npm resolution with the new specifiers (~500ms).

What this now does:

1. Load the npm resolution from the lockfile.
2. Discover only a subset of the specifiers in the documents and take
into account the specifiers from the lockfile.
3. Do not redo resolution (~1ms).
2024-04-05 22:33:01 +00:00
Nayeem Rahman 61f1b8e8dc
fix(lsp): respect DENO_FUTURE for BYONM config (#23207) 2024-04-05 16:18:48 +01:00
David Sherret 049e703331
FUTURE: override byonm with nodeModulesDir setting (#23222)
Makes the `"nodeModulesDir"` setting take precedence over byonm when
using `DENO_FUTURE`.
2024-04-05 10:34:51 -04:00
Nayeem Rahman 7446b0163d
perf(lsp): don't keep remote module ast's in memory (#23230) 2024-04-04 23:39:17 +01:00
JOTSR 5dda32088a
fix(cli): update deno doc help to fit current usage (#23224) 2024-04-04 22:03:29 +00:00
Matt Mastracci 7cc584ed79
fix(cli): fix deadlock in test writer when test pipe is full (#23210)
The tests would deadlock if we tried to write the sync marker into a
pipe that was full because one test streamed just enough data to fill
the pipe, so when we went to actually write the sync marker we blocked
when nobody was reading.

We use a two-phase lock for sync markers now: one to indicate "ready to
sync" and the second to indicate that the sync bytes have been received.
2024-04-04 18:06:58 +00:00
Asher Gomez 207349cfb7
FUTURE: remove deprecated APIs within workers (#23220) 2024-04-05 03:27:18 +11:00
Bartek Iwańczuk de3f0b93f5
refactor(flags): prepare for deno install changes (#23217)
This commit adds enum to "InstallFlags" and "UninstallFlags" that will
allow to support both local and global (un)installation.

Currently the local variant is not used.

Towards https://github.com/denoland/deno/issues/23062
2024-04-04 14:40:54 +00:00
Nathan Whitaker 92a8ada719
fix(lsp): Remove client-facing format failure warning (#23196)
Fixes #23163.

The client-facing warning doesn't provide any value and is super
annoying. We still emit a warning message on the server side for format
errors, which should fulfill the same (less intrusive) purpose.
2024-04-02 19:10:40 -07:00
Bartek Iwańczuk c0b7454175
FUTURE: enable BYONM by default (#23194)
When `DENO_FUTURE=1` env var is present, then BYONM
("bring your own node_modules") is enabled by default.
That means that is there's a `package.json` present, users
are expected to explicitly install dependencies from that file.

Towards https://github.com/denoland/deno/issues/23151
2024-04-03 00:43:03 +02:00
Nayeem Rahman 2b1c6e172e
feat(lsp): respect nested deno.json for fmt and lint config (#23159) 2024-04-02 23:02:50 +01:00
David Sherret b0c1bd82a8
fix: prevent cache db errors when deno_dir not exists (#23168)
Closes #20202
2024-04-01 18:58:52 -04:00
David Sherret 240b362c00
perf(node): put pkg json into an Rc (#23156)
Was doing a bit of debugging on why some stuff is not working in a
personal project and ran a quick debug profile and saw it cloning the
pkg json a lot. We should put this in an Rc.
2024-04-01 09:10:04 -04:00
denobot 8d158058e5
chore: forward v1.42.1 release commit to main (#23162)
This is the release commit being forwarded back to main for 1.42.1

Co-authored-by: littledivy <littledivy@users.noreply.github.com>
2024-04-01 13:35:46 +05:30
David Sherret b8af46e007
fix(check): ignore certain diagnostics in remote modules and when publishing (#23119)
Unused locals and parameters don't make sense to surface in remote
modules. Additionally, fast check can cause these kind of diagnostics
when publishing, so they should be ignored.

Closes #22959
2024-03-31 16:39:40 -04:00
Nayeem Rahman 0144594044
fix(lsp): don't apply preload limit to workspace walk (#23123) 2024-03-31 21:39:23 +01:00
David Sherret db89ce33f4
chore(lsp): remove recursion in recurse_dependents (#23153)
Was investigating a separate stack overflow (that I've now found in the
node resolution code) and came across this. We should avoid recursion
(this is very old code).
2024-03-31 13:04:42 -04:00
David Sherret eb6f6ff33d
refactor: cleanup main entrypoint (#23145) 2024-03-31 10:58:19 -04:00
David Sherret d0a579a7b2
fix: deno_graph 0.69.10 (#23147)
* https://github.com/denoland/deno_graph/issues/420
* https://github.com/denoland/deno_graph/pull/424
2024-03-31 04:06:29 +01:00
Nayeem Rahman 524e451bfb
fix(lsp): implement missing ts server host apis (#23131) 2024-03-29 20:00:58 +00:00
Nayeem Rahman d347e73f5a
fix(jsr): exclude yanked versions from 'deno add' and completions (#23113) 2024-03-28 19:02:07 +00:00
denobot 9c6eca1064
1.42.0 (#23105)
Bumped versions for 1.42.0

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-03-28 01:47:33 +01:00
Leo Kettmeir dc985954e1
chore: update deno_doc to 0.119.0 (#23103) 2024-03-28 00:25:39 +01:00
Łukasz Czerniawski 08d5d32dfc
feat: add --watch-exclude flag (#21935)
This PR introduces the ability to exclude certain paths from the file watcher
in Deno. This is particularly useful when running scripts in watch mode,
as it allows developers to prevent unnecessary restarts when changes are
made to files that do not affect the running script, or when executing
scripts that generate new files which results in an infinite restart
loop.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2024-03-27 22:47:46 +00:00
Bartek Iwańczuk d31f2307ee
feat(install): require -g / --global flag (#23060)
In preparation for upcoming changes to `deno install` in Deno 2.

If `-g` or `--global` flag is not provided a warning will be emitted:
```
⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use `-g` or `--global` flag.
```

The same will happen for `deno uninstall` - unless `-g`/`--global` flag
is provided
a warning will be emitted.

Towards https://github.com/denoland/deno/issues/23062

---------

Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2024-03-27 23:45:57 +01:00
Nathan Whitaker 2dc37f411e
feat(task): Task description in the form of comments (#23101)
Closes #22786.

TLDR;
```jsonc
{
  "tasks": {
    // Some comment
    //
    // describing what the task does
    "dev": "deno run -A --watch main.ts"
  }
}
```
```bash
deno task
```
![Screenshot 2024-03-27 at 1 43
49 PM](https://github.com/denoland/deno/assets/17734409/7a14da8c-8e63-45ba-9bfb-590d250b56a9)
2024-03-27 14:14:27 -07:00
David Sherret 68fecc6de4
fix: less aggressive vendor folder ignoring (#23100)
This is slightly breaking as some users want the `vendor` folder
excluded and may not have that specified in their deno.json.

Closes #22833
2024-03-27 14:25:39 -04:00
Bartek Iwańczuk 0e4d1cb5f9
feat(init): use jsr specifier for @std/assert (#23073)
This commit changes "deno init" subcommand to use "jsr:" specifier for
standard library "assert" module. It is unversioned, but we will change
it to `@^1` once `@std/assert` release version 1.0.

This allows us to start decoupling `deno` and `deno_std` release. The
release scripts have been updated to take that into account.
2024-03-27 18:51:52 +01:00
David Sherret 624e3a04e7
feat(task): cross-platform shebang support (#23091)
Adds cross-platform shebang support (supports using shebangs in `deno
task` on Windows)

https://github.com/denoland/deno_task_shell/pull/113
2024-03-27 13:19:25 -04:00
Nayeem Rahman 726ddabf1f
fix(lsp): use registry cache for completion search (#23094) 2024-03-27 16:02:05 +00:00
David Sherret 49f97d5f85
fix(check): do not suggest running with --unstable (#23092)
Closes #23079
2024-03-27 11:58:36 -04:00
Hajime-san feb744cebd
fix(lsp): decoding percent-encoding(non-ASCII) file path correctly (#22582) 2024-03-27 15:58:18 +00:00
Nayeem Rahman e1e1da2a04
fix(lsp): prefer cache over tsc quick fixes (#23093) 2024-03-27 03:10:23 +00:00
David Sherret 34a651ea2e
feat: type declarations for new Set methods (#23090)
Closes #22851
2024-03-26 21:59:24 -04:00
David Sherret ac4a5f74b8
feat: TypeScript 5.4 (#23086)
Fork PR: https://github.com/denoland/TypeScript/pull/10

Closes #23080
2024-03-26 18:52:57 -04:00
Bartek Iwańczuk 6b95c53e48
feat(add): always produce multiline config file (#23077)
This commit changes `deno add` to always produce a multiline config
file.

In v1.41.3:
```
$ mkdir foo
$ cd foo
$ deno add @std/assert
Created deno.json configuration file.
Add @std/assert - jsr:@std/assert@^0.220.0

$ cat deno.json
{ "imports": { "@std/assert": "jsr:@std/assert@^0.220.0" } }
```

Now:
```
$ mkdir foo
$ cd foo
$ deno add @std/assert
Created deno.json configuration file.
Add @std/assert - jsr:@std/assert@^0.220.0

$ cat deno.json
{ 
  "imports": {
    "@std/assert": "jsr:@std/assert@^0.220.0"
  }
}
```
2024-03-26 17:40:24 -04:00
Don Jayamanne 9841d3fdf1
fix(kernel): Do not increase counter if store_history=false (#20848)
Fixes https://github.com/denoland/deno/issues/20847

Co-authored-by: Nathan Whitaker <nathan@deno.com>
2024-03-26 18:48:23 +00:00
Nathan Whitaker a2a537e196
fix(bench): Fix group header printing logic + don't filter out the warmup benchmark (#23083)
Fixes #23053.
Two small bugs here:
- the existing condition for printing out the group header was broken.
it worked in the reproducer (in the issue above) without filtering only
by accident, due to setting `self.has_ungrouped = true` once we see the
warmup bench. Knowing that we sort benchmarks to put ungrouped benches
first, there are only two cases: 1) we are starting the first group 2)
we are ending the previous group and starting a new group
- when you passed `--filter` we were applying that filter to the warmup
bench (which is not visible to users), so we suffered from jit bias if
you were filtering (unless your filter was `<warmup>`)

TLDR;

Running
```bash
deno bench main.js --filter="G"
```
```js
// main.js
Deno.bench({
  group: "G1",
  name: "G1-A",
  fn() {},
});

Deno.bench({
  group: "G1",
  name: "G1-B",
  fn() {},
});
```


Before this PR:
```
benchmark      time (avg)        iter/s             (min … max)       p75       p99      p995
--------------------------------------------------------------- -----------------------------

G1-A          303.52 ps/iter3,294,726,102.1     (254.2 ps … 7.8 ns) 287.5 ps 391.7 ps 437.5 ps
G1-B             3.8 ns/iter 263,360,635.9     (2.24 ns … 8.36 ns) 3.84 ns 4.73 ns 4.94 ns

summary
  G1-A
   12.51x faster than G1-B
```

After this PR:
```
benchmark      time (avg)        iter/s             (min … max)       p75       p99      p995
--------------------------------------------------------------- -----------------------------

group G1
G1-A            3.85 ns/iter 259,822,096.0     (2.42 ns … 9.03 ns) 3.83 ns 4.62 ns 4.83 ns
G1-B            3.84 ns/iter 260,458,274.5     (3.55 ns … 7.05 ns) 3.83 ns 4.45 ns 4.7 ns

summary
  G1-B
   1x faster than G1-A
```
2024-03-26 09:19:24 -07:00
Nayeem Rahman 3b61104e2a
refactor(lsp): unify config file data into ConfigTree (#23032) 2024-03-26 15:52:20 +00:00
Nathan Whitaker d6452b3946
chore(tests): Introduce integration tests for jupyter subcommand (#23074)
Before this PR, we didn't have any integration tests set up for the
`jupyter` subcommand.

This PR adds a basic jupyter client and helpers for writing integration
tests for the jupyter kernel. A lot of the code here is boilerplate,
mainly around the message format for jupyter.

This also adds a few basic integration tests, most notably for
requesting execution of a snippet of code and getting the correct
results.
2024-03-25 17:53:50 -07:00
David Sherret 0346e597bf
feat(lint): automatically opt-in packages to jsr lint tag (#23072)
This automatically opts packages (deno.json's with a name, version, and
exports field) into the "jsr" lint tag.
2024-03-25 18:20:15 -04:00
Yusuke Tanaka 64e8c36805
fix(cli): output more detailed information for steps when using JUnit reporter (#22797)
This patch gets JUnit reporter to output more detailed information for
test steps (subtests).

## Issue with previous implementation

In the previous implementation, the test hierarchy was represented using
several XML tags like the following:

- `<testsuites>` corresponds to the entire test (one execution of `deno
test` has exactly one `<testsuites>` tag)
- `<testsuite>` corresponds to one file, such as `main_test.ts`
- `<testcase>` corresponds to one `Deno.test(...)`
- `<property>` corresponds to one `t.step(...)`

This structure describes the test layers but one problem is that
`<property>` tag is used for any use cases so some tools that can ingest
a JUnit XML file might not be able to interpret `<property>` as
subtests.

## How other tools address it

Some of the testing frameworks in the ecosystem address this issue by
fitting subtests into the `<testcase>` layer. For instance, take a look
at the following Go test file:

```go
package main_test

import "testing"

func TestMain(t *testing.T) {
  t.Run("child 1", func(t *testing.T) {
    // OK
  })

  t.Run("child 2", func(t *testing.T) {
    // Error
    t.Fatal("error")
  })
}
```

Running [gotestsum], we can get the output like this:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="3" failures="2" errors="0" time="1.013694">
	<testsuite tests="3" failures="2" time="0.510000" name="example/gosumtest" timestamp="2024-03-11T12:26:39+09:00">
		<properties>
			<property name="go.version" value="go1.22.1 darwin/arm64"></property>
		</properties>
		<testcase classname="example/gosumtest" name="TestMain/child_2" time="0.000000">
			<failure message="Failed" type="">=== RUN   TestMain/child_2&#xA;    main_test.go:12: error&#xA;--- FAIL: TestMain/child_2 (0.00s)&#xA;</failure>
		</testcase>
		<testcase classname="example/gosumtest" name="TestMain" time="0.000000">
			<failure message="Failed" type="">=== RUN   TestMain&#xA;--- FAIL: TestMain (0.00s)&#xA;</failure>
		</testcase>
		<testcase classname="example/gosumtest" name="TestMain/child_1" time="0.000000"></testcase>
	</testsuite>
</testsuites>
``` 

This output shows that nested test cases are squashed into the
`<testcase>` layer by treating them as the same layer as their parent,
`TestMain`. We can still distinguish nested ones by their `name`
attributes that look like `TestMain/<subtest_name>`.

As described in #22795, [vitest] solves the issue in the same way as
[gotestsum].

One downside of this would be that one test failure that happens in a
nested test case will end up being counted multiple times, because not
only the subtest but also its wrapping container(s) are considered to be
failures. In fact, in the [gotestsum] output above, `TestMain/child_2`
failed (which is totally expected) while its parent, `TestMain`, was
also counted as failure. As
https://github.com/denoland/deno/pull/20273#discussion_r1307558757
pointed out, there is a test runner that offers flexibility to prevent
this, but I personally don't think the "duplicate failure count" issue
is a big deal.

## How to fix the issue in this patch

This patch fixes the issue with the same approach as [gotestsum] and
[vitest].
More specifically, nested test cases are put into the `<testcase>` level
and their names are now represented as squashed test names concatenated
by `>` (e.g. `parent 2 > child 1 > grandchild 1`). This change also
allows us to put a detailed error message as `<failure>` tag within the
`<testcase>` tag, which should be handled nicely by third-party tools
supporting JUnit XML.

## Extra fix

Also, file paths embedded into XML outputs are changed from absolute
path to relative path, which is helpful when running the test suites in
several different environments like CI.

Resolves #22795

[gotestsum]: https://github.com/gotestyourself/gotestsum
[vitest]: https://vitest.dev/

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-03-26 00:08:46 +09:00
Bartek Iwańczuk d043dd86f7
fix: don't panic in test and bench if ops not available (#23055)
Fixes regression introduced in
https://github.com/denoland/deno/pull/22112 that
removed checks if `Deno.test` or `Deno.bench` are not used in respective
subcommands.

Closes https://github.com/denoland/deno/issues/23041
2024-03-24 16:16:45 -07:00
Sol Boucher ae52b49dd6
docs(dts): Update edge case in prompt() docs (#22954)
This has been incorrect since the function adopted its (more intuitive)
current behavior in 9268df5f3. The same behavior change was backported
to v1.39.3 in 87e954f54.
2024-03-24 08:04:57 +01:00
Bartek Iwańczuk c940205353
refactor(bench): align ops to testing ops (#23038)
Internal refactor that changes how we use ops in `deno bench`
subcommand.

This brings it in line to what we do in `deno test` subcommand.
2024-03-24 06:22:37 +01:00
Matt Mastracci 86cdf37033
perf(cli): use args_os (#23039)
Extracted from #22718
2024-03-22 14:03:56 -07:00
Asher Gomez 2d59372e7a
feat(publish): check for uncommitted files in deno publish --dry-run (#22981)
Closes #22936
2024-03-22 12:41:33 -07:00
David Sherret f96f167dc8
feat(unstable/publish): error when a package's module is excluded from publishing (#22948)
Closes #22657
2024-03-21 21:42:23 +00:00
David Sherret ffbcad3800
feat(lint): deno lint --fix and lsp quick fixes (#22615)
Adds a `--fix` option to deno lint. This currently doesn't work for
basically any rules, but we can add them over time to deno lint.
2024-03-21 14:18:59 -07:00
Bartek Iwańczuk 2166aa8fb6
chore: upgrade deno_core to 0.272.0 (#23022) 2024-03-21 13:57:32 -07:00
David Sherret 9abc722cc3
feat(node): load ES modules defined as CJS (#22945)
Changes the behaviour in Deno to just always load ES modules in npm
packages even if they're defined as CJS.

Closes #22818
2024-03-21 11:35:51 -07:00
David Sherret e55777568e
feat: deno_task_shell 0.15 (#23019)
* feat: implement exit status var
(https://github.com/denoland/deno_task_shell/pull/110)
* feat: support input redirects
(https://github.com/denoland/deno_task_shell/pull/106)
* feat: support output fd redirects for stdout and stderr
(https://github.com/denoland/deno_task_shell/pull/111)
* feat: support parsing fd redirects
(https://github.com/denoland/deno_task_shell/pull/107)
* fix: exit error code on arg parse failure
(https://github.com/denoland/deno_task_shell/pull/112)

Closes #22989
2024-03-21 16:43:17 +00:00
Nayeem Rahman 5a716d1d06
refactor(lsp): factor out workspace walk from resolver update (#22937) 2024-03-21 04:29:52 +00:00
Bartek Iwańczuk e45f433a16
chore: make DENO_FUTURE a singleton (#23009)
Just making sure we read this env var once per process.
2024-03-21 07:32:44 +05:30
Asher Gomez 9593cf2852
chore(ext/io): remove use of deprecated Deno.writeSync() (#22872) 2024-03-20 10:39:25 -07:00
Nathan Whitaker ab67b4c645
fix(coverage): Error if no files are included in the report (#22952)
Fixes #22941.

In that case, the only file with coverage was the `test.ts` file. The
coverage reporter filters out test files before compiling its report, so
after filtering we were left with an empty set of files. Later on it's
assumed that there is at least 1 file to be reported on, and we panic.
Instead of panicking, just issue an error after filtering.
2024-03-15 20:58:57 -07:00
Bartek Iwańczuk c342cd36ba
fix(ext/node): worker_threads doesn't exit if there are message listeners (#22944)
Closes https://github.com/denoland/deno/issues/22934
2024-03-15 21:38:16 +01:00
David Sherret 36e6e4a009
fix: handle cache body file not existing when using etag (#22931) 2024-03-15 09:57:24 -04:00
Matt Mastracci dae162f738
fix(cli): sanitizer should ignore count of ops started before tests begin (#22932) 2024-03-14 18:19:07 -06:00
Łukasz Czerniawski 5403e4f06b
chore(cli): move away from PathBuf in clap (#22036) 2024-03-14 23:53:46 +00:00
Nathan Whitaker 85116226b3
chore: Forward 1.41.3 release commit (#22930)
Forward 1.41.3 release commit

Co-authored-by: denobot <33910674+denobot@users.noreply.github.com>
Co-authored-by: nathanwhit <nathanwhit@users.noreply.github.com>
2024-03-14 21:23:24 +00:00
Matt Mastracci 1f3c4c9763
fix(cli): show asserts before leaks (#22904)
Fixes #22837
2024-03-13 20:49:54 -06:00