-
Notifications
You must be signed in to change notification settings - Fork 730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cqthyy/params integration unit tests #7352
cqthyy/params integration unit tests #7352
Conversation
[TestClass] | ||
public class ParamsParserTests | ||
{ | ||
private class SyntaxCollectorVisitor : SyntaxVisitor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same as the syntax collector visitor in PaserTests. It might be worth extracting it to a new file and make it public helper class.
var syntaxList = SyntaxCollectorVisitor.Build(program); | ||
var syntaxByParent = syntaxList.ToLookup(x => x.Parent); | ||
|
||
string getLoggingString(SyntaxCollectorVisitor.SyntaxItem data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also make it a public helper method of SyntaxCollectorVisitor
which both ParserTests
and ParamsParserTests
can reuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, would be good to extract common logic here
'h' | ||
] | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the we allow non-literal values at syntax level, we can add some test cases to ensure they can also be parsed, for example:
param myFunction = union({}, {})
param myComplexArrWithFunction = [
{
foo: resourceGroup()
}
true
[
42
]
]
They can also be useful for validating semantic diagnostics later, since we are going to implement semantic checking to block non-literal values.
if (dataSet.BicepParam is null) | ||
{ | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than skipping over tests you want to ignore with a return (which will result in these tests being reported as "success"), it would be better to change the GetData
method below to something like GetParamsData
and do the filtering there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to comment this. GetData
already does the filtering, but it makes sense to change the name to GetParamsData
. Also, I think it's better to throw new InvalidOperationException($"Expected {dataSet.BicepParam} to be non-null");
here in case DataSets.ParamDataSets
returns null BicepParam
.
….com/Azure/bicep into cqthyy/params-integration-unit-tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,68 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Git by default will convert line endings depending on whether you're checking out code on Windows (\r\n
) or Unix/Linux (\n
). This causes problems for the baseline tests - to fix this, you may need to copy the config we added for .bicep
to your new extension - to respect the newline format of the file and avoid converting on different platforms:
Lines 1 to 2 in 6d0eeaf
*.bicep -text | |
*.ts text eol=lf |
Bicep parameter file parser integration tests & baseline generation implemented, syntax visitor methods implemented
Microsoft Reviewers: Open in CodeFlow