-
Notifications
You must be signed in to change notification settings - Fork 16
bug(#632): wrong-test-order lint
#784
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bcdb27f
bug(#632): add wrong-test-order lint to enforce proper test placement…
h1alexbel 93ce4b8
bug(#632): motive
h1alexbel 26f8e6c
bug(#632): disable depends on RUN_WORKFLOW
h1alexbel 6ad0891
bug(#632): disable depends on RUN_WORKFLOW
h1alexbel 21d5ecd
ci: update java versions in maven workflow matrix and add exclusions
h1alexbel 93a551e
ci: remove extra spaces in java version matrix for consistency
h1alexbel 3949936
ci: replace env with vars in workflow conditionals to use repository …
h1alexbel c190a69
empty commit to restart pipelines
h1alexbel 67da4ad
ci: add cleanup step to remove eolang dependencies before maven build
h1alexbel 8292612
ci: increase deep workflow timeout from 20 to 30 minutes
h1alexbel 9f01004
empty commit to restart pipelines
h1alexbel ef91850
Merge branch 'master' into 632
h1alexbel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/main/resources/org/eolang/lints/tests/wrong-test-order.xsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| * SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| * SPDX-License-Identifier: MIT | ||
| --> | ||
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" id="wrong-test-order" version="2.0"> | ||
| <xsl:import href="/org/eolang/parser/_funcs.xsl"/> | ||
| <xsl:import href="/org/eolang/funcs/lineno.xsl"/> | ||
| <xsl:import href="/org/eolang/funcs/escape.xsl"/> | ||
| <xsl:import href="/org/eolang/funcs/defect-context.xsl"/> | ||
| <xsl:output encoding="UTF-8" method="xml"/> | ||
| <xsl:template match="/"> | ||
| <defects> | ||
| <xsl:for-each select="/object//o[starts-with(@name, '+')]"> | ||
| <xsl:variable name="next" select="following-sibling::*[1]"/> | ||
| <xsl:if test="$next[self::o] and not(starts-with($next/@name, '+'))"> | ||
| <xsl:element name="defect"> | ||
| <xsl:variable name="line" select="eo:lineno(@line)"/> | ||
| <xsl:attribute name="line"> | ||
| <xsl:value-of select="$line"/> | ||
| </xsl:attribute> | ||
| <xsl:if test="$line = '0'"> | ||
| <xsl:attribute name="context"> | ||
| <xsl:value-of select="eo:defect-context(.)"/> | ||
| </xsl:attribute> | ||
| </xsl:if> | ||
| <xsl:attribute name="severity"> | ||
| <xsl:text>warning</xsl:text> | ||
| </xsl:attribute> | ||
| <xsl:text>The unit test wrongly ordered: </xsl:text> | ||
| <xsl:value-of select="eo:escape(eo:escape-plus(@name))"/> | ||
| </xsl:element> | ||
| </xsl:if> | ||
| </xsl:for-each> | ||
| </defects> | ||
| </xsl:template> | ||
| </xsl:stylesheet> | ||
19 changes: 19 additions & 0 deletions
19
src/main/resources/org/eolang/motives/tests/wrong-test-order.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Wrong test order | ||
|
|
||
| Unit tests must be located after live objects: | ||
|
|
||
| Incorrect: | ||
|
|
||
| ```eo | ||
| [] > foo | ||
| [] +> runs-something | ||
| [] > bar | ||
| ``` | ||
|
|
||
| Correct: | ||
|
|
||
| ```eo | ||
| [] > foo | ||
| [] > bar | ||
| [] +> runs-something | ||
| ``` |
13 changes: 13 additions & 0 deletions
13
src/test/resources/org/eolang/lints/packs/single/wrong-test-order/allows-correct-order.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| sheets: | ||
| - /org/eolang/lints/tests/wrong-test-order.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=1] | ||
| - /defects/defect[@line='3'] | ||
| input: | | ||
| [] > foo | ||
| [] > bar | ||
| [] +> runs-program | ||
| [] > boom |
12 changes: 12 additions & 0 deletions
12
src/test/resources/org/eolang/lints/packs/single/wrong-test-order/allows-no-tests.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| sheets: | ||
| - /org/eolang/lints/tests/wrong-test-order.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=0] | ||
| input: | | ||
| [] > foo | ||
| [] > a | ||
| [] > x | ||
| [] > y |
10 changes: 10 additions & 0 deletions
10
src/test/resources/org/eolang/lints/packs/single/wrong-test-order/allows-single-test.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| sheets: | ||
| - /org/eolang/lints/tests/wrong-test-order.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=0] | ||
| input: | | ||
| [] > main | ||
| [] +> testing |
11 changes: 11 additions & 0 deletions
11
src/test/resources/org/eolang/lints/packs/single/wrong-test-order/allows-tests-only.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| sheets: | ||
| - /org/eolang/lints/tests/wrong-test-order.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=0] | ||
| input: | | ||
| [] > at | ||
| [] +> test | ||
| [] +> another-test |
13 changes: 13 additions & 0 deletions
13
src/test/resources/org/eolang/lints/packs/single/wrong-test-order/catches-mixed.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| sheets: | ||
| - /org/eolang/lints/tests/wrong-test-order.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=1] | ||
| - /defects/defect[@line='2'] | ||
| input: | | ||
| [] > app | ||
| [] +> runs | ||
| [] > x | ||
| [] +> something |
13 changes: 13 additions & 0 deletions
13
src/test/resources/org/eolang/lints/packs/single/wrong-test-order/catches-test-first.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| sheets: | ||
| - /org/eolang/lints/tests/wrong-test-order.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=1] | ||
| - /defects/defect[@line='2'] | ||
| input: | | ||
| [] > x | ||
| [] +> runs-x | ||
| [] > bool | ||
| [] > t |
12 changes: 12 additions & 0 deletions
12
src/test/resources/org/eolang/lints/packs/single/wrong-test-order/catches-wrong-order.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| sheets: | ||
| - /org/eolang/lints/tests/wrong-test-order.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=0] | ||
| input: | | ||
| [] > main | ||
| [] > bar | ||
| [] > boom | ||
| [] > test |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.