Skip to content
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

JS-385 Fix SonarLint ITS #4889

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion its/plugin/sonarlint-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

<artifactId>javascript-it-plugin-sonarlint-tests</artifactId>
<name>JavaScript :: IT :: Plugin :: SonarLint Tests</name>
<packaging>pom</packaging>

<properties>
<surefire.argLine>-server</surefire.argLine>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package com.sonar.javascript.it.plugin.sonarlint.tests;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package com.sonar.javascript.it.plugin.sonarlint.tests;

import static org.assertj.core.api.Assertions.assertThat;

import java.nio.file.Files;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import static java.util.Objects.requireNonNull;

package com.sonar.javascript.it.plugin.sonarlint.tests;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.regex.Pattern;
import org.sonarsource.sonarlint.core.analysis.api.ClientInputFile;

Expand All @@ -42,14 +41,14 @@ public class TestUtils {
*
*/
private static Path artifact() {
var target = homeDir()
.resolve("../../../../../../sonar-plugin/sonar-javascript-plugin/target")
.normalize();
try (var stream = Files.walk(target, 1)) {
return stream
.filter(p -> pluginFilenameMatcher().matcher(p.getFileName().toString()).matches())
.findAny()
.orElseThrow(() -> new IllegalStateException("Cannot find plugin artifact in " + target));
try {
var target = Path.of("../../../sonar-plugin/sonar-javascript-plugin/target").toRealPath();
try (var stream = Files.walk(target, 1)) {
return stream
.filter(p -> pluginFilenameMatcher().matcher(p.getFileName().toString()).matches())
.findAny()
.orElseThrow(() -> new IllegalStateException("Cannot find plugin artifact in " + target));
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Expand All @@ -61,14 +60,6 @@ private static Pattern pluginFilenameMatcher() {
: Pattern.compile("sonar-javascript-plugin-[0-9.]*(?:-SNAPSHOT)?\\.jar");
}

public static Path homeDir() {
try {
return Path.of(requireNonNull(TestUtils.class.getResource("TestUtils.txt")).toURI());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't make this work, huh?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could, but @alban-auzeill mentioned that it makes no sense to use the path of an existing resource to build the homedir, and it's much easier to go directly to the artifact path, as we know where it is. This homeDir method was only used to locate the artifact.

} catch (URISyntaxException e) {
throw new IllegalStateException(e);
}
}

public static Path projectDir(String projectName) {
var file = Path.of("../projects").resolve(projectName);
if (!Files.exists(file)) {
Expand Down