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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. var test = require('tap').test;
  2. var promzard = require('../');
  3. if (process.argv[2] === 'child') {
  4. return child()
  5. }
  6. test('exports', function (t) {
  7. t.plan(1);
  8. var spawn = require('child_process').spawn
  9. var child = spawn(process.execPath, [__filename, 'child'])
  10. var output = ''
  11. child.stderr.on('data', function (c) {
  12. output += c
  13. })
  14. setTimeout(function () {
  15. child.stdin.write('\n');
  16. }, 100)
  17. setTimeout(function () {
  18. child.stdin.end('55\n');
  19. }, 200)
  20. child.on('close', function () {
  21. console.error('output=%j', output)
  22. output = JSON.parse(output)
  23. t.same({
  24. a : 3,
  25. b : '!2b',
  26. c : {
  27. x : 55,
  28. y : '/tmp/y/file.txt',
  29. }
  30. }, output);
  31. t.end()
  32. })
  33. });
  34. function child () {
  35. var ctx = { tmpdir : '/tmp' }
  36. var file = __dirname + '/exports.input';
  37. promzard(file, ctx, function (err, output) {
  38. console.error(JSON.stringify(output))
  39. });
  40. }