Front end of the Slack clone application.

test-configure-python.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. 'use strict'
  2. var test = require('tape')
  3. var path = require('path')
  4. var gyp = require('../lib/node-gyp')
  5. var requireInject = require('require-inject')
  6. var configure = requireInject('../lib/configure', {
  7. 'graceful-fs': {
  8. 'openSync': function (file, mode) { return 0; },
  9. 'closeSync': function (fd) { },
  10. 'writeFile': function (file, data, cb) { cb() },
  11. 'stat': function (file, cb) { cb(null, {}) }
  12. }
  13. })
  14. var EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib')
  15. var SEPARATOR = process.platform == 'win32' ? ';' : ':'
  16. var SPAWN_RESULT = { on: function () { } }
  17. test('configure PYTHONPATH with no existing env', function (t) {
  18. t.plan(1)
  19. delete process.env.PYTHONPATH
  20. var prog = gyp()
  21. prog.parseArgv([])
  22. prog.spawn = function () {
  23. t.equal(process.env.PYTHONPATH, EXPECTED_PYPATH)
  24. return SPAWN_RESULT
  25. }
  26. configure(prog, [], t.fail)
  27. })
  28. test('configure PYTHONPATH with existing env of one dir', function (t) {
  29. t.plan(2)
  30. var existingPath = path.join('a', 'b')
  31. process.env.PYTHONPATH = existingPath
  32. var prog = gyp()
  33. prog.parseArgv([])
  34. prog.spawn = function () {
  35. t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
  36. var dirs = process.env.PYTHONPATH.split(SEPARATOR)
  37. t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath])
  38. return SPAWN_RESULT
  39. }
  40. configure(prog, [], t.fail)
  41. })
  42. test('configure PYTHONPATH with existing env of multiple dirs', function (t) {
  43. t.plan(2)
  44. var pythonDir1 = path.join('a', 'b')
  45. var pythonDir2 = path.join('b', 'c')
  46. var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR)
  47. process.env.PYTHONPATH = existingPath
  48. var prog = gyp()
  49. prog.parseArgv([])
  50. prog.spawn = function () {
  51. t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
  52. var dirs = process.env.PYTHONPATH.split(SEPARATOR)
  53. t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2])
  54. return SPAWN_RESULT
  55. }
  56. configure(prog, [], t.fail)
  57. })