Skip to content

Commit

Permalink
Simplify output of colorization tests (#260)
Browse files Browse the repository at this point in the history
* Fix #250, strings vs expressions boundary cases

* Simplify output of colorization tests

* lint?
  • Loading branch information
StephenWeatherford authored Jul 18, 2019
1 parent 919274d commit b5286bd
Show file tree
Hide file tree
Showing 59 changed files with 1,466 additions and 1,206 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,5 @@ dist
test-results.xml

# Colorization test failure diffs
test/*.actual
test/**/*.actual
test/**/*.full-scope-result.txt
184 changes: 184 additions & 0 deletions test/colorization/inputs/deep-nested.FULL-SCOPE.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"networkInterfaceName": {
"type": "string"
},
"networkSecurityGroupName": {
"type": "string"
},
"networkSecurityGroupRules": {
"type": "array"
},
"subnetName": {
"type": "string"
},
"virtualNetworkName": {
"type": "string"
},
"addressPrefixes": {
"type": "array"
},
"subnets": {
"type": "array"
},
"publicIpAddressName": {
"type": "string"
},
"publicIpAddressType": {
"type": "string"
},
"publicIpAddressSku": {
"type": "string"
},
"virtualMachineName": {
"type": "string"
},
"osDiskType": {
"type": "string"
},
"virtualMachineSize": {
"type": "string"
},
"adminUsername": {
"type": "string"
},
"adminPassword": {
"type": "secureString"
},
"diagnosticsStorageAccountName": {
"type": "string"
}
},
"variables": {
"$TEST": "['test1']",
"vnetId": "[resourceId(resourceGroup().name,'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]"
},
"resources": [
{
"name": "[parameters('networkInterfaceName')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2018-10-01",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
"[concat('Microsoft.Network/publicIpAddresses/', parameters('publicIpAddressName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"privateIPAllocationMethod": "Dynamic",
"publicIpAddress": {
"id": "[resourceId(resourceGroup().name, 'Microsoft.Network/publicIpAddresses', parameters('publicIpAddressName'))]"
}
}
}
],
"networkSecurityGroup": {
"id": "[variables('nsgId')]"
}
},
"tags": {}
},
{
"name": "[parameters('networkSecurityGroupName')]",
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2018-08-01",
"location": "[parameters('location')]",
"properties": {
"securityRules": "[parameters('networkSecurityGroupRules')]"
},
"tags": {}
},
{
"name": "[parameters('virtualNetworkName')]",
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-08-01",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": "[parameters('addressPrefixes')]"
},
"subnets": "[parameters('subnets')]"
},
"tags": {}
},
{
"name": "[parameters('publicIpAddressName')]",
"type": "Microsoft.Network/publicIpAddresses",
"apiVersion": "2018-08-01",
"location": "[parameters('location')]",
"properties": {
"publicIpAllocationMethod": "[parameters('publicIpAddressType')]"
},
"sku": {
"name": "[parameters('publicIpAddressSku')]"
},
"tags": {}
},
{
"name": "[parameters('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2018-06-01",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"storageProfile": {
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "[parameters('osDiskType')]"
}
},
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18.04-LTS",
"version": "latest"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
}
]
},
"osProfile": {
"computerName": "[parameters('virtualMachineName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"$TEST": "['test2']"
}
}
},
"tags": {}
}
],
"outputs": {
"adminUsername": {
"type": "string",
"value": "[parameters('adminUsername')]"
}
}
}
9 changes: 9 additions & 0 deletions test/colorization/inputs/variables.FULL-SCOPE.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",

// With string literal - all same color (except parens)
"$TEST1": "[variables('myvar')]",

// With expression - normal expression colors inside 'variables'
"$TEST2": "[variables(concat('myvar', 'a'))]"
}
30 changes: 15 additions & 15 deletions test/colorization/results/array-access.INVALID.json.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
TEST STRING: "[a()]]"
"[ source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm {{scope-expression-start}}
a source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm {{scope-unknownfunction}}
() source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm meta.function-call.tle.arm {{scope-parentheses-funccall}}
] source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm invalid.illegal.expected-expression.tle.arm
]" source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm {{scope-expression-end}}
"[ {{scope-expression-start}}
a {{scope-unknownfunction}}
() {{scope-parentheses-funccall}}
] invalid.illegal.expected-expression.tle.arm
]" {{scope-expression-end}}

TEST STRING: "[a()[]]"
"[ source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm {{scope-expression-start}}
a source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm {{scope-unknownfunction}}
() source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm meta.function-call.tle.arm {{scope-parentheses-funccall}}
[] source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm invalid.illegal.empty-array-access.tle.arm
]" source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm {{scope-expression-end}}
"[ {{scope-expression-start}}
a {{scope-unknownfunction}}
() {{scope-parentheses-funccall}}
[] invalid.illegal.empty-array-access.tle.arm
]" {{scope-expression-end}}

TEST STRING: "[a()[ ]]"
"[ source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm {{scope-expression-start}}
a source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm {{scope-unknownfunction}}
() source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm meta.function-call.tle.arm {{scope-parentheses-funccall}}
[ ] source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm invalid.illegal.empty-array-access.tle.arm
]" source.json meta.structure.dictionary.json meta.arm-deployment-template.json.comments meta.structure.dictionary.value.json.comments meta.expression.tle.arm {{scope-expression-end}}
"[ {{scope-expression-start}}
a {{scope-unknownfunction}}
() {{scope-parentheses-funccall}}
[ ] invalid.illegal.empty-array-access.tle.arm
]" {{scope-expression-end}}
Loading

0 comments on commit b5286bd

Please sign in to comment.