test_runner: support mock file system
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.3k
- Merge medio
- 4g 2h
- PR unite (30g)
- 283
Descrizione
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?
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando il namespace mock di test_runner e le API del file system descritte nell’issue. Definisci come mock.fileSystem.enable gestisce i file configurati, ricorre al file system reale e gestisce la modalità di override; il lavoro è completato quando questi comportamenti sono esposti e coperti dai test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, node.js
- Ambito
- operating-systems, testing-qa
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100