1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-26 00:59:24 -05:00
denoland-deno/cli/tests/integration
nasa 25fdc7bf6c
feat(node_compat): Added base implementation of FileHandle (#19294)
<!--
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.
-->


## WHY

ref: https://github.com/denoland/deno/issues/19165

Node's fs/promises includes a FileHandle class, but deno does not. The
open function in Node's fs/promises returns a FileHandle, which provides
an IO interface to the file. However, deno's open function returns a
resource id.


### deno 

```js
> const fs = await import("node:fs/promises");
undefined
> const file3 = await fs.open("./README.md");
undefined
> file3
3
> file3.read
undefined
Node:
```

### Node
```js
> const fs = await import("fs/promises");
undefined
>   const file3 = await fs.open("./tests/e2e_unit/testdata/file.txt");
undefined
> file3
FileHandle {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  close: [Function: close],
  [Symbol(kCapture)]: false,
  [Symbol(kHandle)]: FileHandle {},
  [Symbol(kFd)]: 24,
  [Symbol(kRefs)]: 1,
  [Symbol(kClosePromise)]: null
}
> file3.read
[Function: read]
```


To be compatible with Node, deno's open function should also return a
FileHandle.

## WHAT

I have implemented the first step in adding a FileHandle.

- Changed the return value of the open function to a FileHandle object
- Implemented the readFile method in FileHandle
- Add test code


## What to do next
This PR is the first step in adding a FileHandle, and there are things
that should be done next.

- Add functionality equivalent to Node's FileHandle to FileHandle
(currently there is only readFile)

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-06-02 08:28:05 -06:00
..
bench_tests.rs fix(test): disable preventDefault() for beforeunload event (#18911) 2023-05-03 23:10:51 +02:00
bundle_tests.rs feat(cli): --ext parameter for run, compile, and bundle (#17172) 2023-03-22 10:15:53 -04:00
cache_tests.rs fix(ext/cache): cache.put overwrites previous call (#18649) 2023-04-12 11:25:19 +05:30
cert_tests.rs refactor(core): bake single-thread assumptions into spawn/spawn_blocking (#19056) 2023-05-14 15:40:01 -06:00
check_tests.rs fix(dts): move BroadcastChannel type to lib.deno.unstable.d.ts (#19108) 2023-05-14 20:27:14 +09:00
compile_tests.rs fix(compile): inline symlinks as files outside node_modules dir and warn for directories (#19285) 2023-05-27 10:33:15 -04:00
coverage_tests.rs fix(test/coverage): exclude test files (#18748) 2023-04-19 23:30:52 +02:00
doc_tests.rs fix(info/doc): add missing --no-lock and --lock flags (#18166) 2023-03-13 17:04:00 -04:00
eval_tests.rs tests: move integration tests to a single module (#17380) 2023-01-13 02:59:13 +01:00
flags_tests.rs tests: move integration tests to a single module (#17380) 2023-01-13 02:59:13 +01:00
fmt_tests.rs feat: add support for globs in the config file and CLI arguments for files (#19102) 2023-05-23 03:39:59 +02:00
info_tests.rs fix(info/doc): add missing --no-lock and --lock flags (#18166) 2023-03-13 17:04:00 -04:00
init_tests.rs chore(cli/tests): use test builder in more integration tests (#18031) 2023-03-13 09:40:46 -04:00
inspector_tests.rs feat(lsp): support lockfile and node_modules directory (#19203) 2023-05-22 21:28:36 -04:00
install_tests.rs tests: move integration tests to a single module (#17380) 2023-01-13 02:59:13 +01:00
js_unit_tests.rs chore(cli): One Rust test per JS and Node unit test file (#19199) 2023-05-22 13:35:59 -06:00
lint_tests.rs feat: add support for globs in the config file and CLI arguments for files (#19102) 2023-05-23 03:39:59 +02:00
lsp_tests.rs chore(lsp/tests): diagnostic synchronization (reland) (#19270) 2023-05-26 08:10:18 +02:00
mod.rs refactor: move shared library tests to their own file (#18479) 2023-03-28 13:40:43 -04:00
node_compat_tests.rs tests: cleanup "node_compat_tests" (#18594) 2023-04-05 13:15:57 +02:00
node_unit_tests.rs feat(node_compat): Added base implementation of FileHandle (#19294) 2023-06-02 08:28:05 -06:00
npm_tests.rs fix(npm): create node_modules/.deno/node_modules folder (#19242) 2023-05-24 15:04:21 -04:00
repl_tests.rs feat(lsp): ability to configure document pre-load limit (#19097) 2023-05-11 17:17:14 -04:00
run_tests.rs fix(npm): store npm binary command resolution in lockfile (#19219) 2023-05-22 16:55:04 -04:00
shared_library_tests.rs refactor: move shared library tests to their own file (#18479) 2023-03-28 13:40:43 -04:00
task_tests.rs fix(npm): run pre and post tasks if present (#19178) 2023-05-18 15:51:17 -04:00
test_tests.rs feat: add support for globs in the config file and CLI arguments for files (#19102) 2023-05-23 03:39:59 +02:00
upgrade_tests.rs chore: use rustfmt imports_granularity option (#17421) 2023-01-14 23:18:58 -05:00
vendor_tests.rs feat(vendor): support for npm specifiers (#19186) 2023-05-19 22:39:27 +00:00
watcher_tests.rs fix(ext/http): Ensure Deno.serve works across --watch restarts (#18998) 2023-05-08 09:52:56 +02:00
worker_tests.rs tests: move integration tests to a single module (#17380) 2023-01-13 02:59:13 +01:00