UNPKG

3.62 kBJavaScriptView Raw
1/**
2 * Tests windowslib's visualstudio module.
3 *
4 * @copyright
5 * Copyright (c) 2014 by Appcelerator, Inc. All Rights Reserved.
6 *
7 * @license
8 * Licensed under the terms of the Apache Public License.
9 * Please see the LICENSE included with this distribution for details.
10 */
11
12const
13 fs = require('fs'),
14 path = require('path'),
15 windowslib = require('..'),
16 wrench = require('wrench');
17
18describe('visualstudio', function () {
19 it('namespace should be an object', function () {
20 should(windowslib.visualstudio).be.an.Object;
21 });
22
23 (process.platform === 'win32' ? it : it.skip)('detect should find Visual Studio installations', function (done) {
24 this.timeout(5000);
25 this.slow(2000);
26
27 windowslib.visualstudio.detect(function (err, results) {
28 if (err) {
29 return done(err);
30 }
31
32 should(results).be.an.Object;
33 should(results).have.keys('selectedVisualStudio', 'visualstudio', 'issues');
34
35 should(results.selectedVisualStudio).be.an.Object;
36 checkVisualStudio(results.selectedVisualStudio);
37
38 if (results.visualstudio !== null) {
39 should(results.visualstudio).be.an.Object;
40 Object.keys(results.visualstudio).forEach(function (ver) {
41 checkVisualStudio(results.visualstudio[ver]);
42 });
43 }
44
45 should(results.issues).be.an.Array;
46 results.issues.forEach(function (issue) {
47 should(issue).be.an.Object;
48 should(issue).have.keys('id', 'type', 'message');
49 should(issue.id).be.a.String;
50 should(issue.type).be.a.String;
51 should(issue.type).match(/^info|warning|error$/);
52 should(issue.message).be.a.String;
53 });
54
55 done();
56 });
57 });
58
59 (process.platform === 'win32' ? it : it.skip)('should build with spaces in name', function (done) {
60 this.timeout(15000);
61 this.slow(2000);
62 var opts = {
63 buildConfiguration: 'Release',
64 project: path.join(__dirname, 'Name With Space', 'Name With Space.csproj')
65 };
66 windowslib.visualstudio.build(opts, function (err, result) {
67 if (err) {
68 return done(err);
69 }
70 should(result.code).equal(0);
71 should(fs.existsSync(path.join(__dirname, 'Name With Space', 'bin', 'Release', 'Name With Space.exe'))).equal(true);
72 wrench.rmdirSyncRecursive(path.join(__dirname, 'Name With Space', 'bin'));
73 done();
74 });
75 });
76});
77
78function checkVisualStudio(visualstudio) {
79 should(visualstudio).be.an.Object;
80 should(visualstudio).have.keys('version', 'registryKey', 'supported', 'vcvarsall', 'msbuildVersion', 'wpsdk', 'selected', 'path', 'clrVersion', 'vsDevCmd');
81
82 should(visualstudio.version).be.a.String;
83 should(visualstudio.version).not.equal('');
84
85 should(visualstudio.registryKey).be.a.String;
86 should(visualstudio.registryKey).not.equal('');
87
88 should(visualstudio.supported).be.a.Boolean;
89
90 should(visualstudio.vcvarsall).be.a.String;
91 should(visualstudio.vcvarsall).not.equal('');
92
93 should(visualstudio.msbuildVersion).be.a.String;
94 should(visualstudio.msbuildVersion).not.equal('');
95
96 if (visualstudio.wpsdk !== null) {
97 should(visualstudio.wpsdk).be.an.Object;
98 Object.keys(visualstudio.wpsdk).forEach(function (ver) {
99 should(visualstudio.wpsdk[ver]).be.an.Object;
100 should(visualstudio.wpsdk[ver]).have.keys('vcvarsphone');
101
102 should(visualstudio.wpsdk[ver].vcvarsphone).be.a.String;
103 should(visualstudio.wpsdk[ver].vcvarsphone).not.equal('');
104 should(fs.existsSync(visualstudio.wpsdk[ver].vcvarsphone)).be.ok;
105 });
106 }
107
108 should(visualstudio.selected).be.a.Boolean;
109
110 should(visualstudio.path).be.a.String;
111 should(visualstudio.path).not.equal('');
112 should(fs.existsSync(visualstudio.path)).be.ok;
113
114 should(visualstudio.clrVersion).be.a.String;
115 should(visualstudio.clrVersion).not.equal('');
116}