Skip to content
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
6 changes: 4 additions & 2 deletions clwb/test_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ def _integration_test_suite(name, srcs, deps = []):
# fixes preferences not writable on mac
"-Djava.util.prefs.PreferencesFactory=com.google.idea.testing.headless.InMemoryPreferencesFactory",
# suppressed plugin sets for classic, radler is currently disabled for tests
"-Didea.suppressed.plugins.set.classic=org.jetbrains.plugins.clion.radler,intellij.rider.cpp.debugger,intellij.rider.plugins.clion.radler.cwm",
"-Didea.suppressed.plugins.set.selector=classic",
"-Didea.suppressed.plugins.set.radler=com.intellij.cidr.lang",
"-Didea.suppressed.plugins.set.selector=radler",
# disable backend timeout for radler
"-Dpatch.engine.backend.freeze.timeout=-1",
# enable detailed logging in tests to diagnose issues in CI
"-Didea.log.trace.categories=com.jetbrains.cidr.lang.workspace,com.google.idea.blaze.cpp.BlazeCWorkspace",
"-Dcidr.debugger.use.lldbfrontend.from.plugin=false",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import com.google.idea.blaze.base.model.primitives.Label
import com.google.idea.blaze.base.run.BlazeCommandRunConfiguration
import com.google.idea.blaze.base.run.producers.BlazeBuildFileRunConfigurationProducer
import com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState
import com.google.idea.blaze.clwb.base.AllowedVfsRoot
import com.google.idea.blaze.clwb.base.AllowedVfsRoot.Config
import com.google.idea.blaze.clwb.base.ClwbHeadlessTestCase
import com.google.idea.blaze.clwb.run.BlazeCidrRemoteDebugProcess
import com.google.idea.testing.headless.ProjectViewBuilder
Expand Down Expand Up @@ -54,6 +56,7 @@ import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import java.nio.file.Files
import java.nio.file.Path
import java.util.ArrayList
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit

Expand Down Expand Up @@ -96,6 +99,12 @@ class ExecutionTest : ClwbHeadlessTestCase() {
return builder
}

override fun addAllowedVfsRoots(roots: ArrayList<AllowedVfsRoot>) {
super.addAllowedVfsRoots(roots)

roots.add(AllowedVfsRoot.recursive(Config.DEBUG, "external/catch2+"))
}

