Skip to content

Commit 036ee10

Browse files
authored
bug(#716): mutation coverage up, hone profile separation (#721)
* bug(#716): hone separation * bug(#716): hone name * bug(#716): more mutation coverage * bug(#716): mutation coverage up * bug(#716): mutation coverage passes * bug(#716): clean for qulice * bug(#716): hone timeout 45min * bug(#716): hone to process-sources * bug(#716): hone to none phase * bug(#716): hone on property * bug(#716): hone back * empty commit to restart pipelines * bug(#716): hone up * bug(#716): exclude FSNamesystem as benchmark resource * bug(#716): puzzle for hone enablement * bug(#716): typo
1 parent b109855 commit 036ee10

File tree

6 files changed

+221
-5
lines changed

6 files changed

+221
-5
lines changed

.github/workflows/hone.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
2+
# SPDX-License-Identifier: MIT
3+
---
4+
# yamllint disable rule:line-length
5+
name: hone
6+
'on':
7+
push:
8+
branches:
9+
- master
10+
pull_request:
11+
branches:
12+
- master
13+
jobs:
14+
hone:
15+
timeout-minutes: 45
16+
runs-on: ubuntu-24.04
17+
# @todo #716:35min Enable hone.yml and jmh.yml (hone-dependent workflow) after hone will be fixed.
18+
# At present, the hone is unable to generate the correct optimized byte code for Groovy, see
19+
# this issue: https://github.com/objectionary/hone-maven-plugin/issues/297. Also, the plugin run
20+
# is time-consuming, we should enable it only after the plugin will have stable execution time,
21+
# in order to not disturb the development in this repository.
22+
if: false
23+
steps:
24+
- uses: actions/checkout@v5
25+
- uses: actions/setup-java@v4
26+
with:
27+
distribution: 'temurin'
28+
java-version: 23
29+
- uses: actions/cache@v4
30+
with:
31+
path: ~/.m2/repository
32+
key: ubuntu-surefire-jdk-23-maven-${{ hashFiles('**/pom.xml') }}
33+
restore-keys: ubuntu-surefire-jdk-23-maven-
34+
- run: |
35+
mvn clean install -Phone --errors --batch-mode

.github/workflows/jmh.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
jmh:
1212
timeout-minutes: 45
1313
runs-on: ubuntu-24.04
14+
if: false
1415
steps:
1516
- name: Run JMH Benchmark Action
1617
uses: volodya-lombrozo/jmh-benchmark-action@v1

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,16 +389,13 @@
389389
After the issue will be fixed, we should `<os/>` element from the `<activation/>`
390390
and keep `activeByDefault=true`.
391391
-->
392-
<os>
393-
<name>Linux</name>
394-
</os>
395392
</activation>
396393
<build>
397394
<plugins>
398395
<plugin>
399396
<groupId>org.eolang</groupId>
400397
<artifactId>hone-maven-plugin</artifactId>
401-
<version>0.9.1</version>
398+
<version>0.12.0</version>
402399
<executions>
403400
<execution>
404401
<goals>
@@ -408,6 +405,8 @@
408405
<configuration>
409406
<jeoVersion>0.13.9</jeoVersion>
410407
<rules>streams/*</rules>
408+
<!-- Used as benchmark resource. -->
409+
<excludes>/target/classes/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.class</excludes>
411410
</configuration>
412411
</execution>
413412
</executions>
@@ -465,9 +464,10 @@
465464
<class>org.eolang.lints.LtUnlintNonExistingDefectWpaTest</class>
466465
<class>org.eolang.lints.LtTestNotVerbTest</class>
467466
<class>org.eolang.lints.WpaLintsTest</class>
468-
<class>org.eolang.lints.LtReservedNameTest</class>
469467
</excludedTestClasses>
470468
<excludedClasses>
469+
<!-- Groovy script. -->
470+
<class>org.eolang.lints.ReserveNames</class>
471471
<!-- Used as benchmark resource. -->
472472
<class>org.apache.hadoop.hdfs.server.namenode.FSNamesystem</class>
473473
</excludedClasses>

src/test/java/org/eolang/lints/LtReservedNameTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,13 @@ void scansReservedFromHome() throws Exception {
186186
)
187187
);
188188
}
189+
190+
@Test
191+
void allowsAllUnique() throws IOException {
192+
MatcherAssert.assertThat(
193+
"Object names should not be reported, since they all unique",
194+
new LtReservedName(new MapOf<>()).defects(new EoSyntax("[] > foo").parsed()),
195+
Matchers.emptyIterable()
196+
);
197+
}
189198
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
3+
* SPDX-License-Identifier: MIT
4+
*/
5+
package org.eolang.lints;
6+
7+
import com.jcabi.xml.XML;
8+
import java.io.IOException;
9+
import java.util.Collection;
10+
import java.util.Collections;
11+
import java.util.Map;
12+
import org.cactoos.map.MapOf;
13+
import org.eolang.parser.EoSyntax;
14+
import org.hamcrest.MatcherAssert;
15+
import org.hamcrest.Matchers;
16+
import org.junit.jupiter.api.Assertions;
17+
import org.junit.jupiter.api.Test;
18+
19+
/**
20+
* Tests for {@link LtWpaUnlint}.
21+
*
22+
* @since 0.0.57
23+
*/
24+
final class LtWpaUnlintTest {
25+
26+
@Test
27+
void throwsWhenDefectIsOutsideOfTheScope() {
28+
MatcherAssert.assertThat(
29+
"Exception should be thrown, but it was not",
30+
Assertions.assertThrows(
31+
Exception.class,
32+
() -> new LtWpaUnlint(new LtWpaUnlintTest.LtWpaAlways()).defects(
33+
new MapOf<>(
34+
"x",
35+
new EoSyntax(
36+
"[] > x"
37+
).parsed()
38+
)
39+
)
40+
).getMessage(),
41+
Matchers.containsString(
42+
"defect was found in \"stdin\", but this source is not in scope"
43+
)
44+
);
45+
}
46+
47+
@Test
48+
void returnsDefectsWithoutUnlints() throws IOException {
49+
MatcherAssert.assertThat(
50+
"Returned defect does not match with expected",
51+
new LtWpaUnlint(new LtInconsistentArgs()).defects(
52+
new MapOf<>(
53+
"foo",
54+
new EoSyntax("[] > foo\n x 1 > x1\n x 1 2 > x2").parsed()
55+
)
56+
),
57+
Matchers.allOf(
58+
Matchers.hasSize(2),
59+
Matchers.hasToString(
60+
Matchers.containsString(
61+
"[foo inconsistent-args WARNING]"
62+
)
63+
)
64+
)
65+
);
66+
}
67+
68+
/**
69+
* Lint that always complains in WPA scope.
70+
* @since 0.0.57
71+
*/
72+
static final class LtWpaAlways implements Lint<Map<String, XML>> {
73+
@Override
74+
public String name() {
75+
return "noname";
76+
}
77+
78+
@Override
79+
public Collection<Defect> defects(final Map<String, XML> entity) {
80+
return Collections.singletonList(
81+
new Defect.Default(
82+
"some",
83+
Severity.ERROR,
84+
"stdin",
85+
42,
86+
"Foo lint fails!"
87+
)
88+
);
89+
}
90+
91+
@Override
92+
public String motive() {
93+
return "nothing";
94+
}
95+
}
96+
}

src/test/java/org/eolang/lints/WithoutLintsTest.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@
44
*/
55
package org.eolang.lints;
66

7+
import com.jcabi.xml.XML;
78
import com.tngtech.archunit.core.importer.ClassFileImporter;
89
import com.tngtech.archunit.core.importer.ImportOption;
910
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition;
11+
import java.io.IOException;
12+
import java.util.Collection;
13+
import java.util.Collections;
14+
import java.util.List;
15+
import java.util.Map;
16+
import java.util.stream.Collectors;
1017
import org.cactoos.list.ListOf;
1118
import org.hamcrest.MatcherAssert;
1219
import org.hamcrest.Matchers;
@@ -38,6 +45,38 @@ void excludesLints(final String lid) {
3845
);
3946
}
4047

48+
@Test
49+
void doesNotExcludeNonExistingLints() {
50+
final List<Lint<Map<String, XML>>> original = new ListOf<>(new LtInconsistentArgs());
51+
MatcherAssert.assertThat(
52+
"Lint should not be excluded, since lint by provided name does not exist",
53+
new ListOf<>(new WithoutLints<>(original, "计算机科学")),
54+
Matchers.hasSize(original.size())
55+
);
56+
}
57+
58+
@Test
59+
void excludesOnlySpecifiedLints() {
60+
MatcherAssert.assertThat(
61+
"The list of lints does not match with expected",
62+
new ListOf<>(
63+
new WithoutLints<>(
64+
new ListOf<>(
65+
new WithoutLintsTest.LtFake("foo"),
66+
new WithoutLintsTest.LtFake("bar"),
67+
new WithoutLintsTest.LtFake("jeff")
68+
),
69+
"foo", "jeff"
70+
)
71+
).stream().map(Lint::name).collect(Collectors.toList()),
72+
Matchers.allOf(
73+
Matchers.hasItem("bar"),
74+
Matchers.not(Matchers.hasItem("foo")),
75+
Matchers.not(Matchers.hasItem("jeff"))
76+
)
77+
);
78+
}
79+
4180
@Test
4281
@SuppressWarnings("JTCOP.RuleAssertionMessage")
4382
void staysPackagePrivate() {
@@ -49,4 +88,40 @@ void staysPackagePrivate() {
4988
.importPackages("org.eolang.lints")
5089
);
5190
}
91+
92+
/**
93+
* Fake lint.
94+
* @since 0.0.57
95+
*/
96+
static final class LtFake implements Lint<XML> {
97+
98+
/**
99+
* The lint name.
100+
*/
101+
private final String lname;
102+
103+
/**
104+
* Ctor.
105+
*
106+
* @param nme The lint name
107+
*/
108+
LtFake(final String nme) {
109+
this.lname = nme;
110+
}
111+
112+
@Override
113+
public String name() {
114+
return this.lname;
115+
}
116+
117+
@Override
118+
public Collection<Defect> defects(final XML xmir) throws IOException {
119+
return Collections.emptyList();
120+
}
121+
122+
@Override
123+
public String motive() {
124+
return "no motive";
125+
}
126+
}
52127
}

0 commit comments

Comments
 (0)