process.exit before console buffer flushed in Windows
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 38/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- javascript
- Domaine
- cli, operating-systems, testing
Piste de recherche
Commencez dans bin/nodeunit autour des lignes 128-132, en particulier sur process.exit(1) à la ligne 130, et reproduisez le problème avec le tests.js fourni sous Cygwin. Confirmez que les exécutions échouées affichent toute la sortie de la console tout en renvoyant toujours le code de sortie 1 ; le contournement existant fournit le comportement attendu à vérifier.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Symptoms
If any test fails, not all the console output is shown (console output is truncated).
Problem does not show up in standard Windows cmd, but does show up if tests are run from Cygwin or within Sublime Text build system. In Cygwin, if the output is piped to a file instead of being displayed on the console then all the results show in the file, even though they did not show in the console when not piped.
Environment
- nodeunit 0.9.0,
- node 0.10.17
- Windows 7
Minimal Example
I have the following test file, tests.js:
for (var i = 0; i < 30; i++)
console.log('' + i);
exports.dummy = function(test) {
test.fail();
test.done();
}
Running from Cygwin, the result is:
$ nodeunit tests.js
0
(I.e., only the first console.log appears). But if I remove the test.fail line then all the output appears.
Cause
My guess of the cause is given in the title. It appears that under different circumstances, sometimes the node console is asynchronous (perhaps due to the way Windows pipes work, I'm not sure), and doesn't flush the output after every write. When a test fails, line 130 in nodeunit/nodeunit process.exit(1); seems to recognize the error and exit the process, but process.exit does not seem to always wait for the console output to be received by the terminal. To confirm this hypothesis, if I remove the process.exit line, then the output is displayed correctly.
Solution
A work-around seems to be to change lines 128-132 to the following:
testrunner.run(files, options, function(err) {
if (err) {
process.on('exit', function() {
process.exit(1);
});
}
});
This seems to produce the correct error code for the process and also show all the output. I don't know if there are any other side effects of not ending the process immediately in the callback function.
- Langage dominant
- JavaScript
- Étoiles
- 1.9k
- Forks
- 359
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de caolan/nodeunit
-
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 42/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 20/100
Toutes les issues de caolan/nodeunit
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Billionmail/BillionMail#389 ·
-
beginner-friendly category:finding-titles community enhancement first-timers-only good first issue hacktoberfest help wanted low hanging fruit micro-contribution type: task up-for-grabs
Difficulté 1/5 1-3 heures Accessibilité débutants 85/100
Berserk-hub150/skillhawk#227 · 1 commentaire ·
Les mainteneurs répondent en général sous 8 jours
-
Remove responsibilities not working in Custom Roles & BadgesPeut-être pris @thomasgwatson l’a pris aujourd’hui. Ouverteagent-ready agent:needs-test
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
gkjohnson/three-mesh-bvh#933 ·
-
scope: curriculum status: waiting triage
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
freeCodeCamp/freeCodeCamp#71076 ·
Les mainteneurs répondent en général sous 1 jour