test_runner: support mock file system
オープン
まだ誰も着手していません。
feature request
fs
test_runner
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
What is the problem this feature will solve?
The current test requires writing files to a real disk when reading and writing files related to the file system, which is very unsafe.
After all, the file may remain due to test case failure and other reasons.
What is the feature you are proposing to solve the problem?
Under the mock namespace, APIs are exposed to provide a mock file system.
mock.fileSystem.enable({ });
And provide some options
e.g.
Override the file that defined by defaults
mock.fileSystem.enable({
files: {
'/path/to/file': new Uint8Array([0])
}
});
// it will read the virtual file system first if it does exist
// if not found, then read the read the real file system
fs.readFileSync('/path/to/file')
Override the whole file system
mock.fileSystem.enable({
files: {
'/path/to/file': new Uint8Array([0])
},
override: true // override the whole file system
});
// This file is exists in the real file system
// But not define in the vitual file system, so it should throw an error
fs.readFileSync('/etc/proc')
What alternatives have you considered?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、test_runner の mock 名前空間と、issue で説明されているファイルシステム API を確認します。mock.fileSystem.enable が設定済みファイルをどのように処理し、実際のファイルシステムにフォールバックし、オーバーライドモードをどのように扱うかを定義します。これらの動作が公開され、テストでカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, node.js
- 領域
- operating-systems, testing-qa
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100