Search in sources :

Example 1 with GlobalInspectionContextForTests

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());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AnalysisScope(com.intellij.analysis.AnalysisScope) InspectionManagerEx(com.intellij.codeInspection.ex.InspectionManagerEx) GlobalInspectionContextForTests(com.intellij.testFramework.fixtures.impl.GlobalInspectionContextForTests) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 2 with GlobalInspectionContextForTests

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);
}
Also used : InspectionManagerEx(com.intellij.codeInspection.ex.InspectionManagerEx) GlobalInspectionContextForTests(com.intellij.testFramework.fixtures.impl.GlobalInspectionContextForTests)

Example 3 with GlobalInspectionContextForTests

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AnalysisScope(com.intellij.analysis.AnalysisScope) ArrayList(java.util.ArrayList) GlobalInspectionContextForTests(com.intellij.testFramework.fixtures.impl.GlobalInspectionContextForTests) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

GlobalInspectionContextForTests (com.intellij.testFramework.fixtures.impl.GlobalInspectionContextForTests)3 AnalysisScope (com.intellij.analysis.AnalysisScope)2 InspectionManagerEx (com.intellij.codeInspection.ex.InspectionManagerEx)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)1 ArrayList (java.util.ArrayList)1