106 строки
3.5 KiB
JavaScript
106 строки
3.5 KiB
JavaScript
|
#!/usr/bin/env node
|
||
|
/**
|
||
|
* Copyright (c) Microsoft. All rights reserved.
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
|
var fs = require('fs');
|
||
|
|
||
|
var args = (process.ARGV || process.argv);
|
||
|
|
||
|
var coverageOption = Array.prototype.indexOf.call(args, '-coverage');
|
||
|
|
||
|
if (coverageOption !== -1) {
|
||
|
args.splice(coverageOption, 1);
|
||
|
}
|
||
|
|
||
|
var testList = args.pop();
|
||
|
|
||
|
var fileContent;
|
||
|
var root = false;
|
||
|
|
||
|
if (!fs.existsSync) {
|
||
|
fs.existsSync = require('path').existsSync;
|
||
|
}
|
||
|
|
||
|
if (fs.existsSync(testList)) {
|
||
|
fileContent = fs.readFileSync(testList).toString();
|
||
|
} else {
|
||
|
fileContent = fs.readFileSync('./test/' + testList).toString();
|
||
|
root = true;
|
||
|
}
|
||
|
|
||
|
var files = fileContent.split('\n');
|
||
|
|
||
|
args.push('-u');
|
||
|
args.push('tdd');
|
||
|
|
||
|
files.forEach(function (file) {
|
||
|
if (file.length > 0 && file.trim()[0] !== '#') {
|
||
|
// trim trailing \r if it exists
|
||
|
file = file.replace('\r', '');
|
||
|
|
||
|
if (root) {
|
||
|
args.push('test/' + file);
|
||
|
} else {
|
||
|
args.push(file);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
if (coverageOption !== -1) {
|
||
|
args.push('-R');
|
||
|
args.push('html-cov');
|
||
|
} else {
|
||
|
args.push('-R');
|
||
|
args.push('list');
|
||
|
}
|
||
|
|
||
|
var defaultStorageAccount = 'ciserversdk';
|
||
|
var defaultServiceBusAccount = 'ciserversb';
|
||
|
var defaultSubscription = '279b0675-cf67-467f-98f0-67ae31eb540f';
|
||
|
|
||
|
if (!process.env.NOCK_OFF && !process.env.AZURE_NOCK_RECORD) {
|
||
|
if (process.env.AZURE_STORAGE_ACCOUNT !== defaultStorageAccount) {
|
||
|
process.env.AZURE_STORAGE_ACCOUNT = defaultStorageAccount;
|
||
|
process.env.AZURE_STORAGE_ACCESS_KEY = new Buffer('fake_key').toString('base64');
|
||
|
}
|
||
|
|
||
|
if (process.env.AZURE_SERVICEBUS_NAMESPACE !== defaultServiceBusAccount) {
|
||
|
process.env.AZURE_SERVICEBUS_NAMESPACE = defaultServiceBusAccount;
|
||
|
process.env.AZURE_SERVICEBUS_ACCESS_KEY = new Buffer('fake_key').toString('base64');
|
||
|
}
|
||
|
|
||
|
if (process.env.AZURE_SUBSCRIPTION_ID !== defaultSubscription) {
|
||
|
process.env.AZURE_SUBSCRIPTION_ID = defaultSubscription;
|
||
|
process.env.AZURE_CERTIFICATE = 'fake_certificate';
|
||
|
process.env.AZURE_CERTIFICATE_KEY = 'fake_certificate_key';
|
||
|
}
|
||
|
} else if (!process.env.NOCK_OFF && process.env.AZURE_NOCK_RECORD) {
|
||
|
// If in record mode, and environment variables are set, make sure they are the expected one for recording
|
||
|
// NOTE: For now, only the Core team can update recordings. For non-core team PRs, the recordings will be updated
|
||
|
// after merge
|
||
|
if (process.env.AZURE_STORAGE_ACCOUNT && process.env.AZURE_STORAGE_ACCOUNT !== defaultStorageAccount) {
|
||
|
throw new Error('Storage recordings can only be made with the account ' + defaultStorageAccount);
|
||
|
}
|
||
|
|
||
|
if (process.env.AZURE_SERVICEBUS_NAMESPACE && process.env.AZURE_SERVICEBUS_NAMESPACE !== defaultServiceBusAccount) {
|
||
|
throw new Error('Service Bus recordings can only be made with the namespace ' + defaultServiceBusAccount);
|
||
|
}
|
||
|
|
||
|
if (process.env.AZURE_SUBSCRIPTION_ID && process.env.AZURE_SUBSCRIPTION_ID !== defaultSubscription) {
|
||
|
throw new Error('Service Management recordings can only be made with the subscription ' + defaultSubscription);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
require('../node_modules/mocha/bin/mocha');
|