source: trip-planner-front/node_modules/node-gyp/test/test-configure-python.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1'use strict'
2
3const test = require('tap').test
4const path = require('path')
5const devDir = require('./common').devDir()
6const gyp = require('../lib/node-gyp')
7const requireInject = require('require-inject')
8const configure = requireInject('../lib/configure', {
9 'graceful-fs': {
10 openSync: function () { return 0 },
11 closeSync: function () { },
12 writeFile: function (file, data, cb) { cb() },
13 stat: function (file, cb) { cb(null, {}) },
14 mkdir: function (dir, options, cb) { cb() }
15 }
16})
17
18const EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib')
19const SEPARATOR = process.platform === 'win32' ? ';' : ':'
20const SPAWN_RESULT = { on: function () { } }
21
22require('npmlog').level = 'warn'
23
24test('configure PYTHONPATH with no existing env', function (t) {
25 t.plan(1)
26
27 delete process.env.PYTHONPATH
28
29 var prog = gyp()
30 prog.parseArgv([])
31 prog.spawn = function () {
32 t.equal(process.env.PYTHONPATH, EXPECTED_PYPATH)
33 return SPAWN_RESULT
34 }
35 prog.devDir = devDir
36 configure(prog, [], t.fail)
37})
38
39test('configure PYTHONPATH with existing env of one dir', function (t) {
40 t.plan(2)
41
42 var existingPath = path.join('a', 'b')
43 process.env.PYTHONPATH = existingPath
44
45 var prog = gyp()
46 prog.parseArgv([])
47 prog.spawn = function () {
48 t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
49
50 var dirs = process.env.PYTHONPATH.split(SEPARATOR)
51 t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath])
52
53 return SPAWN_RESULT
54 }
55 prog.devDir = devDir
56 configure(prog, [], t.fail)
57})
58
59test('configure PYTHONPATH with existing env of multiple dirs', function (t) {
60 t.plan(2)
61
62 var pythonDir1 = path.join('a', 'b')
63 var pythonDir2 = path.join('b', 'c')
64 var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR)
65 process.env.PYTHONPATH = existingPath
66
67 var prog = gyp()
68 prog.parseArgv([])
69 prog.spawn = function () {
70 t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
71
72 var dirs = process.env.PYTHONPATH.split(SEPARATOR)
73 t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2])
74
75 return SPAWN_RESULT
76 }
77 prog.devDir = devDir
78 configure(prog, [], t.fail)
79})
Note: See TracBrowser for help on using the repository browser.