eclipse-pde / eclipse.pde

Eclipse Public License 2.0
28 stars 79 forks source link

Timing problem with API tests #385

Open merks opened 2 years ago

merks commented 2 years ago

While testing some changes I'm making, I was confused by the test failures (failure to find API problems) until I noticed that while the "full" build is completed, the actual job doing the API analysis is blocked because I set a break point there. So the test completes/fails without finding expected problems while I think it should be waiting for the analysis to complete...

image

It seems to me just asking for problems on a build machine where the API analysis might sometimes not be done...

merks commented 2 years ago

Adding this seems to do the trick. @iloveeclipse Does this seem like the right thing to do?

    protected void deployLeakTest(String sourcename, boolean incremantal) {
        try {
            IPath path = WORKSPACE_PATH.append(sourcename);
            createWorkspaceFile(path, TestSuiteHelper.getPluginDirectoryPath().append(TEST_SOURCE_ROOT).append(getTestSourcePath()).append(sourcename));
            if (incremantal) {
                incrementalBuild();
            } else {
                fullBuild();
            }
            Job.getJobManager().join(ApiAnalysisBuilder.ApiAnalysisJob.class, null);  // <<<<<<<<<
            expectingNoJDTProblemsFor(path);
            ApiProblem[] problems = getEnv().getProblemsFor(path, null);
            assertProblems(problems);
        } catch (Exception e) {
            fail(e.getMessage());
        }
    }
iloveeclipse commented 2 years ago

The API analysis shouldn't run in a job during tests, see org.eclipse.pde.api.tools.builder.tests.ApiBuilderTest.beforeClass()

iloveeclipse commented 2 years ago

Does this seem like the right thing to do?

I assume MethodReturnTypeLeak should be converted to JUnit 4+ where BeforeClass is respected.

merks commented 2 years ago

Something like that because that method isn't invoked otherwise...