This PR brings assertOps and assertResources sanitizers to Deno.test() API.
assertOps checks that test doesn't leak async ops, ie. there are no unresolved
promises originating from Deno APIs. Enabled by default, can be disabled using
Deno.TestDefinition.disableOpSanitizer.
assertResources checks that test doesn't leak resources, ie. all resources used
in test are closed. For example; if a file is opened during a test case it must be
explicitly closed before test case finishes. It's most useful for asynchronous
generators. Enabled by default, can be disabled using
Deno.TestDefinition.disableResourceSanitizer.
We've used those sanitizers in internal runtime tests and it proved very useful in
surfacing incorrect tests which resulted in interference between the tests.
All tests have been sanitized.
Closes #4208
Functions that returns a server are now documented with "Create",
and functions that launches one are documented with "Start".
Also added documentation for listenAndServe that respects these
changes.
Fixes #4367
* My original implementation of `fs.appendFile` used an async API, which, though
it would work fine as a polyfill, wasn't an exact match with the Node API. This PR
reworks that API to mimic the Node API fully as a synchronous void function with
an async internal implementation.
* Refactor move of other internal fs `dirent` and `dir` classes to the _fs internal
directory.
Listener and UDPConn are AsyncIterables instead of AsyncIterators.
The [Symbol.asyncIterator]()s are defined as generators and the
next() methods are gone.
"Listener/Socket has been closed" errors are now BadResource.
Following JS ops were moved to separate files in cli/js/ops directory:
- compiler
- dispatch_json
- dispatch_minimal
- errors
- fetch
- fs_events
- os
- random
- repl
- resources
- runtime_compiler
- runtime
- tty
Adds JSDoc to module, improves the typing of the return type, uses
iteration instead of Array forEach, uses the dotall support in Regular
Expression which is now supported in JavaScript, uses destructuring and
nullish coalescing where appropriate.
This updates this example code to follow the new test running conventions.
The code as is, when ran produces the following output:
```
➜ dencro git:(master) ✗ deno test
Compile file:///Users/hswolff/Sites/dencro/test.ts
running 2 tests
OK oneTest (2.00ms)
OK t2 (0.00ms)
test result: OK 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (2.00ms)
running 2 tests
OK oneTest (0.00ms)
OK t2 (0.00ms)
test result: OK 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (0.00ms)
➜ dencro git:(master) ✗
```
Removing `await Deno.runTests();` just causes the tests to run once.
- Added `ServerRequest.finalize()`: consuming all unread body stream and trailers.
- This is cleanup method for reading next request from same keep-alive connection.
- Needed when handler didn't consume all body and trailers even after responding.
- refactor: `ServerRequest._bodyStream()`, `ServerRequestBody` are removed.
- Now using `bodyReader()` and `chunkedBodyReader()` instead.
- fix: Trailers should only be read `transfer-encoding` is `chunked` and `trailer` header is set and its value is valid.
- fix: use `Headers.append()` on reading trailers.
- fix: delete `trailer` field from headers after reading trailers.
- reorg: Several functions related to IO are moved into `http/io.ts`
Node's os module exports a number of methods that evaluate to themselves
when coerced to a primitive.
I.e., `"" + os.arch` and `os.arch()` evaluate to the same string, and
now Deno's shims do too.