Bug 101022 - [search] JUnit Test Runner on folder runs tests outside directory
Summary: [search] JUnit Test Runner on folder runs tests outside directory
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC4   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-21 07:44 EDT by Jozef Hovan CLA
Modified: 2005-06-24 07:12 EDT (History)
3 users (show)

See Also:


Attachments
Testing project (1.56 KB, application/octet-stream)
2005-06-21 07:47 EDT, Jozef Hovan CLA
no flags Details
Patch to fix this issue (1.94 KB, patch)
2005-06-22 08:10 EDT, Frederic Fusier CLA
no flags Details | Diff
Minimal patch to fix this issue (1.70 KB, patch)
2005-06-22 09:31 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jozef Hovan CLA 2005-06-21 07:44:18 EDT
We have project with 3 source folders - src, test, test2. When you are running
test on test folder (through right click on folder -> run as -> JUnitTest,
eclipse starts also some tests, which are in test2 folder.
Comment 1 Frederic Fusier CLA 2005-06-21 07:47:22 EDT
Move to JDT/UI
Comment 2 Jozef Hovan CLA 2005-06-21 07:47:23 EDT
Created attachment 23605 [details]
Testing project

Testing project containing bug situation. When you open this project, click on
test -> Run As -> JUnit Tests, it will run a test located in
test2/mypackage/MyTestCase.
Comment 3 Dirk Baeumer CLA 2005-06-21 16:58:20 EDT
It looks like that the problem lies in the search engine reporting matches
although they are not contained in the scope.
Comment 4 Dirk Baeumer CLA 2005-06-21 17:52:50 EDT
The JUnit launcher uses the search engine to search for class having a suite
method. To reproduce the problem using search only do the following:

- install the attached project
- select source folder test
- open search dialog
- type in >>suite() Test<< in the pattern field
- select method and declaration
- as scope select "Selected Resource"

observe: it finds one match in test2 source folder

Setting a breakpoint in SearchEngine#search shows that the correct search scope
was created. It is:

JavaSearchScope on [
	/testbug/test
]

Renaming test2 to tesx2 doesn't find any matches. So this seems to be a prefix
problem.

Moving to JDT/Core
Comment 5 Frederic Fusier CLA 2005-06-22 06:39:50 EDT
I confirm this is a JavaSearchScope issue with prefixes.

Currently when selecting "Selected Resources", created JavaSearchScope includes
sub-folders. While verifying if scope encloses an element, it just look if its
path starts with scope path. That's why currently it (wrongly) returns true
while asking if  "test" scope encloses "test2/mypackage/MyTestCase.java".
Comment 6 Frederic Fusier CLA 2005-06-22 07:12:07 EDT
Unfortunately, this is a regression from 3.0.2 since JavaSearchScope uses
Strings instead of IPaths for paths.
I'm currently testing a possible fix...
Comment 7 Frederic Fusier CLA 2005-06-22 08:10:10 EDT
Created attachment 23720 [details]
Patch to fix this issue

Rewrite enclosing test to take verify that even if path starts with scope path,
rest of path is a *real* sub-folder...

This patch pass all JavaModel tests.
Comment 8 Philipe Mulet CLA 2005-06-22 09:26:14 EDT
Please provide the minimal patch we discussed (reviewed by Jerome&Philippe).

Since the fix is quite simple, and it is a regression; we will candidate it for RC4.

Dirk/Dani : pls cast your votes.
Comment 9 Frederic Fusier CLA 2005-06-22 09:31:06 EDT
Created attachment 23726 [details]
Minimal patch to fix this issue

I've added TODO to apply similar change post 3.1 even if not looking at
subfolders
Comment 10 Dani Megert CLA 2005-06-22 10:12:55 EDT
+1 for 3.1 RC4
Comment 11 Frederic Fusier CLA 2005-06-22 10:48:51 EDT
Comment 9 Minimal patch released in HEAD.

All JDT/Core and JDT/UI tests pass.

Specific test #testJavaSearchScopeBug101022 added in
JavaSearchMultipleProjectsTests.
Comment 12 Maxime Daniel CLA 2005-06-24 07:04:13 EDT
Verified for Build id: I20050624-0010.