You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test-create-config-gypi.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict'
  2. const path = require('path')
  3. const { describe, it } = require('mocha')
  4. const assert = require('assert')
  5. const gyp = require('../lib/node-gyp')
  6. const createConfigGypi = require('../lib/create-config-gypi')
  7. const { parseConfigGypi, getCurrentConfigGypi } = createConfigGypi.test
  8. describe('create-config-gypi', function () {
  9. it('config.gypi with no options', async function () {
  10. const prog = gyp()
  11. prog.parseArgv([])
  12. const config = await getCurrentConfigGypi({ gyp: prog, vsInfo: {} })
  13. assert.strictEqual(config.target_defaults.default_configuration, 'Release')
  14. assert.strictEqual(config.variables.target_arch, process.arch)
  15. })
  16. it('config.gypi with --debug', async function () {
  17. const prog = gyp()
  18. prog.parseArgv(['_', '_', '--debug'])
  19. const config = await getCurrentConfigGypi({ gyp: prog, vsInfo: {} })
  20. assert.strictEqual(config.target_defaults.default_configuration, 'Debug')
  21. })
  22. it('config.gypi with custom options', async function () {
  23. const prog = gyp()
  24. prog.parseArgv(['_', '_', '--shared-libxml2'])
  25. const config = await getCurrentConfigGypi({ gyp: prog, vsInfo: {} })
  26. assert.strictEqual(config.variables.shared_libxml2, true)
  27. })
  28. it('config.gypi with nodedir', async function () {
  29. const nodeDir = path.join(__dirname, 'fixtures', 'nodedir')
  30. const prog = gyp()
  31. prog.parseArgv(['_', '_', `--nodedir=${nodeDir}`])
  32. const config = await getCurrentConfigGypi({ gyp: prog, nodeDir, vsInfo: {} })
  33. assert.strictEqual(config.variables.build_with_electron, true)
  34. })
  35. it('config.gypi with --force-process-config', async function () {
  36. const nodeDir = path.join(__dirname, 'fixtures', 'nodedir')
  37. const prog = gyp()
  38. prog.parseArgv(['_', '_', '--force-process-config', `--nodedir=${nodeDir}`])
  39. const config = await getCurrentConfigGypi({ gyp: prog, nodeDir, vsInfo: {} })
  40. assert.strictEqual(config.variables.build_with_electron, undefined)
  41. })
  42. it('config.gypi parsing', function () {
  43. const str = "# Some comments\n{'variables': {'multiline': 'A'\n'B'}}"
  44. const config = parseConfigGypi(str)
  45. assert.deepStrictEqual(config, { variables: { multiline: 'AB' } })
  46. })
  47. })