Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.7 KiB

  1. var spawn = require('child_process').spawn;
  2. var test = require('tap').test;
  3. test('dotSlashEmpty', testCmd('./bin.js', []));
  4. test('dotSlashArgs', testCmd('./bin.js', [ 'a', 'b', 'c' ]));
  5. test('nodeEmpty', testCmd('node bin.js', []));
  6. test('nodeArgs', testCmd('node bin.js', [ 'x', 'y', 'z' ]));
  7. test('whichNodeEmpty', function (t) {
  8. var which = spawn('which', ['node']);
  9. which.stdout.on('data', function (buf) {
  10. t.test(
  11. testCmd(buf.toString().trim() + ' bin.js', [])
  12. );
  13. t.end();
  14. });
  15. which.stderr.on('data', function (err) {
  16. assert.error(err);
  17. t.end();
  18. });
  19. });
  20. test('whichNodeArgs', function (t) {
  21. var which = spawn('which', ['node']);
  22. which.stdout.on('data', function (buf) {
  23. t.test(
  24. testCmd(buf.toString().trim() + ' bin.js', [ 'q', 'r' ])
  25. );
  26. t.end();
  27. });
  28. which.stderr.on('data', function (err) {
  29. t.error(err);
  30. t.end();
  31. });
  32. });
  33. function testCmd (cmd, args) {
  34. return function (t) {
  35. var to = setTimeout(function () {
  36. assert.fail('Never got stdout data.')
  37. }, 5000);
  38. var oldDir = process.cwd();
  39. process.chdir(__dirname + '/_');
  40. var cmds = cmd.split(' ');
  41. var bin = spawn(cmds[0], cmds.slice(1).concat(args.map(String)));
  42. process.chdir(oldDir);
  43. bin.stderr.on('data', function (err) {
  44. t.error(err);
  45. t.end();
  46. });
  47. bin.stdout.on('data', function (buf) {
  48. clearTimeout(to);
  49. var _ = JSON.parse(buf.toString());
  50. t.same(_.map(String), args.map(String));
  51. t.end();
  52. });
  53. };
  54. }