mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
external compiler: fixed warnings on plugin project rebuild
This commit is contained in:
@@ -186,8 +186,8 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
protected void rebuild() {
|
||||
compile(false, new ParameterizedRunnable<CompileStatusNotification>() {
|
||||
protected CompilationLog rebuild() {
|
||||
return compile(false, new ParameterizedRunnable<CompileStatusNotification>() {
|
||||
@Override
|
||||
public void run(CompileStatusNotification compileStatusNotification) {
|
||||
getCompilerManager().rebuild(compileStatusNotification);
|
||||
@@ -196,6 +196,17 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
|
||||
}
|
||||
|
||||
protected CompilationLog compile(final boolean errorsExpected, final ParameterizedRunnable<CompileStatusNotification> action) {
|
||||
CompilationLog log = compile(action);
|
||||
if (errorsExpected && log.myErrors.length == 0) {
|
||||
Assert.fail("compilation finished without errors");
|
||||
}
|
||||
else if (!errorsExpected && log.myErrors.length > 0) {
|
||||
Assert.fail("compilation finished with errors: " + Arrays.toString(log.myErrors));
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
private CompilationLog compile(final ParameterizedRunnable<CompileStatusNotification> action) {
|
||||
final Ref<CompilationLog> result = Ref.create(null);
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@@ -211,14 +222,9 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
|
||||
if (aborted) {
|
||||
Assert.fail("compilation aborted");
|
||||
}
|
||||
if (errorsExpected && errors == 0) {
|
||||
Assert.fail("compilation finished without errors");
|
||||
}
|
||||
else if (!errorsExpected && errors > 0) {
|
||||
Assert
|
||||
.fail("compilation finished with errors: " + Arrays.toString(compileContext.getMessages(CompilerMessageCategory.ERROR)));
|
||||
}
|
||||
result.set(new CompilationLog(CompilerManagerImpl.getPathsToRecompile(), CompilerManagerImpl.getPathsToDelete()));
|
||||
result.set(new CompilationLog(CompilerManagerImpl.getPathsToRecompile(), CompilerManagerImpl.getPathsToDelete(),
|
||||
compileContext.getMessages(CompilerMessageCategory.ERROR),
|
||||
compileContext.getMessages(CompilerMessageCategory.WARNING)));
|
||||
}
|
||||
finally {
|
||||
semaphore.up();
|
||||
@@ -349,8 +355,12 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
|
||||
protected class CompilationLog {
|
||||
private final Set<String> myRecompiledPaths;
|
||||
private final Set<String> myDeletedPaths;
|
||||
private final CompilerMessage[] myErrors;
|
||||
private final CompilerMessage[] myWarnings;
|
||||
|
||||
public CompilationLog(String[] recompiledPaths, String[] deletedPaths) {
|
||||
public CompilationLog(String[] recompiledPaths, String[] deletedPaths, CompilerMessage[] errors, CompilerMessage[] warnings) {
|
||||
myErrors = errors;
|
||||
myWarnings = warnings;
|
||||
myRecompiledPaths = getRelativePaths(recompiledPaths);
|
||||
myDeletedPaths = getRelativePaths(deletedPaths);
|
||||
}
|
||||
@@ -383,6 +393,14 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
|
||||
assertSet("deleted", myDeletedPaths, expected);
|
||||
}
|
||||
|
||||
public CompilerMessage[] getErrors() {
|
||||
return myErrors;
|
||||
}
|
||||
|
||||
public CompilerMessage[] getWarnings() {
|
||||
return myWarnings;
|
||||
}
|
||||
|
||||
private void assertSet(String name, Set<String> actual, String[] expected) {
|
||||
if (useExternalCompiler()) return;
|
||||
for (String path : expected) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.jps.api.RequestFuture;
|
||||
import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.builders.BuildTargetType;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.cmdline.BuildRunner;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
@@ -340,7 +341,7 @@ public class IncProjectBuilder {
|
||||
}
|
||||
|
||||
ProjectDescriptor projectDescriptor = context.getProjectDescriptor();
|
||||
for (BuildTargetType type : BuilderRegistry.getInstance().getTargetTypes()) {
|
||||
for (BuildTargetType type : JavaModuleBuildTargetType.ALL_TYPES) {
|
||||
for (BuildTarget<?> target : projectDescriptor.getBuildTargetIndex().getAllTargets(type)) {
|
||||
for (BuildRootDescriptor descriptor : projectDescriptor.getBuildRootIndex().getTargetRoots(target, context)) {
|
||||
allSourceRoots.add(descriptor.getRootFile());
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.jetbrains.idea.devkit.projectRoots.IdeaJdk;
|
||||
import org.jetbrains.idea.devkit.projectRoots.Sandbox;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.intellij.util.io.TestFileSystemBuilder.fs;
|
||||
|
||||
@@ -80,9 +81,7 @@ public class PluginModuleCompilationTest extends BaseCompilerTestCase {
|
||||
}
|
||||
|
||||
public void testMakeModule() {
|
||||
copyToProject("plugins/devkit/testData/build/simple");
|
||||
Module module = loadModule(getProjectBasePath() + "/pluginProject.iml");
|
||||
readJdomExternalizables((ModuleImpl)module);
|
||||
Module module = setupPluginProject();
|
||||
make(module);
|
||||
assertOutput(module, fs().dir("xxx").file("MyAction.class"));
|
||||
|
||||
@@ -95,4 +94,17 @@ public class PluginModuleCompilationTest extends BaseCompilerTestCase {
|
||||
.dir("xxx").file("MyAction.class")
|
||||
.build().assertDirectoryEqual(sandbox);
|
||||
}
|
||||
|
||||
public void testRebuild() {
|
||||
setupPluginProject();
|
||||
CompilationLog log = rebuild();
|
||||
assertTrue("Rebuild finished with warnings: " + Arrays.toString(log.getWarnings()), log.getWarnings().length == 0);
|
||||
}
|
||||
|
||||
private Module setupPluginProject() {
|
||||
copyToProject("plugins/devkit/testData/build/simple");
|
||||
Module module = loadModule(getProjectBasePath() + "/pluginProject.iml");
|
||||
readJdomExternalizables((ModuleImpl)module);
|
||||
return module;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user