123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670 |
- 'use strict'
-
- const { describe, it } = require('mocha')
- const assert = require('assert')
- const fs = require('fs')
- const path = require('path')
- const findVisualStudio = require('../lib/find-visualstudio')
- const VisualStudioFinder = findVisualStudio.test.VisualStudioFinder
-
- const semverV1 = { major: 1, minor: 0, patch: 0 }
-
- delete process.env.VCINSTALLDIR
-
- function poison (object, property) {
- function fail () {
- console.error(Error(`Property ${property} should not have been accessed.`))
- process.abort()
- }
- var descriptor = {
- configurable: false,
- enumerable: false,
- get: fail,
- set: fail
- }
- Object.defineProperty(object, property, descriptor)
- }
-
- function TestVisualStudioFinder () { VisualStudioFinder.apply(this, arguments) }
- TestVisualStudioFinder.prototype = Object.create(VisualStudioFinder.prototype)
- // Silence npmlog - remove for debugging
- TestVisualStudioFinder.prototype.log = {
- silly: () => {},
- verbose: () => {},
- info: () => {},
- warn: () => {},
- error: () => {}
- }
-
- describe('find-visualstudio', function () {
- it('VS2013', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info, {
- msBuild: 'C:\\MSBuild12\\MSBuild.exe',
- path: 'C:\\VS2013',
- sdk: null,
- toolset: 'v120',
- version: '12.0',
- versionMajor: 12,
- versionMinor: 0,
- versionYear: 2013
- })
- })
-
- finder.findVisualStudio2017OrNewer = (cb) => {
- finder.parseData(new Error(), '', '', cb)
- }
- finder.regSearchKeys = (keys, value, addOpts, cb) => {
- for (var i = 0; i < keys.length; ++i) {
- const fullName = `${keys[i]}\\${value}`
- switch (fullName) {
- case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
- case 'HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
- continue
- case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\12.0':
- assert.ok(true, `expected search for registry value ${fullName}`)
- return cb(null, 'C:\\VS2013\\VC\\')
- case 'HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions\\12.0\\MSBuildToolsPath':
- assert.ok(true, `expected search for registry value ${fullName}`)
- return cb(null, 'C:\\MSBuild12\\')
- default:
- assert.fail(`unexpected search for registry value ${fullName}`)
- }
- }
- return cb(new Error())
- }
- finder.findVisualStudio()
- })
-
- it('VS2013 should not be found on new node versions', function () {
- const finder = new TestVisualStudioFinder({
- major: 10,
- minor: 0,
- patch: 0
- }, null, (err, info) => {
- assert.ok(/find .* Visual Studio/i.test(err), 'expect error')
- assert.ok(!info, 'no data')
- })
-
- finder.findVisualStudio2017OrNewer = (cb) => {
- const file = path.join(__dirname, 'fixtures', 'VS_2017_Unusable.txt')
- const data = fs.readFileSync(file)
- finder.parseData(null, data, '', cb)
- }
- finder.regSearchKeys = (keys, value, addOpts, cb) => {
- for (var i = 0; i < keys.length; ++i) {
- const fullName = `${keys[i]}\\${value}`
- switch (fullName) {
- case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
- case 'HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
- continue
- default:
- assert.fail(`unexpected search for registry value ${fullName}`)
- }
- }
- return cb(new Error())
- }
- finder.findVisualStudio()
- })
-
- it('VS2015', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info, {
- msBuild: 'C:\\MSBuild14\\MSBuild.exe',
- path: 'C:\\VS2015',
- sdk: null,
- toolset: 'v140',
- version: '14.0',
- versionMajor: 14,
- versionMinor: 0,
- versionYear: 2015
- })
- })
-
- finder.findVisualStudio2017OrNewer = (cb) => {
- finder.parseData(new Error(), '', '', cb)
- }
- finder.regSearchKeys = (keys, value, addOpts, cb) => {
- for (var i = 0; i < keys.length; ++i) {
- const fullName = `${keys[i]}\\${value}`
- switch (fullName) {
- case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
- assert.ok(true, `expected search for registry value ${fullName}`)
- return cb(null, 'C:\\VS2015\\VC\\')
- case 'HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions\\14.0\\MSBuildToolsPath':
- assert.ok(true, `expected search for registry value ${fullName}`)
- return cb(null, 'C:\\MSBuild14\\')
- default:
- assert.fail(`unexpected search for registry value ${fullName}`)
- }
- }
- return cb(new Error())
- }
- finder.findVisualStudio()
- })
-
- it('error from PowerShell', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, null)
-
- finder.parseData(new Error(), '', '', (info) => {
- assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
- assert.ok(!info, 'no data')
- })
- })
-
- it('empty output from PowerShell', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, null)
-
- finder.parseData(null, '', '', (info) => {
- assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
- assert.ok(!info, 'no data')
- })
- })
-
- it('output from PowerShell not JSON', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, null)
-
- finder.parseData(null, 'AAAABBBB', '', (info) => {
- assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
- assert.ok(!info, 'no data')
- })
- })
-
- it('wrong JSON from PowerShell', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, null)
-
- finder.parseData(null, '{}', '', (info) => {
- assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
- assert.ok(!info, 'no data')
- })
- })
-
- it('empty JSON from PowerShell', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, null)
-
- finder.parseData(null, '[]', '', (info) => {
- assert.ok(/find .* Visual Studio/i.test(finder.errorLog[0]), 'expect error')
- assert.ok(!info, 'no data')
- })
- })
-
- it('future version', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, null)
-
- finder.parseData(null, JSON.stringify([{
- packages: [
- 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
- 'Microsoft.VisualStudio.Component.Windows10SDK.17763',
- 'Microsoft.VisualStudio.VC.MSBuild.Base'
- ],
- path: 'C:\\VS',
- version: '9999.9999.9999.9999'
- }]), '', (info) => {
- assert.ok(/unknown version/i.test(finder.errorLog[0]), 'expect error')
- assert.ok(/find .* Visual Studio/i.test(finder.errorLog[1]), 'expect error')
- assert.ok(!info, 'no data')
- })
- })
-
- it('single unusable VS2017', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, null)
-
- const file = path.join(__dirname, 'fixtures', 'VS_2017_Unusable.txt')
- const data = fs.readFileSync(file)
- finder.parseData(null, data, '', (info) => {
- assert.ok(/checking/i.test(finder.errorLog[0]), 'expect error')
- assert.ok(/find .* Visual Studio/i.test(finder.errorLog[2]), 'expect error')
- assert.ok(!info, 'no data')
- })
- })
-
- it('minimal VS2017 Build Tools', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info, {
- msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\' +
- 'BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe',
- path:
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools',
- sdk: '10.0.17134.0',
- toolset: 'v141',
- version: '15.9.28307.665',
- versionMajor: 15,
- versionMinor: 9,
- versionYear: 2017
- })
- })
-
- poison(finder, 'regSearchKeys')
- finder.findVisualStudio2017OrNewer = (cb) => {
- const file = path.join(__dirname, 'fixtures',
- 'VS_2017_BuildTools_minimal.txt')
- const data = fs.readFileSync(file)
- finder.parseData(null, data, '', cb)
- }
- finder.findVisualStudio()
- })
-
- it('VS2017 Community with C++ workload', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info, {
- msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\' +
- 'Community\\MSBuild\\15.0\\Bin\\MSBuild.exe',
- path:
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community',
- sdk: '10.0.17763.0',
- toolset: 'v141',
- version: '15.9.28307.665',
- versionMajor: 15,
- versionMinor: 9,
- versionYear: 2017
- })
- })
-
- poison(finder, 'regSearchKeys')
- finder.findVisualStudio2017OrNewer = (cb) => {
- const file = path.join(__dirname, 'fixtures',
- 'VS_2017_Community_workload.txt')
- const data = fs.readFileSync(file)
- finder.parseData(null, data, '', cb)
- }
- finder.findVisualStudio()
- })
-
- it('VS2017 Express', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info, {
- msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\' +
- 'WDExpress\\MSBuild\\15.0\\Bin\\MSBuild.exe',
- path:
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\WDExpress',
- sdk: '10.0.17763.0',
- toolset: 'v141',
- version: '15.9.28307.858',
- versionMajor: 15,
- versionMinor: 9,
- versionYear: 2017
- })
- })
-
- poison(finder, 'regSearchKeys')
- finder.findVisualStudio2017OrNewer = (cb) => {
- const file = path.join(__dirname, 'fixtures', 'VS_2017_Express.txt')
- const data = fs.readFileSync(file)
- finder.parseData(null, data, '', cb)
- }
- finder.findVisualStudio()
- })
-
- it('VS2019 Preview with C++ workload', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info, {
- msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\' +
- 'Preview\\MSBuild\\Current\\Bin\\MSBuild.exe',
- path:
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview',
- sdk: '10.0.17763.0',
- toolset: 'v142',
- version: '16.0.28608.199',
- versionMajor: 16,
- versionMinor: 0,
- versionYear: 2019
- })
- })
-
- poison(finder, 'regSearchKeys')
- finder.findVisualStudio2017OrNewer = (cb) => {
- const file = path.join(__dirname, 'fixtures',
- 'VS_2019_Preview.txt')
- const data = fs.readFileSync(file)
- finder.parseData(null, data, '', cb)
- }
- finder.findVisualStudio()
- })
-
- it('minimal VS2019 Build Tools', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info, {
- msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\' +
- 'BuildTools\\MSBuild\\Current\\Bin\\MSBuild.exe',
- path:
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools',
- sdk: '10.0.17134.0',
- toolset: 'v142',
- version: '16.1.28922.388',
- versionMajor: 16,
- versionMinor: 1,
- versionYear: 2019
- })
- })
-
- poison(finder, 'regSearchKeys')
- finder.findVisualStudio2017OrNewer = (cb) => {
- const file = path.join(__dirname, 'fixtures',
- 'VS_2019_BuildTools_minimal.txt')
- const data = fs.readFileSync(file)
- finder.parseData(null, data, '', cb)
- }
- finder.findVisualStudio()
- })
-
- it('VS2019 Community with C++ workload', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info, {
- msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\' +
- 'Community\\MSBuild\\Current\\Bin\\MSBuild.exe',
- path:
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community',
- sdk: '10.0.17763.0',
- toolset: 'v142',
- version: '16.1.28922.388',
- versionMajor: 16,
- versionMinor: 1,
- versionYear: 2019
- })
- })
-
- poison(finder, 'regSearchKeys')
- finder.findVisualStudio2017OrNewer = (cb) => {
- const file = path.join(__dirname, 'fixtures',
- 'VS_2019_Community_workload.txt')
- const data = fs.readFileSync(file)
- finder.parseData(null, data, '', cb)
- }
- finder.findVisualStudio()
- })
-
- it('VS2022 Preview with C++ workload', function () {
- const msBuildPath = process.arch === 'arm64'
- ? 'C:\\Program Files\\Microsoft Visual Studio\\2022\\' +
- 'Community\\MSBuild\\Current\\Bin\\arm64\\MSBuild.exe'
- : 'C:\\Program Files\\Microsoft Visual Studio\\2022\\' +
- 'Community\\MSBuild\\Current\\Bin\\MSBuild.exe'
-
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info, {
- msBuild: msBuildPath,
- path:
- 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community',
- sdk: '10.0.22621.0',
- toolset: 'v143',
- version: '17.4.33213.308',
- versionMajor: 17,
- versionMinor: 4,
- versionYear: 2022
- })
- })
-
- poison(finder, 'regSearchKeys')
- finder.msBuildPathExists = (path) => {
- return true
- }
- finder.findVisualStudio2017OrNewer = (cb) => {
- const file = path.join(__dirname, 'fixtures',
- 'VS_2022_Community_workload.txt')
- const data = fs.readFileSync(file)
- finder.parseData(null, data, '', cb)
- }
- finder.findVisualStudio()
- })
-
- function allVsVersions (finder) {
- finder.findVisualStudio2017OrNewer = (cb) => {
- const data0 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
- 'VS_2017_Unusable.txt')))
- const data1 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
- 'VS_2017_BuildTools_minimal.txt')))
- const data2 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
- 'VS_2017_Community_workload.txt')))
- const data3 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
- 'VS_2017_Express.txt')))
- const data4 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
- 'VS_2019_Preview.txt')))
- const data5 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
- 'VS_2019_BuildTools_minimal.txt')))
- const data6 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
- 'VS_2019_Community_workload.txt')))
- const data7 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
- 'VS_2022_Community_workload.txt')))
- const data = JSON.stringify(data0.concat(data1, data2, data3, data4,
- data5, data6, data7))
- finder.parseData(null, data, '', cb)
- }
- finder.regSearchKeys = (keys, value, addOpts, cb) => {
- for (var i = 0; i < keys.length; ++i) {
- const fullName = `${keys[i]}\\${value}`
- switch (fullName) {
- case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
- case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\12.0':
- continue
- case 'HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7\\12.0':
- return cb(null, 'C:\\VS2013\\VC\\')
- case 'HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions\\12.0\\MSBuildToolsPath':
- return cb(null, 'C:\\MSBuild12\\')
- case 'HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
- return cb(null, 'C:\\VS2015\\VC\\')
- case 'HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions\\14.0\\MSBuildToolsPath':
- return cb(null, 'C:\\MSBuild14\\')
- default:
- assert.fail(`unexpected search for registry value ${fullName}`)
- }
- }
- return cb(new Error())
- }
- }
-
- it('fail when looking for invalid path', function () {
- const finder = new TestVisualStudioFinder(semverV1, 'AABB', (err, info) => {
- assert.ok(/find .* Visual Studio/i.test(err), 'expect error')
- assert.ok(!info, 'no data')
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('look for VS2013 by version number', function () {
- const finder = new TestVisualStudioFinder(semverV1, '2013', (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.versionYear, 2013)
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('look for VS2013 by installation path', function () {
- const finder = new TestVisualStudioFinder(semverV1, 'C:\\VS2013',
- (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.path, 'C:\\VS2013')
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('look for VS2015 by version number', function () {
- const finder = new TestVisualStudioFinder(semverV1, '2015', (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.versionYear, 2015)
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('look for VS2015 by installation path', function () {
- const finder = new TestVisualStudioFinder(semverV1, 'C:\\VS2015',
- (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.path, 'C:\\VS2015')
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('look for VS2017 by version number', function () {
- const finder = new TestVisualStudioFinder(semverV1, '2017', (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.versionYear, 2017)
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('look for VS2017 by installation path', function () {
- const finder = new TestVisualStudioFinder(semverV1,
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community',
- (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.path,
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community')
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('look for VS2019 by version number', function () {
- const finder = new TestVisualStudioFinder(semverV1, '2019', (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.versionYear, 2019)
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('look for VS2019 by installation path', function () {
- const finder = new TestVisualStudioFinder(semverV1,
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools',
- (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.path,
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools')
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('look for VS2022 by version number', function () {
- const finder = new TestVisualStudioFinder(semverV1, '2022', (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.versionYear, 2022)
- })
-
- finder.msBuildPathExists = (path) => {
- return true
- }
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('msvs_version match should be case insensitive', function () {
- const finder = new TestVisualStudioFinder(semverV1,
- 'c:\\program files (x86)\\microsoft visual studio\\2019\\BUILDTOOLS',
- (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.path,
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools')
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('latest version should be found by default', function () {
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.versionYear, 2022)
- })
-
- finder.msBuildPathExists = (path) => {
- return true
- }
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('run on a usable VS Command Prompt', function () {
- process.env.VCINSTALLDIR = 'C:\\VS2015\\VC'
- // VSINSTALLDIR is not defined on Visual C++ Build Tools 2015
- delete process.env.VSINSTALLDIR
-
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.path, 'C:\\VS2015')
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('VCINSTALLDIR match should be case insensitive', function () {
- process.env.VCINSTALLDIR =
- 'c:\\program files (x86)\\microsoft visual studio\\2019\\BUILDTOOLS\\VC'
-
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.path,
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools')
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('run on a unusable VS Command Prompt', function () {
- process.env.VCINSTALLDIR =
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildToolsUnusable\\VC'
-
- const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
- assert.ok(/find .* Visual Studio/i.test(err), 'expect error')
- assert.ok(!info, 'no data')
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('run on a VS Command Prompt with matching msvs_version', function () {
- process.env.VCINSTALLDIR = 'C:\\VS2015\\VC'
-
- const finder = new TestVisualStudioFinder(semverV1, 'C:\\VS2015',
- (err, info) => {
- assert.strictEqual(err, null)
- assert.deepStrictEqual(info.path, 'C:\\VS2015')
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
-
- it('run on a VS Command Prompt with mismatched msvs_version', function () {
- process.env.VCINSTALLDIR =
- 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC'
-
- const finder = new TestVisualStudioFinder(semverV1, 'C:\\VS2015',
- (err, info) => {
- assert.ok(/find .* Visual Studio/i.test(err), 'expect error')
- assert.ok(!info, 'no data')
- })
-
- allVsVersions(finder)
- finder.findVisualStudio()
- })
- })
|