本文整理汇总了TypeScript中vsts-task-lib.osType函数的典型用法代码示例。如果您正苦于以下问题:TypeScript osType函数的具体用法?TypeScript osType怎么用?TypeScript osType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osType函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getArtifactToolLocation
export function getArtifactToolLocation(dirName: string): string {
let toolPath: string = path.join(dirName, "ArtifactTool.exe");
if (tl.osType() !== "Windows_NT"){
toolPath = path.join(dirName, "artifacttool");
}
return toolPath;
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:7,代码来源:ArtifactToolUtilities.ts
示例2: getArtifactToolFromService
export async function getArtifactToolFromService(serviceUri: string, accessToken: string, toolName: string){
let osName = tl.osType();
let arch = os.arch();
if(osName === "Windows_NT"){
osName = "windows";
}
if (arch === "x64"){
arch = "amd64";
}
const blobstoreAreaName = "clienttools";
const blobstoreAreaId = "187ec90d-dd1e-4ec6-8c57-937d979261e5";
const ApiVersion = "5.0-preview";
const blobstoreConnection = getWebApiWithProxy(serviceUri, accessToken);
try{
const artifactToolGetUrl = await blobstoreConnection.vsoClient.getVersioningData(ApiVersion,
blobstoreAreaName, blobstoreAreaId, { toolName }, {osName, arch});
const artifactToolUri = await blobstoreConnection.rest.get(artifactToolGetUrl.requestUrl);
if (artifactToolUri.statusCode !== 200){
tl.debug(tl.loc("Error_UnexpectedErrorFailedToGetToolMetadata", artifactToolUri.toString()));
throw new Error(tl.loc("Error_UnexpectedErrorFailedToGetToolMetadata", artifactToolGetUrl.requestUrl));
}
let artifactToolPath = toollib.findLocalTool(toolName, artifactToolUri.result.version);
if (!artifactToolPath) {
tl.debug(tl.loc("Info_DownloadingArtifactTool", artifactToolUri.result.uri));
const zippedToolsDir: string = await toollib.downloadTool(artifactToolUri.result.uri);
tl.debug("Downloaded zipped artifact tool to " + zippedToolsDir);
const unzippedToolsDir = await extractZip(zippedToolsDir);
artifactToolPath = await toollib.cacheDir(unzippedToolsDir, "ArtifactTool", artifactToolUri.result.version);
}
else{
tl.debug(tl.loc("Info_ResolvedToolFromCache", artifactToolPath));
}
return getArtifactToolLocation(artifactToolPath);
}
catch(err){
tl.error(err);
tl.setResult(tl.TaskResult.Failed, tl.loc("FailedToGetArtifactTool", err));
}
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:49,代码来源:ArtifactToolUtilities.ts
示例3: it
it('Runs successfully with XDT Transformation (L1)', (done:MochaDone) => {
let tp = path.join(__dirname, "..", "node_modules","webdeployment-common","Tests","L1XdtTransform.js");
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
if(tl.osType().match(/^Win/)) {
var resultFile = ltx.parse(fs.readFileSync(path.join(__dirname, "..", "node_modules","webdeployment-common","Tests", 'L1XdtTransform', 'Web_test.config')));
var expectFile = ltx.parse(fs.readFileSync(path.join(__dirname, "..", "node_modules","webdeployment-common","Tests", 'L1XdtTransform','Web_Expected.config')));
assert(ltx.equal(resultFile, expectFile) , 'Should Transform attributes on Web.config');
}
else {
tl.warning('Cannot test XDT Transformation in Non Windows Agent');
}
done();
});
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:15,代码来源:L0.ts
示例4: describe
describe('IISWebsiteDeploymentOnMachineGroup test suite', function() {
var taskSrcPath = path.join(__dirname, '..','deployiiswebapp.js');
before((done) => {
tl.cp(path.join(__dirname, "..", "node_modules", "webdeployment-common", "Tests", 'L1XmlVarSub', 'Web.config'), path.join(__dirname, "..", "node_modules", "webdeployment-common", "Tests", 'L1XmlVarSub', 'Web_test.config'), null, false);
tl.cp(path.join(__dirname, "..", "node_modules", "webdeployment-common", "Tests", 'L1XmlVarSub', 'Web.Debug.config'), path.join(__dirname, "..", "node_modules", "webdeployment-common", "Tests", 'L1XmlVarSub', 'Web_test.Debug.config'), null, false);
tl.cp(path.join(__dirname, "..", "node_modules","webdeployment-common","Tests", 'L1XdtTransform', 'Web.config'), path.join(__dirname, "..", "node_modules","webdeployment-common","Tests", 'L1XdtTransform', 'Web_test.config'), null, false);
tl.cp(path.join(__dirname, "..", "node_modules", "webdeployment-common", "Tests", 'L1XmlVarSub', 'parameters.xml'), path.join(__dirname, "..", "node_modules", "webdeployment-common", "Tests", 'L1XmlVarSub', 'parameters_test.xml'), null, false);
done();
});
after(function() {
tl.rmRF(path.join(__dirname, "..", "node_modules","webdeployment-common","Tests", 'L1XdtTransform', 'Web_test.config'), true);
tl.rmRF(path.join(__dirname, "..", "node_modules", "webdeployment-common", "Tests", 'L1XmlVarSub', 'Web_test.config'), true);
tl.rmRF(path.join(__dirname, "..", "node_modules", "webdeployment-common", "Tests", 'L1XmlVarSub', 'Web_Test.Debug.config'), true);
tl.rmRF(path.join(__dirname, "..", "node_modules", "webdeployment-common", "Tests", 'L1XmlVarSub', 'parameters_test.xml'), true);
});
if(!tl.osType().match(/^Win/)) {
return;
}
it('Runs successfully with default inputs', (done:MochaDone) => {
let tp = path.join(__dirname, 'L0WindowsDefault.js');
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
assert(tr.invokedToolCount == 1, 'should have invoked tool once');
assert(tr.stderr.length == 0 || tr.errorIssues.length, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');
done();
});
it('Runs successfully with all other inputs', (done) => {
let tp = path.join(__dirname, 'L0WindowsAllInput.js');
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
assert(tr.invokedToolCount == 1, 'should have invoked tool once');
assert(tr.stderr.length == 0 && tr.errorIssues.length == 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');
done();
});
it('Fails if msdeploy fails to execute', (done) => {
let tp = path.join(__dirname, 'L0WindowsFailDefault.js');
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
var expectedErr = 'Error: msdeploy failed with return code: 1';
assert(tr.invokedToolCount == 1, 'should have invoked tool once');
assert(tr.errorIssues.length > 0 || tr.stderr.length > 0, 'should have written to stderr');
assert(tr.stdErrContained(expectedErr) || tr.createdErrorIssue(expectedErr), 'E should have said: ' + expectedErr);
assert(tr.failed, 'task should have failed');
done();
});
it('Runs successfully with parameter file present in package', (done) => {
let tp = path.join(__dirname, 'L0WindowsParamFileinPkg.js');
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
assert(tr.invokedToolCount == 1, 'should have invoked tool once');
assert(tr.stderr.length == 0 && tr.errorIssues.length == 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');
done();
});
it('Fails if parameters file provided by user is not present', (done) => {
let tp = path.join(__dirname, 'L0WindowsFailSetParamFile.js');
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
assert(tr.invokedToolCount == 0, 'should not have invoked any tool');
assert(tr.stderr.length > 0 || tr.errorIssues.length > 0, 'should have written to stderr');
var expectedErr = 'Error: loc_mock_SetParamFilenotfound0 invalidparameterFile.xml';
assert(tr.stdErrContained(expectedErr) || tr.createdErrorIssue(expectedErr), 'should have said: ' + expectedErr);
assert(tr.failed, 'task should have succeeded');
done();
});
it('Fails if more than one package matched with specified pattern', (done) => {
let tp = path.join(__dirname, 'L0WindowsManyPackage.js');
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
assert(tr.invokedToolCount == 0, 'should not have invoked any tool');
assert(tr.stderr.length > 0 || tr.errorIssues.length > 0, 'should have written to stderr');
var expectedErr = 'Error: loc_mock_MorethanonepackagematchedwithspecifiedpatternPleaserestrainthesearchpatern';
assert(tr.stdErrContained(expectedErr) || tr.createdErrorIssue(expectedErr), 'should have said: ' + expectedErr);
assert(tr.failed, 'task should have failed');
done();
});
it('Fails if package or folder name is invalid', (done) => {
let tp = path.join(__dirname, 'L0WindowsNoPackage.js');
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
//.........这里部分代码省略.........
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:101,代码来源:L0.ts
示例5: describe
describe('Azure VMSS Deployment', function () {
this.timeout(30000);
before((done) => {
done();
});
after(function () {
});
if (tl.osType().match(/^Win/)) {
it("should succeed if vmss image updated successfully", (done) => {
let tp = path.join(__dirname, "updateImageOnWindowsAgent.js");
let tr = new ttm.MockTestRunner(tp);
process.env["existingExtensionName"] = "extensionNameTest";
tr.run();
delete process.env["existingExtensionName"];
runValidations(() => {
assert(tr.succeeded, "Should have succeeded");
assert(tr.stdout.indexOf("virtualMachineScaleSets.list is called") > -1, "virtualMachineScaleSets.list function should have been called from azure-sdk");
assert(tr.stdout.indexOf("Creating archive C:\\users\\temp\\vstsvmss12345\\cs.zip of compression type zip from C:\\some\\dir") > -1, "archive should be correctly created");
assert(tr.stdout.indexOf("Invoker command: powershell ./100-12345/200/5/customScriptInvoker.ps1 -zipName 'cs.zip' -script '.\\\\\"\"\"de`$p``l o''y.ps1\"\"\"' -scriptArgs '\"\"\"first ''arg''\"\"\" seco``nd`$arg' -prefixPath '100-12345/200/5'") > -1, "invoker command should be correct");
assert(tr.stdout.indexOf("storageAccounts.listKeys is called") > -1, "storage accounts should be listed");
assert(tr.stdout.indexOf("blobService.uploadBlobs is called with source C:\\users\\temp\\vstsvmss12345 and dest vststasks") > -1, "scripts should be uploaded to correct account and container");
assert(tr.stdout.indexOf("loc_mock_DestinationBlobContainer teststorage1.blob.core.windows.net/vststasks") > -1, "scripts should be uploaded to correct account and container");
assert(tr.stdout.indexOf("virtualMachineExtensions.list is called") > -1, "virtualMachineExtensions.list function should have been called from azure-sdk");
assert(tr.stdout.indexOf("virtualMachineExtensions.createOrUpdate is called with resource testvmss1 and extension extensionNameTest") > -1, "virtualMachineExtensions.createOrUpdate function should have been called from azure-sdk");
assert(tr.stdout.indexOf("custom script: teststorage1.blob.core.windows.net/vststasks/100-12345/200/5/folder1/file1") > -1, "vm extension should use correct file1");
assert(tr.stdout.indexOf("custom script: teststorage1.blob.core.windows.net/vststasks/100-12345/200/5/folder1/folder2/file2") > -1, "vm extension should use correct file2");
assert(tr.stdout.indexOf("virtualMachinesScaleSets.updateImage is called with RG: testrg1, VMSS: testvmss1 and imageurl : https://someurl") > -1, "virtualMachinesScaleSets.updateImage function should have been called from azure-sdk");
assert(tr.stdout.indexOf("loc_mock_CustomScriptExtensionInstalled") > -1, "new extension should be installed");
assert(tr.stdout.indexOf("loc_mock_UpdatedVMSSImage") > -1, "VMSS image should be updated");
}, tr, done);
});
it("should succeed if linux vmss image updated successfully", (done) => {
process.env["_vmssOsType_"] = "Linux";
let tp = path.join(__dirname, "updateImageOnWindowsAgent.js");
let tr = new ttm.MockTestRunner(tp);
tr.run();
delete process.env["_vmssOsType_"];
runValidations(() => {
assert(tr.succeeded, "Should have succeeded");
assert(tr.stdout.indexOf("virtualMachineScaleSets.list is called") > -1, "virtualMachineScaleSets.list function should have been called from azure-sdk");
assert(tr.stdout.indexOf("Creating archive C:\\users\\temp\\vstsvmss12345\\cs.tar.gz of compression type targz from C:\\some\\dir") > -1, "archive should be correctly created");
assert(tr.stdout.indexOf("Invoker command: ./customScriptInvoker.sh 'cs.tar.gz' './\"set V'\"'\"'a\\\`r\\\$.sh\"' '\"first '\"'\"'arg'\"'\"'\" seco\\`nd\\$arg'") > -1, "invoker command should be correct");
assert(tr.stdout.indexOf("blobService.uploadBlobs is called with source C:\\users\\temp\\vstsvmss12345 and dest vststasks") > -1, "scripts should be uploaded to correct account and container");
assert(tr.stdout.indexOf("loc_mock_DestinationBlobContainer teststorage1.blob.core.windows.net/vststasks") > -1, "scripts should be uploaded to correct account and container");
assert(tr.stdout.indexOf("virtualMachineExtensions.list is called") > -1, "virtualMachineExtensions.list function should have been called from azure-sdk");
assert(tr.stdout.indexOf("virtualMachineExtensions.deleteMethod is called") == -1, "virtualMachineExtensions.deleteMethod function should not be called as no custom-script-linux extension is present");
assert(tr.stdout.indexOf("virtualMachineExtensions.createOrUpdate is called with resource testvmss2 and extension AzureVmssDeploymentTask") > -1, "virtualMachineExtensions.createOrUpdate function should have been called from azure-sdk");
assert(tr.stdout.indexOf("custom script: teststorage1.blob.core.windows.net/vststasks/100-12345/200/5/folder1/file1") > -1, "vm extension should use correct file1");
assert(tr.stdout.indexOf("custom script: teststorage1.blob.core.windows.net/vststasks/100-12345/200/5/folder1/folder2/file2") > -1, "vm extension should use correct file2");
assert(tr.stdout.indexOf("virtualMachinesScaleSets.updateImage is called with RG: testrg2, VMSS: testvmss2 and imageurl : https://someurl") > -1, "virtualMachinesScaleSets.updateImage function should have been called from azure-sdk");
assert(tr.stdout.indexOf("loc_mock_CustomScriptExtensionInstalled") > -1, "new extension should be installed");
assert(tr.stdout.indexOf("loc_mock_UpdatedVMSSImage") > -1, "VMSS image should be updated");
}, tr, done);
});
it("should fail if failed to update VMSS image", (done) => {
process.env["imageUpdateFailed"] = "true";
let tp = path.join(__dirname, "updateImageOnWindowsAgent.js");
let tr = new ttm.MockTestRunner(tp);
tr.run();
process.env["imageUpdateFailed"] = undefined;
runValidations(() => {
assert(tr.failed, "Should have failed");
assert(tr.stdout.indexOf("virtualMachineScaleSets.list is called") > -1, "virtualMachineScaleSets.list function should have been called from azure-sdk");
assert(tr.stdout.indexOf("virtualMachinesScaleSets.updateImage is called") > -1, "virtualMachinesScaleSets.updateImage function should have been called from azure-sdk");
assert(tr.stdout.indexOf("loc_mock_VMSSImageUpdateFailed") > -1, "VMSS image update should fail");
}, tr, done);
});
it("should fail if failed to list VMSSs", (done) => {
process.env["vmssListFailed"] = "true";
let tp = path.join(__dirname, "updateImageOnWindowsAgent.js");
let tr = new ttm.MockTestRunner(tp);
tr.run();
process.env["vmssListFailed"] = undefined;
runValidations(() => {
assert(tr.failed, "Should have failed");
assert(tr.stdout.indexOf("virtualMachineScaleSets.list is called") > -1, "virtualMachineScaleSets.list function should have been called from azure-sdk");
assert(tr.stdout.indexOf("virtualMachinesScaleSets.updateImage is called") == -1, "virtualMachinesScaleSets.updateImage function should not be called from azure-sdk");
assert(tr.stdout.indexOf("loc_mock_VMSSListFetchFailed") > -1, "VMSS list should be failed");
}, tr, done);
});
it("should fail if failed to get matching VMSS", (done) => {
process.env["noMatchingVmss"] = "true";
let tp = path.join(__dirname, "updateImageOnWindowsAgent.js");
let tr = new ttm.MockTestRunner(tp);
tr.run();
process.env["noMatchingVmss"] = undefined;
runValidations(() => {
assert(tr.failed, "Should have failed");
assert(tr.stdout.indexOf("virtualMachineScaleSets.list is called") > -1, "virtualMachineScaleSets.list function should have been called from azure-sdk");
assert(tr.stdout.indexOf("virtualMachinesScaleSets.updateImage is called") == -1, "virtualMachinesScaleSets.updateImage function should not be called from azure-sdk");
assert(tr.stdout.indexOf("loc_mock_FailedToGetRGForVMSS") > -1, "VMSS list should be failed");
//.........这里部分代码省略.........
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:101,代码来源:L0.ts
示例6: describe
describe('VsTestPlatformToolInstaller Suite', function() {
this.timeout(10000);
if (!tl.osType().match(/^Win/)) {
return;
}
before((done) => {
done();
});
beforeEach((done) => {
// Clear all inputs and other environment variables
delete process.env[constants.vsTestToolsInstallerInstalledToolLocation];
delete process.env[constants.versionSelector];
delete process.env[constants.testPlatformVersion];
delete process.env[constants.downloadPath];
delete process.env[testConstants.expectedTestPlatformVersion];
delete process.env[testConstants.findLocalToolFirstCallReturnValue];
delete process.env[testConstants.findLocalToolSecondCallReturnValue];
delete process.env[testConstants.listPackagesReturnCode];
delete process.env[testConstants.listPackagesOutput];
delete process.env[constants.username];
delete process.env[constants.password];
delete process.env[testConstants.feedId];
delete process.env[constants.packageFeedSelector];
delete process.env[constants.customFeed];
delete process.env[testConstants.packageSource];
delete process.env[testConstants.configFile];
process.env[constants.packageFeedSelector] = constants.nugetOrg;
process.env[testConstants.packageSource] = constants.defaultPackageSource;
process.env[testConstants.writeNugetConfigReturnCode] = '0';
process.env[constants.agentTempDirectory] = 'temp';
process.env[constants.downloadPath] = `${process.env[constants.agentTempDirectory]}\\VsTest`;
done();
});
after(function () {
// add code for cleanup if any
});
// *************************************************** Nuget Org Tests ******************************************************
it('Get latest pre-release version cache hit', (done: MochaDone) => {
// Setup the mock runner
const tp = path.join(__dirname, 'TestSetup.js');
const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
// Set the inputs
process.env[constants.versionSelector] = 'latestPreRelease';
process.env[constants.testPlatformVersion] = '';
process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';
process.env[testConstants.findLocalToolFirstCallReturnValue] = `VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}`;
process.env[testConstants.listPackagesReturnCode] = '0';
// Start the run
tr.run();
// Asserts
assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');
assert(tr.succeeded, `Task should have succeeded`);
assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);
assert(tr.stdOutContained(`Found the latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}`);
assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);
assert(tr.stdOutContained(`Cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Expected a cache hit.`);
assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);
assert(tr.stdOutContained('InstallationSuccessful'));
done();
});
it('Get latest pre-release version cache miss and download success', (done: MochaDone) => {
// Setup the mock runner
const tp = path.join(__dirname, 'TestSetup.js');
const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
// Set the inputs
process.env[constants.versionSelector] = 'latestPreRelease';
process.env[constants.testPlatformVersion] = '';
process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';
process.env[testConstants.listPackagesReturnCode] = '0';
process.env[testConstants.downloadPackageReturnCode] = '0';
// Start the run
tr.run();
// Asserts
assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');
assert(tr.succeeded, `Task should have succeeded`);
assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);
assert(tr.stdOutContained(`Found the latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}`);
assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);
assert(tr.stdOutContained(`Could not find Microsoft.TestPlatform.${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache. Fetching it from nuget.`), `Should have encountered a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}.`);
assert(tr.stdOutContained(`Downloading Test Platform version ${process.env[testConstants.expectedTestPlatformVersion]} from ${process.env[testConstants.packageSource]} to ${process.env[constants.downloadPath]}.`), `Should have attempted download of version ${process.env[testConstants.expectedTestPlatformVersion]}`);
assert(tr.stdOutContained(`Caching the downloaded folder temp\\VsTest\\${constants.packageId}.${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have cached ${process.env[testConstants.expectedTestPlatformVersion]}`);
assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);
//.........这里部分代码省略.........
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:101,代码来源:L0.ts
示例7: describe
describe('DotNetCoreInstaller', function() {
this.timeout(30000);
before((done) => {
done();
});
after(function() {
});
if(tl.osType().match(/^Win/)) {
it("[windows]should succeed if sdk installed successfully", (done) => {
let tp = path.join(__dirname, "InstallWindows.js");
let tr = new ttm.MockTestRunner(tp);
tr.run();
runValidations(() => {
assert(tr.succeeded, "Should have succeeded");
assert(tr.stdout.indexOf("loc_mock_ToolToInstall sdk 1.0.4") > -1, "should print to-be-installed info");
assert(tr.stdout.indexOf("Checking local tool for dncs and version 1.0.4") > -1, "should check for local cached tool");
assert(tr.stdout.indexOf("loc_mock_InstallingAfresh") > -1, "should install fresh if cache miss");
assert(tr.stdout.indexOf("Downloading tool from https://primary-url") > -1, "should download from correct url");
assert(tr.stdout.indexOf("Extracting zip archieve from C:\\agent\\_temp\\someArchieve") > -1, "Should extract downloaded archieve corectly");
assert(tr.stdout.indexOf("Caching dir C:\\agent\\_temp\\someDir for tool dncs version 1.0.4") > -1, "should cache correctly");
assert(tr.stdout.indexOf("loc_mock_SuccessfullyInstalled sdk 1.0.4") > -1, "should print installed tool info");
assert(tr.stdout.indexOf("prepending path: C:\\agent\\_tools\\cacheDir") > -1, "should pre-prend to PATH");
}, tr, done);
});
it("[windows]should succeed if runtime installed successfully", (done) => {
process.env["__package_type__"] = "runtime";
let tp = path.join(__dirname, "InstallWindows.js");
let tr = new ttm.MockTestRunner(tp);
tr.run();
delete process.env["__package_type__"];
runValidations(() => {
assert(tr.succeeded, "Should have succeeded");
assert(tr.stdout.indexOf("loc_mock_ToolToInstall runtime 1.0.4") > -1, "should print to-be-installed info");
assert(tr.stdout.indexOf("Checking local tool for dncr and version 1.0.4") > -1, "should check for local cached tool");
assert(tr.stdout.indexOf("loc_mock_InstallingAfresh") > -1, "should install fresh if cache miss");
assert(tr.stdout.indexOf("Downloading tool from https://primary-runtime-url") > -1, "should download from correct url");
assert(tr.stdout.indexOf("Extracting zip archieve from C:\\agent\\_temp\\someArchieve") > -1, "Should extract downloaded archieve corectly");
assert(tr.stdout.indexOf("Caching dir C:\\agent\\_temp\\someDir for tool dncr version 1.0.4") > -1, "should cache correctly");
assert(tr.stdout.indexOf("loc_mock_SuccessfullyInstalled runtime 1.0.4") > -1, "should print installed tool info");
assert(tr.stdout.indexOf("prepending path: C:\\agent\\_tools\\cacheDir") > -1, "should pre-prend to PATH");
}, tr, done);
});
it("[windows]should not install again if cache hit", (done) => {
process.env["__cache_hit__"] = "true";
let tp = path.join(__dirname, "InstallWindows.js");
let tr = new ttm.MockTestRunner(tp);
tr.run();
delete process.env["__cache_hit__"];
runValidations(() => {
assert(tr.succeeded, "Should have succeeded");
assert(tr.stdout.indexOf("loc_mock_ToolToInstall sdk 1.0.4") > -1, "should print to-be-installed info");
assert(tr.stdout.indexOf("Checking local tool for dncs and version 1.0.4") > -1, "should check for local cached tool");
assert(tr.stdout.indexOf("loc_mock_InstallingAfresh") == -1, "should not install fresh");
assert(tr.stdout.indexOf("loc_mock_GettingDownloadUrls") == -1, "should not download");
assert(tr.stdout.indexOf("loc_mock_UsingCachedTool") > -1, "should print that cached dir is being used");
assert(tr.stdout.indexOf("Caching dir C:\\agent\\_temp\\someDir for tool dncs version 1.0.4") == -1, "should not update cache again");
assert(tr.stdout.indexOf("prepending path: C:\\agent\\_tools\\oldCacheDir") > -1, "should pre-prend to PATH");
}, tr, done);
});
it("[windows]should download using legacy url if primary url does not work", (done) => {
process.env["__primary_url_failed__"] = "true";
let tp = path.join(__dirname, "InstallWindows.js");
let tr = new ttm.MockTestRunner(tp);
tr.run();
delete process.env["__primary_url_failed__"];
runValidations(() => {
assert(tr.succeeded, "Should have succeeded");
assert(tr.stdout.indexOf("loc_mock_PrimaryUrlDownloadFailed 404 not found https://primary-url") >= -1, "should print primary url failure error")
assert(tr.stdout.indexOf("Downloading tool from https://legacy-url") > -1, "should download from legacy url");
}, tr, done);
});
it("[windows]should fail if explicit version is not used", (done) => {
process.env["__implicit_version__"] = "true";
let tp = path.join(__dirname, "InstallWindows.js");
let tr = new ttm.MockTestRunner(tp);
tr.run();
delete process.env["__implicit_version__"];
runValidations(() => {
assert(tr.failed, "Should have failed");
assert(tr.stdout.indexOf("loc_mock_ImplicitVersionNotSupported") > -1, "should print error message");
}, tr, done);
});
it("[windows]should fail if getting download script fails", (done) => {
process.env["__get_dlurls_failed__"] = "true";
let tp = path.join(__dirname, "InstallWindows.js");
let tr = new ttm.MockTestRunner(tp);
tr.run();
delete process.env["__get_dlurls_failed__"];
//.........这里部分代码省略.........
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:101,代码来源:L0.ts
示例8: describe
describe('VsTestPlatformToolInstaller Suite', function() {
this.timeout(10000);
if (!tl.osType().match(/^Win/)) {
return;
}
before((done) => {
done();
});
beforeEach((done) => {
// Clear all inputs and other environment variables
delete process.env[constants.vsTestToolsInstallerInstalledToolLocation];
delete process.env[constants.versionSelector];
delete process.env[constants.testPlatformVersion];
delete process.env[constants.downloadPath];
delete process.env[constants.expectedTestPlatformVersion];
delete process.env[constants.findLocalToolFirstCallReturnValue];
delete process.env[constants.findLocalToolSecondCallReturnValue];
delete process.env[constants.listPackagesReturnCode];
delete process.env[constants.listPackagesOutput];
done();
});
after(function () {
//console.log('after');
});
it('Get latest pre-release version cache hit', (done: MochaDone) => {
console.log('TestCaseName: Get latest pre-release version cache hit');
// Setup the mock runner
const tp = path.join(__dirname, 'TestSetup.js');
const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
// Set the inputs
process.env[constants.agentTempDirectory] = 'temp';
process.env[constants.versionSelector] = 'latestPreRelease';
process.env[constants.testPlatformVersion] = '';
process.env[constants.downloadPath] = 'temp\\VsTest';
process.env[constants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';
process.env[constants.findLocalToolFirstCallReturnValue] = `VsTest\\${process.env[constants.expectedTestPlatformVersion]}`;
process.env[constants.listPackagesReturnCode] = 0;
// Start the run
tr.run();
// Asserts
assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');
assert(tr.succeeded, `Task should have succeeded`);
assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);
assert(tr.stdOutContained(`Found the latest version to be ${process.env[constants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[constants.expectedTestPlatformVersion]}`);
assert(tr.stdOutContained(`Looking for version ${process.env[constants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[constants.expectedTestPlatformVersion]} in the cache.`);
assert(tr.stdOutContained(`Cache hit for ${process.env[constants.expectedTestPlatformVersion]}`), `Expected a cache hit.`);
assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[constants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[constants.expectedTestPlatformVersion]}.`);
assert(tr.stdOutContained('InstallationSuccessful'));
done();
});
it('Get latest pre-release version cache miss and download success', (done: MochaDone) => {
console.log('TestCaseName: Get latest pre-release version cache miss and download success');
// Setup the mock runner
const tp = path.join(__dirname, 'TestSetup.js');
const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
// Set the inputs
process.env[constants.agentTempDirectory] = 'temp';
process.env[constants.versionSelector] = 'latestPreRelease';
process.env[constants.testPlatformVersion] = '';
process.env[constants.downloadPath] = 'temp\\VsTest';
process.env[constants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';
process.env[constants.listPackagesReturnCode] = 0;
process.env[constants.downloadPackageReturnCode] = 0;
// Start the run
tr.run();
// Asserts
assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');
assert(tr.succeeded, `Task should have succeeded`);
assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);
assert(tr.stdOutContained(`Found the latest version to be ${process.env[constants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[constants.expectedTestPlatformVersion]}`);
assert(tr.stdOutContained(`Looking for version ${process.env[constants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[constants.expectedTestPlatformVersion]} in the cache.`);
assert(tr.stdOutContained(`Could not find Microsoft.TestPlatform.${process.env[constants.expectedTestPlatformVersion]} in the tools cache. Fetching it from nuget.`), `Should have encountered a cache miss for ${process.env[constants.expectedTestPlatformVersion]}.`);
assert(tr.stdOutContained(`Downloading Test Platform version ${process.env[constants.expectedTestPlatformVersion]} from ${constants.packageSource} to ${process.env[constants.downloadPath]}.`), `Should have attempted download of version ${process.env[constants.expectedTestPlatformVersion]}`);
assert(tr.stdOutContained(`Caching the downloaded folder temp\\VsTest\\${constants.packageName}.${process.env[constants.expectedTestPlatformVersion]}.`), `Should have cached ${process.env[constants.expectedTestPlatformVersion]}`);
assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[constants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[constants.expectedTestPlatformVersion]}.`);
assert(tr.stdOutContained('InstallationSuccessful'));
done();
});
it('Get latest pre-release version listing failed but a stable version found in cache', (done: MochaDone) => {
console.log('TestCaseName: Get latest pre-release version listing failed but a stable version found in cache');
// Setup the mock runner
//.........这里部分代码省略.........
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:101,代码来源:L0.ts
注:本文中的vsts-task-lib.osType函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论