test_runner: support mock file system
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
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?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Überprüfung des mock-Namespace von test_runner und der in der Issue beschriebenen Dateisystem-APIs. Definiere, wie mock.fileSystem.enable konfigurierte Dateien verarbeitet, auf das echte Dateisystem zurückfällt und den Überschreibmodus handhabt; abgeschlossen ist die Aufgabe, wenn diese Verhaltensweisen verfügbar und durch Tests abgedeckt sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js
- Bereich
- operating-systems, testing-qa
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100