Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

run-tests.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env node
  2. require('../global');
  3. var path = require('path');
  4. var failed = false;
  5. //
  6. // Lint
  7. //
  8. JSHINT_BIN = './node_modules/jshint/bin/jshint';
  9. cd(__dirname + '/..');
  10. if (!test('-f', JSHINT_BIN)) {
  11. echo('JSHint not found. Run `npm install` in the root dir first.');
  12. exit(1);
  13. }
  14. if (exec(JSHINT_BIN + ' *.js test/*.js').code !== 0) {
  15. failed = true;
  16. echo('*** JSHINT FAILED! (return code != 0)');
  17. echo();
  18. } else {
  19. echo('All JSHint tests passed');
  20. echo();
  21. }
  22. //
  23. // Unit tests
  24. //
  25. cd(__dirname + '/../test');
  26. ls('*.js').forEach(function(file) {
  27. echo('Running test:', file);
  28. if (exec('node ' + file).code !== 123) { // 123 avoids false positives (e.g. premature exit)
  29. failed = true;
  30. echo('*** TEST FAILED! (missing exit code "123")');
  31. echo();
  32. }
  33. });
  34. if (failed) {
  35. echo();
  36. echo('*******************************************************');
  37. echo('WARNING: Some tests did not pass!');
  38. echo('*******************************************************');
  39. exit(1);
  40. } else {
  41. echo();
  42. echo('All tests passed.');
  43. }