Skip to content

Commit ca2647a

Browse files
authored
[mustache_template] Fix auto-generated specification tests, run with dart test (#11056)
This PR reorganizes the tests in mustache_template such that CI can run them, per the second option proposed in flutter/flutter#174721. The changes include a script to pull mustache specifications from the mustache repository and note the time/date and commit hash of that action, along with documentation of the above and the new test structure laid out below. The former `all.dart` (which called three `main` functions in three test files) is now `mustache_test.dart`, and the former `mustache_test.dart` (which contained handwritten tests) is now `feature_test.dart`. The `mustache_specs.dart` file is now solely responsible for generating the tests in `mustache_test.dart` from the mustache specs, and no longer has a `main` of its own. As this implementation doesn't support two of the optional mustache specs (inheritance and dynamic names, which were added to the mustache repo in the early 2020s, while the original mustache_template package was written in the mid-2010s), this PR also adds an UNSUPPORTED_SPECS constant in `mustache_test.dart` that skips generation of tests from those spec files. (Separately, I'm working on an implementation of the inheritance spec, so it seemed better to pull all the specification files and selectively disable the unsupported ones.) ## Pre-Review Checklist ### Exemptions - Version change exemption: PR affects tests only. - CHANGELOG exemption: PR affects tests only. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent a2d6d61 commit ca2647a

19 files changed

Lines changed: 3497 additions & 988 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/spec
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Test Structure
2+
3+
## Specifications
4+
5+
`mustache_test.dart` and `mustache_specs.dart` generate tests for all mustache specifications,
6+
except for those disabled by `mustache_test.dart`'s `unsupportedSpecs` constant.
7+
`dart test mustache_test.dart` runs all of the generated tests.
8+
9+
Each generated specification file contains the mustache commit hash from which it was generated,
10+
and the date when it was generated.
11+
12+
### Updating specifications
13+
14+
From the package root, run `dart run tool/download_spec.dart` to pull new definitions from the
15+
mustache repository into `test/specs/`.
16+
17+
## Features
18+
19+
Standalone or handwritten tests regarding template output go in `feature_test.dart`.
20+
21+
## Parser
22+
23+
Tests for the template language parser go in `parser_test.dart`.

third_party/packages/mustache_template/test/all.dart

Lines changed: 0 additions & 9 deletions
This file was deleted.

third_party/packages/mustache_template/test/download-spec.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)