Skip to content
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

Add Terraform language tmgrammar snapshots #914

Merged
merged 2 commits into from
Feb 2, 2022
Merged

Add Terraform language tmgrammar snapshots #914

merged 2 commits into from
Feb 2, 2022

Conversation

jpogran
Copy link
Contributor

@jpogran jpogran commented Feb 1, 2022

This adds a snapshot file for every language construct from https://www.terraform.io/language that makes sense to test syntax grammar for. Some constructs are left out because it does not make sense to test grammar for it now.

A minimal listing of numeric and string functions are added to expressions_functions.tf, which is not the complete listing of functions. The existing grammar uses a regex with a list of function names, so this small list is enough to test at the moment. If we decide to change the regex for functions in the future, we should add more test cases to this file.

@jpogran jpogran self-assigned this Feb 1, 2022
@jpogran jpogran added the enhancement New feature or request label Feb 1, 2022
@jpogran jpogran changed the title Add Terraform language tmgrammar snapshosts Add Terraform language tmgrammar snapshots Feb 1, 2022
This adds a snapshot file for every language construct from https://www.terraform.io/language that makes sense to test syntax grammar for. Some constructs are left out because it does not make sense to test grammar for it now.

A minimal listing of numeric and string functions are added to expressions_functions.tf, which is not the complete listing of functions. The existing grammar uses a regex with a list of function names, so this small list is enough to test at the moment. If we decide to change the regex for functions in the future, we should add more test cases to this file.
@jpogran jpogran marked this pull request as ready for review February 1, 2022 16:32
@jpogran jpogran requested a review from a team February 1, 2022 16:32
@jpogran jpogran linked an issue Feb 1, 2022 that may be closed by this pull request
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you know this and it may not matter for the static grammar - that some lines represent an expression which is only valid either within a template (i.e. "${ HERE }") or on the RHS from attribute name.

tests/snapshot/terraform/expressions_operators.tf Outdated Show resolved Hide resolved
Co-authored-by: Radek Simko <radek.simko@gmail.com>
@jpogran
Copy link
Contributor Author

jpogran commented Feb 2, 2022

Correct, however we can't always check for things like that with the grammar how it is. For example, if we are inside a template or if we are in a tfvars file.

There is some refactoring we can do to separate out those aspects, but these snapshots are an attempt to get a baseline of what we have now and what it lights up.

@jpogran jpogran merged commit 57100d3 into main Feb 2, 2022
@jpogran jpogran deleted the test_snapshots branch February 2, 2022 14:16
@dbanck
Copy link
Member

dbanck commented Feb 3, 2022

Sorry for the delayed review.

I've noticed that only the first snapshot test is being executed.

CleanShot 2022-02-03 at 11 42 15

I've raised #917 to address this.

@jpogran
Copy link
Contributor Author

jpogran commented Feb 3, 2022

Apparently that's a platform specific glob problem, as it worked locally 😂

@jpogran jpogran added this to the 2.20.0 milestone Feb 18, 2022
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stabilize existing syntax highlighting grammar
3 participants