diff --git a/error-prone-contrib/pom.xml b/error-prone-contrib/pom.xml index a19e292d337..06554471060 100644 --- a/error-prone-contrib/pom.xml +++ b/error-prone-contrib/pom.xml @@ -216,15 +216,6 @@ - - com.coveo - fmt-maven-plugin - - - ${basedir}/src/test/resources - - - org.apache.maven.plugins maven-compiler-plugin diff --git a/pom.xml b/pom.xml index f80ffe6ffcb..e43e58b4399 100644 --- a/pom.xml +++ b/pom.xml @@ -455,6 +455,9 @@ fmt-maven-plugin 2.18 + + ${basedir}/src/test/resources + never diff --git a/refaster-runner/pom.xml b/refaster-runner/pom.xml index a273ca9938d..b66abe2da13 100644 --- a/refaster-runner/pom.xml +++ b/refaster-runner/pom.xml @@ -11,7 +11,7 @@ refaster-runner Picnic :: Error Prone Support :: Refaster Runner - Apply Refaster templates found on the classpath. + Applies Refaster templates found on the classpath. diff --git a/refaster-test-support/README.md b/refaster-test-support/README.md index 1ac884f4114..ca05112966d 100644 --- a/refaster-test-support/README.md +++ b/refaster-test-support/README.md @@ -4,58 +4,77 @@ This package provides utilities to validate Refaster template collections. ## What does this module do? -These utilities allow for validating the rewrites performed by Refaster templates, or absence thereof. Each collection -of Refaster templates is applied to an input file and the result of that should match the provided output file. +These utilities allow for validating the rewrites performed by Refaster +templates, or absence thereof. Each collection of Refaster templates is applied +to an input file and the result of that should match the provided output file. -This extension ensures that each Refaster template has a test and has a match at the expected place. If a test is -missing, an error is reported in the test's console. This way, the developer has some guidance on how to write tests and +This extension ensures that each Refaster template has a test and has a match at +the expected place. If a test is missing, an error is reported in the test's +console. This way, the developer has some guidance on how to write tests and assurance that every template is tested. ## How to test a collection of Refaster templates? -In summary, to test Refaster templates using the `RefasterCollectionTestUtil`, one should create an input and output -file. The Refaster templates from the collection are applied on the input file and should exactly match the content of +In summary, to test Refaster templates using the `RefasterCollectionTestUtil`, +one should create an input and output file. The Refaster templates from the +collection are applied on the input file and should exactly match the content of the provided output file. -To test Refaster templates, one can create a (parameterized) test for every class containing the Refaster templates to -invoke the `RefasterCollectionTestUtil`. A class that contains one or more Refaster templates is called a Refaster -template collection. This test utility applies the Refaster templates in the collection to a provided input file, and -expects the result to exactly match the contents of a provided output file. +To test Refaster templates, one can create a (parameterized) test for every +class containing the Refaster templates to invoke the +`RefasterCollectionTestUtil`. A class that contains one or more Refaster +templates is called a Refaster template collection. This test utility applies +the Refaster templates in the collection to a provided input file, and expects +the result to exactly match the contents of a provided output file. To adopt this setup, the following requirements have to be met: - Create a class with a (parameterized) test method that calls - the `RefasterCollectionTestUtil#validateTemplateCollection` and passes the collection(s) to validate. The Refaster - template collection must match the naming convention `Templates.java`. -- An input file matching the naming convention `TemplatesTestInput.java` is added for every + the `RefasterCollectionTestUtil#validateTemplateCollection` and passes the + collection(s) to validate. The Refaster template collection must match the + naming convention `Templates.java`. +- An input file matching the naming convention + `TemplatesTestInput.java` is added for every template + collection. +- An output file matching the naming convention + `TemplatesTestOutput.java` file is added for every template collection. -- An output file matching the naming convention `TemplatesTestOutput.java` - file is added for every template collection. -- For each Refaster template in the collection, the input and output file must contain a method. The name of the method - is equal to the name of the Refaster template prefixed with `test` (e.g. `test`). -- The method contains at least one expression that matches the `@BeforeTemplate` of one specific Refaster template. As - a result, the output file contains the same method with an updated expression, matching the content of - the `@AfterTemplate`. Additionally, incorrect matches of _other_ Refaster templates in the method are flagged. +- For each Refaster template in the collection, the input and output file must + contain a method. The name of the method is equal to the name of the Refaster + template prefixed with `test` (e.g. `test`). +- The method contains at least one expression that matches the `@BeforeTemplate` + of one specific Refaster template. As a result, the output file contains the + same method with an updated expression, matching the content of the + `@AfterTemplate`. Additionally, incorrect matches of _other_ Refaster + templates in the method are flagged. As a result from these tests, unexpected output will be shown in the console. An example of a folder structure for such a setup is as follows: ``` -main/java/ - tech.picnic.errorprone.refastertemplates - └── ExampleTemplates.java -- Contains multiple Refaster templates. - └── Example1Template - └── Example2Template +main/ + java/ + tech.picnic.errorprone.refastertemplates + └── ExampleTemplates.java -- Contains multiple Refaster templates. + └── Example1Template + └── Example2Template test/ java/ └── tech.picnic.errorprone.refastertemplates - └── RefasterCollectionTest.java -- Here the test invokes `RefasterCollectionTestUtil#validateTemplateCollection`. + └── RefasterCollectionTest.java + -- Here the test invokes + -- `RefasterCollectionTestUtil#validateTemplateCollection`. resources/ └── tech.picnic.errorprone.refastertemplates - └── ExampleTemplatesTestInput.java -- Contains a class named `ExampleTemplatesTest` and - two methods named `testExample1Template` and `testExample2Template`. - └── ExampleTemplatesTestOutput.java -- Contains a class named `ExampleTemplatesTest` and - two methods named `testExample1Template` and `testExample2Template`. + └── ExampleTemplatesTestInput.java + -- Contains a class named `ExampleTemplatesTest` and + -- two methods named `testExample1Template` and + -- `testExample2Template`. + └── ExampleTemplatesTestOutput.java + -- Contains a class named `ExampleTemplatesTest` and + -- two methods named `testExample1Template` and + -- `testExample2Template`. ``` + diff --git a/refaster-test-support/pom.xml b/refaster-test-support/pom.xml index 598d4f6c073..abddc783d5e 100644 --- a/refaster-test-support/pom.xml +++ b/refaster-test-support/pom.xml @@ -85,15 +85,6 @@ - - com.coveo - fmt-maven-plugin - - - ${basedir}/src/test/resources - - - org.apache.maven.plugins maven-compiler-plugin