summaryrefslogtreecommitdiff
path: root/server/.yarn/unplugged/node-gyp-npm-9.3.1-43540bab9c/node_modules/node-gyp/test/test-create-config-gypi.js
blob: eeac73fab1dccffae33da28c8d722bd4a10224ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'use strict'

const path = require('path')
const { test } = require('tap')
const gyp = require('../lib/node-gyp')
const createConfigGypi = require('../lib/create-config-gypi')
const { parseConfigGypi, getCurrentConfigGypi } = createConfigGypi.test

test('config.gypi with no options', async function (t) {
  t.plan(2)

  const prog = gyp()
  prog.parseArgv([])

  const config = await getCurrentConfigGypi({ gyp: prog, vsInfo: {} })
  t.equal(config.target_defaults.default_configuration, 'Release')
  t.equal(config.variables.target_arch, process.arch)
})

test('config.gypi with --debug', async function (t) {
  t.plan(1)

  const prog = gyp()
  prog.parseArgv(['_', '_', '--debug'])

  const config = await getCurrentConfigGypi({ gyp: prog, vsInfo: {} })
  t.equal(config.target_defaults.default_configuration, 'Debug')
})

test('config.gypi with custom options', async function (t) {
  t.plan(1)

  const prog = gyp()
  prog.parseArgv(['_', '_', '--shared-libxml2'])

  const config = await getCurrentConfigGypi({ gyp: prog, vsInfo: {} })
  t.equal(config.variables.shared_libxml2, true)
})

test('config.gypi with nodedir', async function (t) {
  t.plan(1)

  const nodeDir = path.join(__dirname, 'fixtures', 'nodedir')

  const prog = gyp()
  prog.parseArgv(['_', '_', `--nodedir=${nodeDir}`])

  const config = await getCurrentConfigGypi({ gyp: prog, nodeDir, vsInfo: {} })
  t.equal(config.variables.build_with_electron, true)
})

test('config.gypi with --force-process-config', async function (t) {
  t.plan(1)

  const nodeDir = path.join(__dirname, 'fixtures', 'nodedir')

  const prog = gyp()
  prog.parseArgv(['_', '_', '--force-process-config', `--nodedir=${nodeDir}`])

  const config = await getCurrentConfigGypi({ gyp: prog, nodeDir, vsInfo: {} })
  t.equal(config.variables.build_with_electron, undefined)
})

test('config.gypi parsing', function (t) {
  t.plan(1)

  const str = "# Some comments\n{'variables': {'multiline': 'A'\n'B'}}"
  const config = parseConfigGypi(str)
  t.deepEqual(config, { variables: { multiline: 'AB' } })
})