Commit graph

51 commits

Author SHA1 Message Date
evan d2c80aa26f
fix(bench): eliminate sanitizeExit overhead (#14361) 2022-04-23 14:39:56 +02:00
evan f785ecee1a
feat(bench): update API, new console reporter (#14305)
This commit changes "deno bench" subcommand, by updating
the "Deno.bench" API as follows:
- remove "Deno.BenchDefinition.n"
- remove "Deno.BenchDefintion.warmup"
- add "Deno.BenchDefinition.group"
- add "Deno.BenchDefintion.baseline"

This is done because bench cases are no longer run fixed amount
of iterations, but instead they are run until there is difference between
subsequent runs that is statistically insiginificant.

Additionally, console reporter was rewritten completely, to looks
similar to "hyperfine" reporter.
2022-04-20 21:06:39 +02:00
Bartek Iwańczuk 5f2d9a4a22
feat(test): use structured data for JavaScript errors in tests (#14287)
This commit rewrites test runner to send structured error data from JavaScript
to Rust instead of passing strings. This will allow to customize display of errors
in test report (which will be addressed in follow up commits).
2022-04-16 19:51:12 +02:00
Bartek Iwańczuk 244926e83c
feat(test): format user code output (#14271)
This commit changes "deno test" to better denote user output coming
from test cases.

This is done by printing "---- output ----" and "---- output end ----"
markers if an output is produced. The output from "console" and
"Deno.core.print" is captured, as well as direct writes to "Deno.stdout"
and "Deno.stderr".

To achieve that new APIs were added to "deno_core" crate, that allow
to replace an existing resource with a different one (while keeping resource
ids intact). Resources for stdout and stderr are replaced by pipes.

Co-authored-by: David Sherret <dsherret@gmail.com>
2022-04-15 14:24:41 +02:00
AEtheve c03fbb3c1f
fix(test): Don't error on missing op details (#14184) 2022-04-13 14:18:12 +02:00
Yongwook Choi 0df1854249
feat(test): Add "name", "origin" and "parent" to "Deno.TestContext" (#14007)
This commit adds following fields to "Deno.TestContext" interface:
- name
- origin
- parent

These are prerequisites for supporting snapshot functionality in
"std/testing".
2022-04-06 16:51:38 +02:00
Kitson Kelly 061090de7e
feat(lsp): add experimental testing API (#13798)
Ref: denoland/vscode_deno#629
2022-03-30 09:59:27 +11:00
Bartek Iwańczuk b82ded84d3
fix(bench): require --unstable flag in JavaScript (#14091) 2022-03-23 16:33:42 +01:00
Bartek Iwańczuk c3f306d778
fix(test): don't error on missing op details (#14074) 2022-03-23 00:24:45 +01:00
Leo Kettmeir e55dee7fd8
refactor: cleanup assert() & AssertionError definitions (#13859) 2022-03-19 13:57:37 +01:00
Bartek Iwańczuk 09ae512ccb
feat: "deno bench" subcommand (#13713)
This commit adds "deno bench" subcommand and "Deno.bench()"
API that allows to register bench cases. 

The API is modelled after "Deno.test()" and "deno test" subcommand.

Currently the output is rudimentary and bench cases and not
subject to "ops" and "resource" sanitizers.

Co-authored-by: evan <github@evan.lol>
2022-03-11 23:07:02 +01:00
Bartek Iwańczuk d332bf1132
feat: deno test --trace-ops (#13770)
This commit adds "--trace-ops" flag to "deno test" subcommand.

This flag enables saving of stack traces for async ops, that before were always
saved. While the feature proved to be very useful it comes with a significant performance
hit, it's caused by excessive source mapping of stack frames.
2022-02-25 16:14:46 +01:00
Luca Casonato 53088e16de
feat(test): improved op sanitizer errors + traces (#13676)
This commit improves the error messages for the `deno test` async op
sanitizer. It does this in two ways:
- it uses handwritten error messages for each op that could be leaking
- it includes traces showing where each op was started

This "async op tracing" functionality is a new feature in deno_core.
It likely has a significant performance impact, which is why it is only
enabled in tests.
2022-02-16 19:53:17 +01:00
Bartek Iwańczuk bf22f114a6
refactor: update runtime code for primordial check for iterators (#13510) 2022-02-07 13:54:32 +01:00
Bartek Iwańczuk 8176a4d166
refactor: primordials for instanceof (#13527) 2022-02-01 18:06:11 +01:00
Bartek Iwańczuk f248e6f177
Revert "refactor: update runtime code for primordial checks for "instanceof" (#13497)" (#13511)
This reverts commit 884143218f.
2022-01-27 16:27:22 +01:00
Bartek Iwańczuk 884143218f
refactor: update runtime code for primordial checks for "instanceof" (#13497) 2022-01-27 13:36:36 +01:00
Luca Casonato b53997273d
feat(test): better errors for resource sanitizer (#13296)
This commit makes the errors produced from the resource sanitizer much
more human readable. It does this by using real words rather than our
"resource names" when referring to resources, and by giving helpful
hints on how to clean up each of the resources.
2022-01-25 17:03:38 +01:00
David Sherret 0f3a53e5d4
feat: stabilize test steps API (#13400) 2022-01-18 15:02:56 -05:00
Ryan Dahl 1fb5858009
chore: update copyright to 2022 (#13306)
Co-authored-by: Erfan Safari <erfanshield@outlook.com>
2022-01-07 22:09:52 -05:00
Andreu Botella a3aa2c184c
fix(test): Make the op sanitizer delay macrotask into a queue (#12966)
Fixes #12945.
2021-12-10 18:30:46 -05:00
Andreu Botella 9a10668694
fix(test): Improve reliability of deno test's op sanitizer with timers (#12934)
Although not easy to replicate in the wild, the `deno test` op sanitizer
can fail when there are intervals that started before a test runs, since
the op sanitizer can end up running in the time between the timer op for
an interval's run resolves and the op for the next run starts.

This change fixes that by adding a new macrotask callback that will run
after the timer macrotask queue has drained. This ensures that there is
a timer op if there are any timers which are unresolved by the time the
op sanitizer runs.
2021-11-30 01:27:30 +01:00
Bartek Iwańczuk 5178e093ed
Revert "fix(test): Improve reliability of deno test's op sanitizer with timers (#12908)" (#12929)
This reverts commit d335343a79.
2021-11-29 12:07:47 +01:00
Andreu Botella d335343a79
fix(test): Improve reliability of deno test's op sanitizer with timers (#12908)
Although not easy to replicate in the wild, the `deno test` op sanitizer
can fail when there are intervals that started before a test runs, since
the op sanitizer can end up running in the time between the timer op for
an interval's run resolves and the op for the next run starts.

This change fixes that by adding a new macrotask callback that will run
after the timer macrotask queue has drained. This ensures that there is
a timer op if there are any timers which are unresolved by the time the
op sanitizer runs.
2021-11-28 16:40:38 +01:00
Bartek Iwańczuk d8afd56838
feat(test): Add more overloads for "Deno.test" (#12749)
This commit adds 4 more overloads to "Deno.test()" API.

```
// Deno.test(function testName() { });
export function test(fn: (t: TestContext) => void | Promise<void>): void;

// Deno.test("test name", { only: true }, function() { });
export function test(
  name: string,
  options: Omit<TestDefinition, "name">,
  fn: (t: TestContext) => void | Promise<void>,
): void;

// Deno.test({ name: "test name" }, function() { });
export function test(
  options: Omit<TestDefinition, "fn">,
  fn: (t: TestContext) => void | Promise<void>,
): void;

// Deno.test({ only: true }, function testName() { });
export function test(
  options: Omit<TestDefinition, "fn" | "name">,
  fn: (t: TestContext) => void | Promise<void>,
): void;
```
2021-11-23 14:57:51 +01:00
Yacine Hmito 2dbc8fb3d5
fix(test): do not throw on error.errors.map (#12810)
In tests, the function to format errors would assume that any error with
a property `errors` would be an `AggregateError`, and therefore the
property `errors` would contain an error. This is not necessarily the
case.
2021-11-20 09:43:40 -05:00
Nayeem Rahman 7a22df9b76
fix(runtime/ops/worker_host): move permission arg parsing to Rust (#12297) 2021-10-13 13:04:44 -04:00
David Sherret d5a7a6d575
chore: fix flaky steps_invalid_usage tests (#12422) 2021-10-13 08:55:12 -04:00
David Sherret 9b1f0c8ba3
chore: upgrade crates based on deno ast 0.3 (#12403) 2021-10-12 09:58:04 -04:00
Casper Beyer 1683044ed9
feat: provide ops details for ops sanitizer failures (#12188) 2021-10-11 17:00:33 +02:00
David Sherret 426ebf854a
feat(unstable/test): imperative test steps API (#12190) 2021-10-11 09:45:02 -04:00
Aaron O'Mullan 5a8a989b78
refactor(metrics): move to core (#12386)
Avoids overhead of wrapping ops (and allocs when inspecting async-op futures)
2021-10-10 17:20:30 +02:00
Casper Beyer 6bf5c850e6
fix(runtime/testing): format aggregate errors (#12183) 2021-09-30 21:54:56 +02:00
Casper Beyer 01bfb7d913
refactor(testing): use discrete report functions (#11917) 2021-09-05 22:42:35 +02:00
Casper Beyer ce79cb5797
refactor(testing): redirect console output via reporter (#11911)
This feeds console output to the reporter and handles silencing there
instead of in the JavaScript code.
2021-09-04 15:16:35 +02:00
Casper Beyer 69ca44d8e2
refactor(cli/tools/test_runner): split reporter into distinct stages (#11395)
This splits up the reporter into smaller functions, one for each
distinct event that happens during the testing process.
2021-07-14 21:05:16 +02:00
Casper Beyer 9cb48bd8fe
refactor(runtime): apply permissions as a hook during registration (#11347) 2021-07-14 00:11:02 +02:00
Casper Beyer e8258e0210
feat(test): add --shuffle flag to randomize test ordering (#11163) 2021-07-05 21:20:33 -04:00
Casper Beyer 407de8b834
fix(runtime): ignored tests should not cause permission changes (#11278) 2021-07-05 18:36:43 +02:00
Casper Beyer c4cc353d59
refactor(runtime): reduce duplication in test harness (#11274) 2021-07-05 10:26:57 +02:00
Bartek Iwańczuk 5addba2abc
refactor: use primordials in runtime/, part2 (#11248) 2021-07-04 00:17:52 +02:00
Yusuke Tanaka cda09c166f
chore: update deno_lint binary used in CI to v0.5.0 (#10652) 2021-05-18 17:24:01 +02:00
Casper Beyer c455c28b83
feat(test): run test modules in parallel (#9815)
This commit adds support for running test in parallel.

Entire test runner functionality has been rewritten
from JavaScript to Rust and a set of ops was added to support reporting in Rust.

A new "--jobs" flag was added to "deno test" that allows to configure 
how many threads will be used. When given no value it defaults to 2.
2021-04-28 20:17:04 +02:00
Casper Beyer f3751e498f
feat(cli): add test permissions to Deno.test (#10188)
This commits adds adds "permissions" option to the test definitions 
which allows tests to run with different permission sets than 
the process's permission.

The change will only be in effect within the test function, once the 
test has completed the original process permission set is restored.

Test permissions cannot exceed the process's permission.
You can only narrow or drop permissions, failure to acquire a 
permission results in an error being thrown and the test case will fail.
2021-04-25 23:38:59 +02:00
Luca Casonato 0770449c93
refactor: move Console to op_crates/console (#9770) 2021-03-12 21:23:59 +01:00
Casper Beyer 9cc7e32e37
feat: add exit sanitizer to Deno.test (#9529)
This adds an exit sanitizer to ensure that code being tested or 
dependencies of that code can't accidentally call "Deno.exit"
leading to partial test runs and false results.
2021-02-24 13:55:50 +01:00
Casper Beyer eefd522f04
fix(runtime/testing): false positive for timers when an error is thrown (#9553) 2021-02-21 17:21:25 +01:00
Developing 923214c537
chore: use strict mode for internal runtime, core, and op_crates js (#9391) 2021-02-04 23:18:32 +01:00
Bartek Iwańczuk b26dcbc69d
chore: Enforce ban-untagged-todo lint rule (#9135) 2021-01-17 00:32:59 +01:00
Yusuke Tanaka d8fd71afdf
chore: update copyright to 2021 (#9092) 2021-01-11 18:13:41 +01:00