Commit graph

852 commits

Author SHA1 Message Date
Leo Kettmeir dc985954e1
chore: update deno_doc to 0.119.0 (#23103) 2024-03-28 00:25:39 +01: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
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
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
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
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
Matt Mastracci 1f3c4c9763
fix(cli): show asserts before leaks (#22904)
Fixes #22837
2024-03-13 20:49:54 -06:00
David Sherret c10d96cb21
fix(slow-types): improved exports tracing and infer type literals in as exprs (#22849)
Several fixes in deno_graph:

* https://github.com/denoland/deno_graph/pull/411
* https://github.com/denoland/deno_graph/pull/413
* https://github.com/denoland/deno_graph/pull/414
* https://github.com/denoland/deno_graph/pull/415
* https://github.com/denoland/deno_graph/pull/416
* https://github.com/denoland/deno_graph/pull/417

Also created https://github.com/denoland/publish_smoke_tests to help
prevent regressions in the future.

Closes https://github.com/denoland/deno/issues/22829
Closes https://github.com/denoland/deno/issues/22819
Closes https://github.com/denoland/deno/issues/22802
2024-03-12 17:45:38 +00:00
David Sherret ad6b00a2bf
chore: enable clippy unused_async rule (#22834) 2024-03-11 23:48:00 -04:00
Matt Mastracci 61d86b906f
fix(cli): use Instant for test times (#22853)
Fixes https://github.com/denoland/deno_std/issues/4473
2024-03-11 19:30:15 -06:00
David Sherret 644ac0fe43
chore: hidden tool for overwriting files with fast check output (#22822)
Not sure if we should do this, but it's a nice hidden tool that
overwrites the working tree with the fast check output.
2024-03-11 11:42:12 -04:00
David Sherret f8543a9fd8
fix(publish): regression - publishing with vendor folder (#22830)
In
https://github.com/denoland/deno/pull/22720/files#diff-d62d85de2a7ffb816cd2fdbaa47e588352f521c7c43d058b75649bbb255e0ae1R70
, I copy and pasted from another area of the code and didn't think about
removing how it ignores the vendor folder by default.
2024-03-09 20:40:53 -05:00
David Sherret 119744c285
fix(publish): suggest using --allow-dirty on uncommitted changes (#22810) 2024-03-08 22:49:15 +00:00
David Sherret 2c6e9107b6
fix(publish): do not include .gitignore (#22789)
Regression from https://github.com/denoland/deno/pull/22720
2024-03-08 04:16:19 +00:00
David Sherret 2dfc0aca7c
fix(publish): make include and exclude work (#22720)
1. Stops `deno publish` using some custom include/exclude behaviour from
other sub commands
2. Takes ancestor directories into account when resolving gitignore
3. Backards compatible change that adds ability to unexclude an exclude
by using a negated glob at a more specific level for all sub commands
(see https://github.com/denoland/deno_config/pull/44).
2024-03-07 20:16:32 -05:00
Bartek Iwańczuk 914b7495a8
fix(publish): reland error if there are uncommitted changes (#22613) (#22632)
Reverted in https://github.com/denoland/deno/pull/22625
2024-03-07 22:13:36 +01:00
Matt Mastracci 0fdb33c3aa
fix(cli): limit test parallelism on Windows to avoid pipe error (#22776)
One last attempt to fix the parallelism issue on Windows.
2024-03-07 10:04:39 -07:00
Matt Mastracci 4791d16a8e
perf(cli): use faster_hex (#22761)
`cli::util::checksum` was showing up on flame graphs because it was
concatenating allocated strings. We can use `faster-hex` to improve it.
2024-03-07 10:00:43 -07:00
David Sherret 594d8397ad
fix(publish): properly display graph validation errors (#22775)
The graph validation errors were displaying cryptically during publish.
This fixes that.
2024-03-07 17:30:30 +01:00
Luca Casonato 87a08fc3b2
fix(tools/publish): correctly handle importing from self in unfurling (#22774)
We emitted `import "./` rather than `import "./$NAME"`. This is now
fixed.

Also makes a cosmetic change so that `../` imports are now just imported
as `../`, not `./../`.
2024-03-07 17:29:17 +01:00
Nayeem Rahman 01bc2f530e
feat(unstable/pm): support npm packages in 'deno add' (#22715) 2024-03-06 13:24:15 +00:00
Divy Srivastava 156950828e
fix(publish): permissionless dry-run in GHA (#22679)
Fixes https://github.com/denoland/deno/issues/22658
2024-03-06 18:26:20 +05:30
David Sherret 3eaf174bfc
fix(node): improve cjs tracking (#22673)
We were missing saying that a file is CJS when some Deno code imported
from the node_modules directory at runtime.
2024-03-06 00:23:51 +00:00
David Sherret 942dcbad84
refactor: move deno json functionality to args module (#22710) 2024-03-05 15:45:44 -05:00
Matt Mastracci 72d34a79ac
fix(cli): remove possible deadlock in test channel (#22662)
The stderr stream could possibly starve the other bits of the
output-redirecting event loop.

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-03-04 20:14:21 -07:00
cui fliter d4b3b39cc0
chore: fix typos (#22677) 2024-03-04 14:28:57 +00:00
Divy Srivastava 11db68ce96
feat(publish): add npm: suggestion for esm.sh specifiers (#22343)
![image](https://github.com/denoland/deno/assets/34997667/f32642ed-c109-4519-84c5-6f78e9452703)

Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2024-03-04 09:55:28 +05:30
Nayeem Rahman 15f5f74eb7
feat(unstable/pm): support version contraints in 'deno add' (#22646) 2024-03-01 21:34:13 +00:00
Matt Mastracci 2e4a1fc3e8
fix(cli): force flush output after test unloads (#22660)
Fixes flake in load_unload test
2024-03-01 21:26:57 +00:00
Matt Mastracci 736b91edd0
perf(cli): use new deno_core timers (#22569)
Improves #19100 

Fixes #20356

Replaces #20428



Changes made in deno_core to support this:

 - [x] Errors must be handled in setTimeout callbacks
 - [x] Microtask ordering is not-quite-right
 - [x] Timer cancellation must be checked right before dispatch
 - [x] Timer sanitizer
 - [x] Move high-res timer to deno_core
 - [x] Timers need opcall tracing
2024-03-01 11:15:18 -07:00
David Sherret 878384aefa
fix(unstable/publish): repect --no-check in no-slow-types (#22653) 2024-03-01 15:54:46 +00:00
Bartek Iwańczuk ea3651a1ac
fix(publish): disable provenance if not in GHA (#22638)
The condition was wrong
2024-02-29 21:19:30 +00:00
Bartek Iwańczuk fb31ae73e4
feat(unstable): deno add subcommand (#22520)
This commit adds "deno add" subcommand that has a basic support for
adding "jsr:" packages to "deno.json" file. 

This currently doesn't support "npm:" specifiers and specifying version
constraints.
2024-02-29 19:12:04 +00:00
David Sherret 8d9a54ca18
fix(publish): reduce warnings about dynamic imports (#22636) 2024-02-29 11:34:07 -05:00
Divy Srivastava 9ffc34c159
feat(publish): enable package provenance by default on github actions (#22635) 2024-02-29 21:48:47 +05:30
Bartek Iwańczuk 211b3ff244
fix(publish): print a warning when .jsx or .tsx is imported (#22631)
This commit adds a warning when .jsx or .tsx is encountered during
publishing.

This is a stop-gap solution before we fix it proper.
2024-02-29 12:54:57 +01:00
Matt Mastracci b6e44f91ad
fix(cli): ensure that pre- and post-test output is flushed at the appropriate times (#22611)
Some `deno_std` tests were failing to print output that was resolved
after the last test finished. In addition, output printed before tests
began would sometimes appear above the "running X tests ..." line, and
sometimes below it depending on timing.

We now guarantee that all output is flushed before and after tests run,
making the output consistent.

Pre-test and post-test output are captured in `------ pre-test output
------` and `------ post-test output ------` blocks to differentiate
them from the regular output blocks.

Here's an example of a test (that is much noisier than normal, but an
example of what the output will look like):

```
Check ./load_unload.ts
------- pre-test output -------
load
----- output end -----
running 1 test from ./load_unload.ts
test ...
------- output -------
test
----- output end -----
test ... ok ([WILDCARD])
------- post-test output -------
unload
----- output end -----
```
2024-02-28 22:12:21 +00:00