Skip to content

Commit 8718f5a

Browse files
1.4.0 integration test fixes (#2842)
* Fix typo * Update release testing
1 parent 90413e7 commit 8718f5a

File tree

3 files changed

+30
-33
lines changed

3 files changed

+30
-33
lines changed

RELEASE_TESTING.MD

+21-23
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ Before releasing a new version of KtLint, the release candidate is tested on a s
1313
```shell
1414
# Examples of usage
1515
#
16-
# Do not run ktlint commands with this script. Instead run them direct from the `sample-projects` directory
17-
# ktlint --version && ktlint "**/*.kt" -v --relative --format --force-lint-after-format
18-
#
1916
# Outstanding changes per project
2017
# ./exec-in-each-project.sh "git status"
2118
#
2219
# Rollback outstanding changes per project
2320
# ./exec-in-each-project.sh "git reset --hard"
2421
#
22+
# Run ktlint standard rules
23+
# ktlint --version && ktlint "**/*.kt" -v --relative -F
24+
#
2525
# Commit changes of standard rules:
2626
# ./exec-in-each-project.sh "git commit -m \"ktlint (0.43.2) -F\""
2727

@@ -40,12 +40,12 @@ Before releasing a new version of KtLint, the release candidate is tested on a s
4040
```
4141
4. Create an alias or script to run the latest released version of ktlint (note that this script will print the version as reference to which version is used):
4242
```shell
43-
alias ktlint-prev="ktlint-1.3.0 $@" # Replace with the latest release version
43+
alias ktlint-prev="ktlint-1.3.1 $@" # Replace with the latest release version
4444
```
4545
Note that `~/git/ktlint` is the directory in which the ktlint project is checked out and that `~/git/ktlint/ktlint` refers to the `ktlint` CLI-module.
4646
5. Create an alias or script to run the latest development-version of ktlint (note that this script will print the version and the datetime of compilation as reference to which version is used):
4747
```shell
48-
alias ktlint-dev="echo 'ktlint-dev version:';ls -aslh ~/git/ktlint/pinterest/ktlint/ktlint-cli/build/run/ktlint;echo ' ';~/git/ktlint/pinterest/ktlint/ktlint-cli/build/run/ktlint $@"
48+
alias ktlint-dev="echo 'ktlint-dev version:';ls -aslh ~/git/ktlint/ktlint/ktlint-cli/build/run/ktlint;echo ' ';~/git/ktlint/ktlint/ktlint-cli/build/run/ktlint $@"
4949
```
5050
Note that `~/git/ktlint/pinterest/ktlint` is the directory in which the ktlint project is checked out.
5151

@@ -82,7 +82,6 @@ Formatting projects in which ktlint is not used may result in a huge amount of f
8282
8383
[graphql-kotlin/**/*.{kt,kts}]
8484
ktlint_standard_no-unused-imports = disabled
85-
ktlint_standard_import-ordering = disabled
8685
8786
[kotlinx.coroutines/**/*.{kt,kts}]
8887
ktlint_standard_no-wildcard-imports = disabled
@@ -92,7 +91,6 @@ Formatting projects in which ktlint is not used may result in a huge amount of f
9291
# be changed:
9392
# 1) Disable the "root = true" property so that each project ultimately falls back on this file. In this way offending
9493
# rules can be easily enabled/disabled for all test projects
95-
# 2) From the graphql project remove the `disabled_rules` property
9694
ktlint_code_style = ktlint_official
9795
ktlint_experimental = enabled
9896
ktlint_standard = enabled
@@ -109,7 +107,7 @@ Formatting projects in which ktlint is not used may result in a huge amount of f
109107
Note: Ignore all output as this is the old version!
110108
4. Format the sample projects with the previous (*latest released*) ktlint version:
111109
```shell
112-
ktlint-prev --format --force-lint-after-format --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script.
110+
ktlint-prev -F --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script.
113111
```
114112
Note: Ignore all output as this is the old version!
115113
5. Commit changes:
@@ -132,25 +130,25 @@ Formatting projects in which ktlint is not used may result in a huge amount of f
132130
ktlint-dev --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want to use the one combined baseline.xml file for all projects.
133131
```
134132
Inspect the output roughly (detailed inspection is done when formatting):
135-
* Is the amount of logging messages comparable to before? If not, are the changes intended?
136-
* Are violations related to rules that have actually been added or changed?
137-
* If you see an error like below, then this version obviously may *not* be released. It is best to fix this error before continuing with testing and validating!
133+
* Is the amount of logging messages comparable to before? If not, are the changes intended?
134+
* Are violations related to rules that have actually been added or changed?
135+
* If you see an error like below, then this version obviously may *not* be released. It is best to fix this error before continuing with testing and validating!
138136
```plain
139137
Internal Error (...) in file '...' at position '0:0. Please create a ticket at https://github.com/pinterest/ktlint/issues ...
140138
```
141139
9. Format with *latest development* version:
142140
```shell
143-
ktlint-dev --format --force-lint-after-format --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want to use the one combined baseline.xml file for all projects.
141+
ktlint-dev -F --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want to use the one combined baseline.xml file for all projects.
144142
```
145143
Inspect the output carefully:
146-
* If you see an error like below, then this version obviously may *not* be released. It is best to fix this error before continuing with testing and validating!
144+
* If you see an error like below, then this version obviously may *not* be released. It is best to fix this error before continuing with testing and validating!
147145
```plain
148146
Internal Error (...) in file '...' at position '0:0. Please create a ticket at https://github.com/pinterest/ktlint/issues ...
149147
```
150-
* Usually it helps to disable all rules that emit violations, except one of those rules. In this way it is possible to evaluate the changes rule by rule.
151-
* Ideally, no violations are shown. This means that all violations have been autocorrected. Note that violations might pop up that previously were suppressed via the baseline. This can happen as due to code changes, the references in the baseline.xml no longer match with the positions where they occur. First check the code changes, and regenerating the baseline before verifying the next can be a helpful approach.
152-
* Violations which could not be autocorrected should be validated for correctness but do not block the release as most likely this is intended behavior.
153-
* If a violation is shown which is not marked as being "can not be autocorrected" this means that during autocorrect of another violation a new violations has been introduced. This should be fixed before releasing especially when the next format introduces the original violation again which of course would result in an endless loop.
148+
* Usually it helps to disable all rules that emit violations, except one of those rules. In this way it is possible to evaluate the changes rule by rule.
149+
* Ideally, no violations are shown. This means that all violations have been autocorrected. Note that violations might pop up that previously were suppressed via the baseline. This can happen as due to code changes, the references in the baseline.xml no longer match with the positions where they occur. First check the code changes, and regenerating the baseline before verifying the next can be a helpful approach.
150+
* Violations which could not be autocorrected should be validated for correctness but do not block the release as most likely this is intended behavior.
151+
* If a violation is shown which is not marked as being "can not be autocorrected" this means that during autocorrect of another violation a new violations has been introduced. This should be fixed before releasing especially when the next format introduces the original violation again which of course would result in an endless loop.
154152
10. Inspect all fixed violations, Of course inspection similar violations tens of times does not make sense. At least check different types of violations a couple of times. Commit changes which do not need to be inspected again:
155153
```shell
156154
./exec-in-each-project.sh "git add --all && git commit -m \"Fixed with latest development version\""
@@ -165,14 +163,14 @@ Formatting projects in which ktlint is not used may result in a huge amount of f
165163
Internal Error (...) in file '...' at position '0:0. Please create a ticket at https://github.com/pinterest/ktlint/issues ...
166164
```
167165
12. Rerun lint with *latest development* version and verify that no violations are reported:
168-
```shell
169-
ktlint-dev --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want one combined baseline.xml file for all projects.
170-
```
166+
```shell
167+
ktlint-dev --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want one combined baseline.xml file for all projects.
168+
```
171169
No violations should be reported in this run.
172170
13. Rerun format with *latest development* version without baseline:
173-
```shell
174-
ktlint-dev --format --force-lint-after-format --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want to use the one combined baseline.xml file for all projects.
175-
```
171+
```shell
172+
ktlint-dev -F --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want to use the one combined baseline.xml file for all projects.
173+
```
176174
As the baseline is removed, thousands of violations are to be expected. Check at least in the summary that no internal errors are thrown like below:
177175
```plain
178176
Internal Error (...) in file '...' at position '0:0. Please create a ticket at https://github.com/pinterest/ktlint/issues ...

ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BlankLineBetweenWhenConditions.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ public class BlankLineBetweenWhenConditions :
8484
?.let { whitespaceBeforeWhenEntry ->
8585
emitAndApprove(
8686
whitespaceBeforeWhenEntry.startOffset + 1,
87-
"Add a blank line between all when-condition in case at least one multiline when-condition is found in the " +
88-
"statement",
87+
"Add a blank line between all when-conditions in case at least one multiline when-condition is found in the statement",
8988
true,
9089
).ifAutocorrectAllowed {
9190
whitespaceBeforeWhenEntry.upsertWhitespaceBeforeMe("\n${whenEntry.indent()}")

ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BlankLineBetweenWhenConditionsTest.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class BlankLineBetweenWhenConditionsTest {
8484
@Suppress("ktlint:standard:argument-list-wrapping", "ktlint:standard:max-line-length")
8585
blankLineAfterWhenConditionRuleAssertThat(code)
8686
.hasLintViolations(
87-
LintViolation(4, 1, "Add a blank line between all when-condition in case at least one multiline when-condition is found in the statement"),
88-
LintViolation(6, 1, "Add a blank line between all when-condition in case at least one multiline when-condition is found in the statement"),
87+
LintViolation(4, 1, "Add a blank line between all when-conditions in case at least one multiline when-condition is found in the statement"),
88+
LintViolation(6, 1, "Add a blank line between all when-conditions in case at least one multiline when-condition is found in the statement"),
8989
).isFormattedAs(formattedCode)
9090
}
9191

@@ -116,8 +116,8 @@ class BlankLineBetweenWhenConditionsTest {
116116
@Suppress("ktlint:standard:argument-list-wrapping", "ktlint:standard:max-line-length")
117117
blankLineAfterWhenConditionRuleAssertThat(code)
118118
.hasLintViolations(
119-
LintViolation(4, 1, "Add a blank line between all when-condition in case at least one multiline when-condition is found in the statement"),
120-
LintViolation(5, 1, "Add a blank line between all when-condition in case at least one multiline when-condition is found in the statement"),
119+
LintViolation(4, 1, "Add a blank line between all when-conditions in case at least one multiline when-condition is found in the statement"),
120+
LintViolation(5, 1, "Add a blank line between all when-conditions in case at least one multiline when-condition is found in the statement"),
121121
).isFormattedAs(formattedCode)
122122
}
123123

@@ -152,8 +152,8 @@ class BlankLineBetweenWhenConditionsTest {
152152
@Suppress("ktlint:standard:argument-list-wrapping", "ktlint:standard:max-line-length")
153153
blankLineAfterWhenConditionRuleAssertThat(code)
154154
.hasLintViolations(
155-
LintViolation(5, 1, "Add a blank line between all when-condition in case at least one multiline when-condition is found in the statement"),
156-
LintViolation(7, 1, "Add a blank line between all when-condition in case at least one multiline when-condition is found in the statement"),
155+
LintViolation(5, 1, "Add a blank line between all when-conditions in case at least one multiline when-condition is found in the statement"),
156+
LintViolation(7, 1, "Add a blank line between all when-conditions in case at least one multiline when-condition is found in the statement"),
157157
).isFormattedAs(formattedCode)
158158
}
159159

@@ -182,7 +182,7 @@ class BlankLineBetweenWhenConditionsTest {
182182
""".trimIndent()
183183
@Suppress("ktlint:standard:argument-list-wrapping", "ktlint:standard:max-line-length")
184184
blankLineAfterWhenConditionRuleAssertThat(code)
185-
.hasLintViolation(4, 1, "Add a blank line between all when-condition in case at least one multiline when-condition is found in the statement")
185+
.hasLintViolation(4, 1, "Add a blank line between all when-conditions in case at least one multiline when-condition is found in the statement")
186186
.isFormattedAs(formattedCode)
187187
}
188188

@@ -209,7 +209,7 @@ class BlankLineBetweenWhenConditionsTest {
209209
""".trimIndent()
210210
@Suppress("ktlint:standard:argument-list-wrapping", "ktlint:standard:max-line-length")
211211
blankLineAfterWhenConditionRuleAssertThat(code)
212-
.hasLintViolation(4, 1, "Add a blank line between all when-condition in case at least one multiline when-condition is found in the statement")
212+
.hasLintViolation(4, 1, "Add a blank line between all when-conditions in case at least one multiline when-condition is found in the statement")
213213
.isFormattedAs(formattedCode)
214214
}
215215
}

0 commit comments

Comments
 (0)