Skip to content

Commit

Permalink
Update to next alpha (#1259)
Browse files Browse the repository at this point in the history
* Update to next alpha

* Fix Random modifications occasional failures

* fix # iters

Co-authored-by: Stephen Weatherford <[email protected]>
  • Loading branch information
StephenWeatherford and Stephen Weatherford authored Mar 12, 2021
1 parent 598f86c commit 55b627f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "azurerm-vscode-tools",
"displayName": "Azure Resource Manager (ARM) Tools",
"description": "Language server, editing tools and snippets for Azure Resource Manager (ARM) template files.",
"version": "0.15.0",
"version": "0.15.1-alpha",
"publisher": "msazurermtools",
"config": {
"ARM_LANGUAGE_SERVER_NUGET_VERSION": "3.0.0-preview.21158.1"
Expand Down
20 changes: 18 additions & 2 deletions test/DeploymentTemplate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as assert from "assert";
import { randomBytes } from "crypto";
import { ISuiteCallbackContext, ITestCallbackContext } from "mocha";
import { Uri } from "vscode";
import { parseError } from "vscode-azureextensionui";
import { DefinitionKind, DeploymentTemplateDoc, getVSCodeRangeFromSpan, Histogram, INamedDefinition, IncorrectArgumentsCountIssue, IParameterDefinition, Issue, IssueKind, IVariableDefinition, Json, LineColPos, ReferenceInVariableDefinitionsVisitor, ReferenceList, Span, TemplateScope, UnrecognizedUserFunctionIssue, UnrecognizedUserNamespaceIssue } from "../extension.bundle";
import { diagnosticSources, IDeploymentTemplate, testDiagnostics } from "./support/diagnostics";
import { parseTemplate } from "./support/parseTemplate";
Expand Down Expand Up @@ -1247,7 +1248,8 @@ ${err}`);
// Just make sure nothing throws
let modifiedTemplate: string = template;

for (let i = 0; i < 1000; ++i) {
for (let i = 0; i < 5000; ++i) {
const previousTemplate = modifiedTemplate;
if (modifiedTemplate.length > 0 && Math.random() < 0.5) {
// Delete some characters
let position = Math.random() * (modifiedTemplate.length - 1);
Expand All @@ -1261,7 +1263,21 @@ ${err}`);
modifiedTemplate = modifiedTemplate.slice(0, position) + s + modifiedTemplate.slice(position);
}

let dt = await parseTemplate(modifiedTemplate);
let dt: DeploymentTemplateDoc;
try {
dt = await parseTemplate(modifiedTemplate);
} catch (err) {
if (parseError(err).message.includes('Malformed marker')) {
// We messed up the markers in the template (testcase issue). Revert this modification and try again
// next loop
modifiedTemplate = previousTemplate;
dt = await parseTemplate(modifiedTemplate);
} else {
// Valid failure
throw err;
}
}

findReferences(dt, DefinitionKind.Parameter, "adminUsername", dt.topLevelScope);
findReferences(dt, DefinitionKind.Variable, "resourceGroup", dt.topLevelScope);
dt.getFunctionCounts();
Expand Down

0 comments on commit 55b627f

Please sign in to comment.