private fun checkRun(executorId: String) {
val echo = execute(Label.create("//main:echo0"), executorId)
echo.assertSuccess()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.google.idea.blaze.base.bazel.BazelVersion;
import com.google.idea.blaze.clwb.base.AllowedVfsRoot;
import com.google.idea.blaze.clwb.base.AllowedVfsRoot.Config;
import com.google.idea.blaze.clwb.base.ClwbHeadlessTestCase;
import com.google.idea.testing.headless.BazelVersionRule;
import com.google.idea.testing.headless.ProjectViewBuilder;
Expand Down Expand Up @@ -64,7 +65,8 @@ protected ProjectViewBuilder projectViewText(BazelVersion version) {
@Override
protected void addAllowedVfsRoots(ArrayList<AllowedVfsRoot> roots) {
super.addAllowedVfsRoots(roots);
roots.add(AllowedVfsRoot.bazelBinRecursive(myBazelInfo, "proto"));
roots.add(AllowedVfsRoot.recursive(Config.FASTBUILD, "proto"));
roots.add(AllowedVfsRoot.recursive(Config.FASTBUILD, "external/protobuf+"));
}

private void checkProto() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.google.idea.blaze.base.bazel.BazelVersion;
import com.google.idea.blaze.clwb.base.AllowedVfsRoot;
import com.google.idea.blaze.clwb.base.AllowedVfsRoot.Config;
import com.google.idea.blaze.clwb.base.ClwbHeadlessTestCase;
import com.google.idea.testing.headless.ProjectViewBuilder;
import com.intellij.openapi.vfs.VirtualFile;
Expand Down Expand Up @@ -65,8 +66,8 @@ protected ProjectViewBuilder projectViewText(BazelVersion version) {
@Override
protected void addAllowedVfsRoots(ArrayList<AllowedVfsRoot> roots) {
super.addAllowedVfsRoots(roots);
roots.add(AllowedVfsRoot.bazelBinRecursive(myBazelInfo, "lib/strip_absolut/_virtual_includes"));
roots.add(AllowedVfsRoot.bazelBinRecursive(myBazelInfo, "external/clwb_virtual_includes_external+"));
roots.add(AllowedVfsRoot.recursive(Config.FASTBUILD, "lib/strip_absolut/_virtual_includes"));
roots.add(AllowedVfsRoot.recursive(Config.FASTBUILD, "external/clwb_virtual_includes_external+"));
}

private void checkIncludes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,70 @@

package com.google.idea.blaze.clwb.base;

import com.google.idea.testing.headless.BazelInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.ObjectUtils;
import java.nio.file.Path;
import org.jetbrains.annotations.NotNull;

public class AllowedVfsRoot {

private final Path root;
public enum Config {ANY, FASTBUILD, DEBUG}

private final Config config;
private final Path path;
private final boolean recursive;

private AllowedVfsRoot(Path root, boolean recursive) {
assert !root.isAbsolute() : "the path should be relative to the execution root";
private AllowedVfsRoot(Config config, Path path, boolean recursive) {
assert !path.isAbsolute() : "the path should be relative to the execution path";

this.root = root;
this.config = config;
this.path = path;
this.recursive = recursive;
}

public static AllowedVfsRoot flat(String path) {
return new AllowedVfsRoot(Path.of(path).normalize(), false);
}

public static AllowedVfsRoot recursive(String path) {
return new AllowedVfsRoot(Path.of(path).normalize(), true);
}

public static AllowedVfsRoot bazelBinFlat(BazelInfo info, String path) {
return new AllowedVfsRoot(info.executionRoot().relativize(info.bazelBin().resolve(path)).normalize(), false);
public static AllowedVfsRoot flat(Config config, String path) {
return new AllowedVfsRoot(config, Path.of(path).normalize(), false);
}

public static AllowedVfsRoot bazelBinRecursive(BazelInfo info, String path) {
return new AllowedVfsRoot(info.executionRoot().relativize(info.bazelBin().resolve(path)).normalize(), true);
public static AllowedVfsRoot recursive(Config config, String path) {
return new AllowedVfsRoot(config, Path.of(path).normalize(), true);
}

public boolean contains(Path path) {
assert !path.isAbsolute() : "the path should be relative to the execution root";
assert !path.isAbsolute() : "the path should be relative to the execution path";
assert path.getNameCount() > 3 : "the path should contain at least more then 3 elemnts";
assert path.getName(0).toString().equals("bazel-out") : "the path should start with bazel-out";
assert path.getName(2).toString().equals("bin") : "the path should reside in bazel-bin";

final var effectiveConfig = path.getName(1).toString();
if (config == Config.FASTBUILD && !effectiveConfig.contains("fastbuild")) return false;
if (config == Config.DEBUG && !effectiveConfig.contains("dbg")) return false;

final var effectivePath = path.subpath(3, path.getNameCount());
if (recursive) {
return FileUtil.isAncestor(root.toFile(), path.toFile(), false);
return FileUtil.isAncestor(this.path.toFile(), effectivePath.toFile(), false);
} else {
return FileUtil.pathsEqual(root.toString(), ObjectUtils.coalesce(path.getParent(), Path.of("")).toString());
return FileUtil.pathsEqual(this.path.toString(), ObjectUtils.coalesce(effectivePath.getParent().toString(), ""));
}
}

@Override
public @NotNull String toString() {
final var builder = new StringBuilder();

if (recursive) {
return root.toString();
builder.append("|");
} else {
return "|" + root.toString();
builder.append("-");
}

builder.append("[");
builder.append(config.toString());
builder.append("]:");

builder.append(path.toString());

return builder.toString();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@

public class Assertions {

private final static Pattern defineRx = Pattern.compile("#define ([^ ]+) ?(.*)");
private final static String ASPECT_FILE_EXTENSION = ".intellij-info.txt";
private final static Pattern DEFINE_RX = Pattern.compile("#define ([^ ]+) ?(.*)");

public static void assertContainsHeader(String fileName, OCCompilerSettings settings) {
assertContainsHeader(fileName, true, settings);
Expand Down Expand Up @@ -91,7 +92,7 @@ public static StringSubject assertDefine(String symbol, OCCompilerSettings setti
assertThat(defines).isNotEmpty();

for (final var define : defines) {
final var matcher = defineRx.matcher(define);
final var matcher = DEFINE_RX.matcher(define);
if (!matcher.find()) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,40 @@
package com.google.idea.blaze.clwb.base;

import static com.google.common.truth.Truth.assertThat;
import static com.google.idea.testing.headless.Assertions.abort;

import com.google.idea.blaze.base.bazel.BazelVersion;
import com.google.idea.testing.headless.HeadlessTestCase;
import com.google.idea.testing.headless.ProjectViewBuilder;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.testFramework.HeavyPlatformTestCase;
import com.jetbrains.cidr.lang.CLanguageKind;
import com.jetbrains.cidr.lang.OCLanguageKind;
import com.jetbrains.cidr.lang.workspace.OCCompilerSettings;
import com.jetbrains.cidr.lang.workspace.OCResolveConfiguration;
import com.jetbrains.cidr.lang.workspace.OCWorkspace;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;

public abstract class ClwbHeadlessTestCase extends HeadlessTestCase {

@Override
protected void setUp() throws Exception {
super.setUp();
protected void setUpProject() throws Exception {
super.setUpProject();

setupSandboxBin();
// RadInitialConfigurator (clion-radler) flips AUTO_POPUP_JAVADOC_INFO on
// the first launch. The tearDown checks compare against default settings.
setDefaultCodeInsightSettings(CodeInsightSettings.getInstance());
}

@Override
protected void tearDown() throws Exception {
final var roots = new ArrayList<AllowedVfsRoot>();
addAllowedVfsRoots(roots);

Assertions.assertVfsLoads(myBazelInfo.executionRoot(), roots);
// HeavyPlatformTestCase.cleanupApplicationCaches(myProject);
// TODO: these assertions are failing due to the upgrade to radler
// Assertions.assertVfsLoads(myBazelInfo.executionRoot(), roots);
HeavyPlatformTestCase.cleanupApplicationCaches(myProject);

super.tearDown();
}

private void setupSandboxBin() {
final var clionId = PluginId.getId("com.intellij.clion");
assertThat(clionId).isNotNull();

final var clionPlugin = PluginManager.getInstance().findEnabledPlugin(clionId);
assertThat(clionPlugin).isNotNull();

var pluginsPath = clionPlugin.getPluginPath();
while (pluginsPath != null && !pluginsPath.endsWith("plugins")) pluginsPath = pluginsPath.getParent();
assertThat(pluginsPath).isNotNull();

final var sdkBinPath = pluginsPath.getParent().resolve("bin");
assertExists(sdkBinPath.toFile());

try {
final var link = Path.of(PathManager.getBinPath());
Files.deleteIfExists(link);
Files.createSymbolicLink(link, sdkBinPath);
} catch (IOException e) {
abort("could not create bin path symlink", e);
}
}

protected void addAllowedVfsRoots(ArrayList<AllowedVfsRoot> roots) { }

protected OCWorkspace getWorkspace() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.google.common.truth.Truth.assertThat
import com.google.idea.blaze.clwb.base.ExecutionRootPathResolverStub
import com.google.common.collect.ImmutableList
import com.google.idea.blaze.cpp.copts.CoptsProcessor
import com.intellij.codeInsight.CodeInsightSettings
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import com.jetbrains.cidr.lang.workspace.compiler.ClangCompilerKind
import com.jetbrains.cidr.lang.workspace.compiler.ClangClCompilerKind
Expand All @@ -39,6 +40,14 @@ private val ALL_COMPILER = listOf(ClangCompilerKind, GCCCompilerKind, ClangClCom
@RunWith(JUnit4::class)
class CoptsProcessorTest : BasePlatformTestCase() {

override fun setUp() {
super.setUp()

// RadInitialConfigurator (clion-radler) flips AUTO_POPUP_JAVADOC_INFO on the
// first launch. The tearDown checks compare against default settings.
setDefaultCodeInsightSettings(CodeInsightSettings.getInstance())
}

private fun doTest(
compilers: List<OCCompilerKind>,
copts: List<String>,
Expand Down
1 change: 1 addition & 0 deletions intellij_platform_sdk/BUILD.clion261
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ java_import(
"maven/test-framework.jar", #MAVEN:platform:test-framework
"maven/test-framework-common.jar", #MAVEN:platform:test-framework-common
"maven/test-framework-core.jar", #MAVEN:platform:test-framework-core
"maven/test-framework-team-city.jar", #MAVEN:platform:test-framework-team-city
"maven/java-rt.jar", #MAVEN:java:java-rt
]),
)
Expand Down
1 change: 1 addition & 0 deletions intellij_platform_sdk/BUILD.clion262
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ java_import(
"maven/test-framework.jar", #MAVEN:platform:test-framework
"maven/test-framework-common.jar", #MAVEN:platform:test-framework-common
"maven/test-framework-core.jar", #MAVEN:platform:test-framework-core
"maven/test-framework-team-city.jar", #MAVEN:platform:test-framework-team-city
"maven/java-rt.jar", #MAVEN:java:java-rt
]),
)
Expand Down
Loading
Loading