deno_std
Refs
スタイルガイド
code: zsh
deno test -A --unstable node/_tools/test.ts -- test-fs-read-zero-length.js
Kotlinの配列ドキュメント
nit: We prefer the format of TODO(username):
deno run --compat foo.mjs
次の目玉
findLastがV8に実装された
V8使ってるやつどするかの議論
Hello! I was working on issue 662 for implementing isDeepStrictEqual in node/util and in the node implementation a getOwnNonIndexProperties is used from the node-bindings, is there an equivalent that can used? Or is there a way to recreate the logic in typescript without having to use Rust as I didn't fully understand what was being done in their C code with them using a v8::IndexFilter.
i think IndexFilter is just an enum
but youd probably have to recreate the behaviour in ts
okay thanks. I have started to implement it, do you think something like this would be able to do get the results?
I see that this is primarily being used for 2 cases, when the comparison is to be done for either value being
1. Array or 2. ArrayBuffers
I guess the best way would be to finish this and check it against the test cases once, else I'll just end up taking up too much time pre-emptively. However, if you do see something glaringly wrong here please do give a shout out.
Simulating the behavior in typescript is a good idea. We actually don't touch V8 APIs directly in std/node
https://scrapbox.io/files/618c5fcf1a0a1e001e755e40.png
code: ts
function getOwnNonIndexProperties(obj: { unknown: unknown }): string[] {
if (Array.isArray(obj)) return [];
// Object.keys(SET) will return an empty array for sets as well as weaksets
// Object.keys(MAP) will return an empty array for sets as well as weakmaps
return Object.keys(obj);
}
code: check.ts
import { config } from "./common.ts";
const tests = []
for await (const entry of Deno.readDir('node/_tools/versions/node-v18.8.0/test/parallel')) {
if (entry.name.includes("test-fs") && !config.tests.parallel.includes(entry.name)) {
tests.push(entry.name)
}
}
console.log(tests.sort())
code: zsh
deno run -A ./node/_tools/check.ts
issue
issue
snapshotのtab
issue
snapshots -> snapshot
$ deno test --allow-all --unstable ./snapshot_test.ts -- -u
issue
code: .ts
// ここでキューに入らない
assertSnapshotContext.pushSnapshotToUpdateQueue(name);
currentSnapshots.set(snapshotName, undefined);
だいぶ変わった
issue
code: zsh
------- output -------
{
value: { name: "empty", isFile: true, isDirectory: false, isSymlink: false },
done: false
}
issue
issue
code: zsh
$$$$$$$$$$$$ empty
$$$$$$$$$$$$ files
$$$$$$$$$$$$ for
$$$$$$$$$$$$ just
$$$$$$$$$$$$ testing
########################
empty ==================
just ==================
code: fs-readdir-types.js
// Create the necessary files
files.forEach(function(currentFile) {
console.log("$$$$$$$$$$$$", currentFile)
fs.closeSync(fs.openSync(${readdirDir}/${currentFile}, 'w'));
});
function assertDirents(dirents) {
assert.strictEqual(files.length, dirents.length);
console.log("########################")
console.log(dirent.name, "==================")
assert(dirent instanceof fs.Dirent);
assert.strictEqual(dirent.name, filesi); assert.strictEqual(dirent.isFile(), true);
assert.strictEqual(dirent.isDirectory(), false);
// assert.strictEqual(dirent.isSocket(), false);
// assert.strictEqual(dirent.isBlockDevice(), false);
// assert.strictEqual(dirent.isCharacterDevice(), false);
// assert.strictEqual(dirent.isFIFO(), false);
assert.strictEqual(dirent.isSymbolicLink(), false);
}
}
// Check the readdir Sync version
assertDirents(fs.readdirSync(readdirDir, { withFileTypes: true }));
issue
TODO: Also accept 'path' parameter as a Node polyfill Buffer type once these are implemented
issue
TODO: sep = "&",eq = "="はoptionではないのか?
nodeだから関係ないわ
issue
TODO: _fs_chown.ts引数
issue
issue
code: ts
const clones: Tuple<AsyncIterableClone<T>, N> = Array.from({ length: n }).map(
() => new AsyncIterableClone(),
// deno-lint-ignore no-explicit-any
) as any;
issue
deep_assign.ts
): // deno-lint-ignore ban-types
issue
テストがほとんどない
node/test/parallel
Windowsで落ちる
issue
参考
issueもdenoだった
2021/9/25
issue
配列追加
README.mdにもテストが走る
issue
テストisWindowsはignoreとonlyでいけないか
_fs_writeFile_test.ts if (isWindows) return;
issue
issue & PR テンプレート
issueテンプレートでコメントにしたほうがいい箇所がある
$ deno --versionもつけたほうが良い
やってくれた
issue
permissions/test.ts: 例外とファイル名
Deno.permissions.requestはdenoに飛んでいる
issue
目次つける
これがあるが...ってのも
アルファベット順
BRANCH: collection-doc
issue立てる?
TODO: Exampleとセミコロン
issue
nodeテストの自動生成
code: zsh
~/desktop/deno_std
$ deno run --allow-read --allow-net --allow-write node/_tools/setup.ts
Check file:///Users/tagawahirotaka/Desktop/deno_std/node/_tools/setup.ts
Decompressing node-v17.0.0.tar.gz...
Cleaning up previous tests
Copying test files...
TODO: setup.ts complited!! とか欲しい
issue
TODO: assertThrowsAsync 非推奨がserver_test.tsで使われている
issue
code: zsh
$ deno upgrade
Looking up latest version
Found latest version 1.14.1
28.5 MiB / 28.5 MiB (100.0%)
Deno is upgrading to version 1.14.1
Archive: /var/folders/h0/n4dr2mwn6vqbtk9y1zrcykd80000gn/T/.tmpqgtdvu/deno.zip
inflating: deno
Upgraded successfully
issue
config.jsonの順番をテストする
code: setup.ts
console.log(config)
{
nodeVersion: "15.5.1",
tests: {
parallel: [
"test-assert.js",
"test-assert-async.js",
"test-assert-fail.js",
...
"test-util-inherits.js"
]
},
suitesFolder: "suites",
versionsFolder: "versions"
}
issue
code: zsh
$ deno test --allow-read --allow-run node/_tools/test.ts
Check file:///Users/tagawahirotaka/Desktop/deno_std/node/_tools/test.ts
running 21 tests from file:///Users/tagawahirotaka/Desktop/deno_std/node/_tools/test.ts
test suites/parallel/test-assert-fail.js ... ok (5236ms)
test suites/parallel/test-event-emitter-invalid-listener.js ... ok (376ms)
↑ testsFolder
code: zsh
console.log(testList, 'testList');
[
/parallel\/test-assert-async.js/,
/parallel\/test-assert-fail.js/,
/parallel\/test-assert.js/,
/parallel\/test-event-emitter-add-listeners.js --only/,
/parallel\/test-event-emitter-check-listener-leaks.js/,
/parallel\/test-util-i
]
[- TODO: -- ignoreも]
issue
FYI we also have an infrastructure for running actual node.js test cases under node/_tools. (Modify node/_tools/config.json and run node/_tools/setup.ts, then it will enable the test cases listed in config.json)
ERR_INVALID_ARG_TYPEの実装例
issue
Node.js test cases are usually more exhaustive than ours. So if native Node.js test cases are enabled, then we don't need our own version of test cases anymore.
issue
// todo(wafuwafu13) Add Windows and invalid caseも削除したい
どのみち通ってしまっている
code:js
if (isWindows) {
assert.throws(() => url.fileURLToPath('file:///C:/a%2F/'), {
code: 'ERR_INVALID_FILE_URL_PATH'
});
プロダクトコードのisWindowsを調整しないといけない
issue
TODO(wafuwafu13): implement ERR_INVALID_URL_SCHEME
I don't know why Generate locv is failing 😓
issue
const StringPrototypeStartsWith = String.prototype.startsWith;
node/tools/test通ってる
issue
issue
これは冗長
code: typescript
export function runningReduce<T, O>(
array: readonly T[],
reducer: (accumulator: O, current: T, index?: O) => O,
initialValue: O,
): O[] {
let currentResult = initialValue;
return reducer.length === 3
? array.map((el, index) =>
currentResult = reducer(currentResult, el, index as unknown as O)
)
: array.map((el) => currentResult = reducer(currentResult, el));
}
issue
TODO: isWindowsでプロダクトコードもisWindowsになる仕組み
issue
test-net-write-callbacks.jsがログいっぱいのやつ
code: js
// const N = 500000;
const N = 50000;
code: zsh
$ git checkout main
$ git fetch upstream
$ git merge upstream/main
$ git checkout repond-tests
$ git merge origin main
なぜか手元にある
code: zsh
deleted: node/_tools/suites/common/dns.js
deleted: node/_tools/suites/common/internet.js
これが原因で落ちる
test suites/internet/test-dns-ipv4.js ...error: Uncaught Error: Cannot find module '../common/internet'
test-net-reconnect.jsが新たに生成されている
config.jsonには追加時、現在もある
ファイル自体は手元、リモートにないので操作ミスっぽい? => TODO: 削除
test-net-timeout.jsが消されてる => TODO: 追加
TODO: ドキュメント(issueの存在、トラブルシューテぃング)
issue
どのテストが実装されていないか
code: typescript
import { config } from "./common.ts";
for await (const entry of Deno.readDir('node/_tools/versions/node-v15.5.1/test/parallel')) {
if (entry.name.includes("test-net") && !config.tests.parallel.includes(entry.name)) {
console.log(entry.name);
}
}
ディレクトリ名 + プレフィックス
なかったものの例
code: text
test-net-better-error-messages-listen-path
test-net-better-error-messages-path
test-net-binary
test-net-bytes-read
test-net-connect-bind-twice
test-net-connect-memleak
test-net-connect-options-allowhalfopen
issue
config.tests 以降の補完
issue
issue
issue
querystring実装していくかどうか
TypeError: Cannot read properties of undefined (reading 'split') から対応を始める
issue
TODO: setup時に要らないtagzやつ消すかどうか
issue
依存関係でトラブってる
issue
code: zsh
test suites/parallel/test-net-listen-close-server-callback-is-not-function.js ...error: TS2339 ERROR: Property 'addSignalListener' does not exist on type 'typeof Deno'. Deno.addSignalListener(event as Deno.Signal, listener);
~~~~~~~~~~~~~~~~~
at file:///Users/tagawahirotaka/Desktop/deno_std/node/process.ts:382:12
test result: FAILED. 1 passed; 110 failed; 0 ignored; 0 measured; 0 filtered out (839474ms)
LGTM too, I like this API better; it will be useful for std/node
unsteableフラグ?
code: zsh
~/desktop/deno_std
$ git submodule update --init
Cloning into '/Users/tagawahirotaka/Desktop/deno_std/wasi/testdata'...
remote: Enumerating objects: 355, done.
remote: Counting objects: 100% (355/355), done.
remote: Compressing objects: 100% (70/70), done.
remote: Total 313 (delta 253), reused 284 (delta 225), pack-reused 0
Receiving objects: 100% (313/313), 8.02 MiB | 5.10 MiB/s, done.
Resolving deltas: 100% (253/253), completed with 3 local objects.
* branch aa121de88de512680fe5752f0e9bfc07e311854c -> FETCH_HEAD
Submodule path 'wasi/testdata': checked out 'aa121de88de512680fe5752f0e9bfc07e311854c'
issue
process.tsのversion
issue
processの理解
30_fs.js function cwd()
issue
そもそもオーバーライド必要なくね?
オプションで指定できるしそうするべき
issue
これみたいに仕切りあったらいいね
混乱を生む
issue
エラー判定されないやつ
code: zsh
test-net-write-connect-write.js
test-stream-readable-add-chunk-during-data.js
test-stream-writable-end-cb-error.js
test suites/parallel/test-net-connect-buffer2.js
issue
Bufferの破壊的変更
issue
補完効いて欲しい
base = Number.isNaN(value.getTime()) ?
issue
inspectバグ拾い
code: js
// TODO(wafuwafu13): Implement correctly (faild test in 59~)
let type = "Function";
if (types.isGeneratorFunction(value)) {
type = Generator${type};
}
typesから攻めていくか...
util.inspect.defaultOptions = null;
export function toPathIfFileURL(fileURLOrPath: string | URL) {のFix
issue
primodialブランチ作ってる
util-logブランチ作ってる
issue
import/exportデバッグ
issue
code: check.ts
import { config } from "./common.ts";
const tests = []
for await (const entry of Deno.readDir('node/_tools/versions/node-v16.13.0/test/parallel')) {
if (entry.name.includes("test-fs") && !config.tests.parallel.includes(entry.name)) {
tests.push(entry.name)
}
}
console.log(tests.sort())
code: zsh
[
"test-fs-assert-encoding-error.js",
"test-fs-buffer.js",
"test-fs-buffertype-writesync.js",
"test-fs-close-errors.js",
"test-fs-close.js",
"test-fs-copyfile-respect-permissions.js",
"test-fs-cp.mjs",
"test-fs-empty-readStream.js",
"test-fs-error-messages.js",
"test-fs-exists.js",
"test-fs-existssync-false.js",
"test-fs-fchmod.js",
"test-fs-fchown.js",
"test-fs-filehandle-use-after-close.js",
"test-fs-filehandle.js",
"test-fs-fmap.js",
"test-fs-fsync.js",
"test-fs-lchmod.js",
"test-fs-lchown.js",
"test-fs-link.js",
"test-fs-long-path.js",
"test-fs-make-callback.js",
"test-fs-makeStatsCallback.js",
"test-fs-mkdir-mode-mask.js",
"test-fs-mkdir-recursive-eaccess.js",
"test-fs-mkdir-rmdir.js",
"test-fs-mkdir.js",
"test-fs-mkdtemp-prefix-check.js",
"test-fs-mkdtemp.js",
"test-fs-non-number-arguments-throw.js",
"test-fs-null-bytes.js",
"test-fs-open-flags.js",
"test-fs-open-mode-mask.js",
"test-fs-open-no-close.js",
"test-fs-open-numeric-flags.js",
"test-fs-open.js",
"test-fs-opendir.js",
"test-fs-options-immutable.js",
"test-fs-promises-exists.js",
"test-fs-promises-file-handle-append-file.js",
"test-fs-promises-file-handle-chmod.js",
"test-fs-promises-file-handle-close.js",
"test-fs-promises-file-handle-read-worker.js",
"test-fs-promises-file-handle-read.js",
"test-fs-promises-file-handle-readFile.js",
"test-fs-promises-file-handle-stat.js",
"test-fs-promises-file-handle-stream.js",
"test-fs-promises-file-handle-sync.js",
"test-fs-promises-file-handle-truncate.js",
"test-fs-promises-file-handle-write.js",
"test-fs-promises-file-handle-writeFile.js",
"test-fs-promises-readfile-empty.js",
"test-fs-promises-readfile-with-fd.js",
"test-fs-promises-readfile.js",
"test-fs-promises-watch.js",
"test-fs-promises-writefile-typedarray.js",
"test-fs-promises-writefile-with-fd.js",
"test-fs-promises-writefile.js",
"test-fs-promises.js",
"test-fs-promisified.js",
"test-fs-read-empty-buffer.js",
"test-fs-read-file-assert-encoding.js",
"test-fs-read-file-sync-hostname.js",
"test-fs-read-file-sync.js",
"test-fs-read-offset-null.js",
"test-fs-read-optional-params.js",
"test-fs-read-promises-optional-params.js",
"test-fs-read-stream-autoClose.js",
"test-fs-read-stream-concurrent-reads.js",
"test-fs-read-stream-double-close.js",
"test-fs-read-stream-encoding.js",
"test-fs-read-stream-err.js",
"test-fs-read-stream-fd-leak.js",
"test-fs-read-stream-fd.js",
"test-fs-read-stream-file-handle.js",
"test-fs-read-stream-inherit.js",
"test-fs-read-stream-patch-open.js",
"test-fs-read-stream-pos.js",
"test-fs-read-stream-resume.js",
"test-fs-read-stream-throw-type-error.js",
"test-fs-read-stream.js",
"test-fs-read-type.js",
"test-fs-read-zero-length.js",
"test-fs-read.js",
"test-fs-readSync-optional-params.js",
"test-fs-readdir-buffer.js",
"test-fs-readdir-types.js",
"test-fs-readdir-ucs2.js",
"test-fs-readfile-error.js",
"test-fs-readfile-fd.js",
"test-fs-readfile-flags.js",
"test-fs-readfile-pipe-large.js",
"test-fs-readfile-pipe.js",
"test-fs-readfile-unlink.js",
"test-fs-readfile-zero-byte-liar.js",
"test-fs-readfile.js",
"test-fs-readfilesync-enoent.js",
"test-fs-readfilesync-pipe-large.js",
"test-fs-readlink-type-check.js",
"test-fs-readv-promises.js",
... 70 more items
]