use of com.intellij.testFramework.fixtures.impl.GlobalInspectionContextForTests in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoPerformanceTest method doInspectionTest.
private void doInspectionTest(@NotNull InspectionProfileEntry tool, long expected) {
VirtualFile sourceDir = installTestData("docker");
if (sourceDir == null)
return;
//noinspection ConstantConditions
AnalysisScope scope = new AnalysisScope(getPsiManager().findDirectory(sourceDir));
scope.invalidate();
InspectionManagerEx inspectionManager = (InspectionManagerEx) InspectionManager.getInstance(getProject());
InspectionToolWrapper wrapper = InspectionToolRegistrar.wrapTool(tool);
GlobalInspectionContextForTests globalContext = CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, wrapper);
PlatformTestUtil.startPerformanceTest(getTestName(true), (int) expected, () -> InspectionTestUtil.runTool(wrapper, scope, globalContext)).cpuBound().usesAllCPUCores().assertTiming();
InspectionTestUtil.compareToolResults(globalContext, wrapper, false, new File(getTestDataPath(), wrapper.getShortName()).getPath());
}
use of com.intellij.testFramework.fixtures.impl.GlobalInspectionContextForTests in project android by JetBrains.
the class AndroidTestCase method doGlobalInspectionTest.
/**
* Given an inspection and a path to a directory that contains an "expected.xml" file, run the
* inspection on the current test project and verify that its output matches that of the
* expected file.
*/
protected final void doGlobalInspectionTest(@NotNull GlobalInspectionToolWrapper wrapper, @NotNull String globalTestDir, @NotNull AnalysisScope scope) {
myFixture.enableInspections(wrapper.getTool());
scope.invalidate();
InspectionManagerEx inspectionManager = (InspectionManagerEx) InspectionManager.getInstance(getProject());
GlobalInspectionContextForTests globalContext = CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, wrapper);
InspectionTestUtil.runTool(wrapper, scope, globalContext);
InspectionTestUtil.compareToolResults(globalContext, wrapper, false, getTestDataPath() + globalTestDir);
}
use of com.intellij.testFramework.fixtures.impl.GlobalInspectionContextForTests in project intellij-community by JetBrains.
the class InspectionTestCase method runTool.
protected GlobalInspectionContextImpl runTool(@NotNull final String testDir, final String jdkName, boolean runDeadCodeFirst, @NotNull InspectionToolWrapper toolWrapper, @NotNull InspectionToolWrapper... additional) {
final VirtualFile[] sourceDir = new VirtualFile[1];
ApplicationManager.getApplication().runWriteAction(() -> {
try {
setupRootModel(testDir, sourceDir, jdkName);
} catch (Exception e) {
LOG.error(e);
}
});
VirtualFile projectDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(testDir));
AnalysisScope scope = createAnalysisScope(sourceDir[0].equals(projectDir) ? projectDir : sourceDir[0].getParent());
List<InspectionToolWrapper<?, ?>> toolWrappers = new ArrayList<>();
if (runDeadCodeFirst) {
toolWrappers.add(getUnusedDeclarationWrapper());
}
toolWrappers.add(toolWrapper);
ContainerUtil.addAll(toolWrappers, additional);
GlobalInspectionContextForTests globalContext = InspectionsKt.createGlobalContextForTool(scope, getProject(), toolWrappers);
InspectionTestUtil.runTool(toolWrapper, scope, globalContext);
return globalContext;
}
Aggregations