Bug 1295867: Wait for all IO operations to complete before ending test tasks. r=aswan

MozReview-Commit-ID: A6DIpXE5M1R

--HG--
extra : rebase_source : 386f3e602a169ad105dc4bf9abe74c4c6ffe10c2
This commit is contained in:
Kris Maglione 2016-08-20 15:32:42 -07:00
Родитель 2c634c4cb0
Коммит 5f2a25f86e
1 изменённых файлов: 19 добавлений и 2 удалений

Просмотреть файл

@ -61,6 +61,19 @@ class BaseProcess {
this.spawn(options);
}
/**
* Waits for the process to exit and all of its pending IO operations to
* complete.
*
* @returns {Promise<void>}
*/
awaitFinished() {
return Promise.all([
this.exitPromise,
...this.pipes.map(pipe => pipe.closedPromise),
]);
}
/**
* Creates a null-terminated array of pointers to null-terminated C-strings,
* and returns it.
@ -130,8 +143,11 @@ let requests = {
process.wait();
return process.exitPromise.then(exitCode => {
process.awaitFinished().then(() => {
io.cleanupProcess(process);
});
return process.exitPromise.then(exitCode => {
return {data: {exitCode}};
});
},
@ -163,7 +179,8 @@ let requests = {
},
waitForNoProcesses() {
return Promise.all(Array.from(io.processes.values(), proc => proc.exitPromise));
return Promise.all(Array.from(io.processes.values(),
proc => proc.awaitFinished()));
},
};