source: node_modules/node-gyp/test/test-configure-python.js@ 81bc7da

finki-main main
Last change on this file since 81bc7da was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[81bc7da]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 promises: {
16 writeFile: function (file, data) { return Promise.resolve(null) }
17 }
18 }
19})
20
21const EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib')
22const SEPARATOR = process.platform === 'win32' ? ';' : ':'
23const SPAWN_RESULT = { on: function () { } }
24
25require('npmlog').level = 'warn'
26
27test('configure PYTHONPATH with no existing env', function (t) {
28 t.plan(1)
29
30 delete process.env.PYTHONPATH
31
32 var prog = gyp()
33 prog.parseArgv([])
34 prog.spawn = function () {
35 t.equal(process.env.PYTHONPATH, EXPECTED_PYPATH)
36 return SPAWN_RESULT
37 }
38 prog.devDir = devDir
39 configure(prog, [], t.fail)
40})
41
42test('configure PYTHONPATH with existing env of one dir', function (t) {
43 t.plan(2)
44
45 var existingPath = path.join('a', 'b')
46 process.env.PYTHONPATH = existingPath
47
48 var prog = gyp()
49 prog.parseArgv([])
50 prog.spawn = function () {
51 t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
52
53 var dirs = process.env.PYTHONPATH.split(SEPARATOR)
54 t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath])
55
56 return SPAWN_RESULT
57 }
58 prog.devDir = devDir
59 configure(prog, [], t.fail)
60})
61
62test('configure PYTHONPATH with existing env of multiple dirs', function (t) {
63 t.plan(2)
64
65 var pythonDir1 = path.join('a', 'b')
66 var pythonDir2 = path.join('b', 'c')
67 var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR)
68 process.env.PYTHONPATH = existingPath
69
70 var prog = gyp()
71 prog.parseArgv([])
72 prog.spawn = function () {
73 t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
74
75 var dirs = process.env.PYTHONPATH.split(SEPARATOR)
76 t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2])
77
78 return SPAWN_RESULT
79 }
80 prog.devDir = devDir
81 configure(prog, [], t.fail)
82})
Note: See TracBrowser for help on using the repository browser.