Bug 43030 - unit tests failing due to misuse of getAbsolutePath()
Summary: unit tests failing due to misuse of getAbsolutePath()
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: IDE (show other bugs)
Version: 1.1.1   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-12 12:59 EDT by Jim Hugunin CLA
Modified: 2003-09-17 03:06 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Hugunin CLA 2003-09-12 12:59:40 EDT
Many of the unit tests in org.aspectj.ajdt.ajc.BuildArgParserTestCase and in
org.aspectj.ajde.StructureModelTest are failing for me.  These failures appear
to be due to the behavior of File.getAbsolutePath().  My suspicion is that these
failures are caused by recent changes to the structure model code to remove
calls to File.getCanonicalPath().

These failures all come under Win XP using either jdk 1.4.2 or jdk 1.3.x from
SUN.  To reproduce the failures, you need to launch eclipse using "-data
c:/path_to_workspace".  Note the lowercase 'c' in the path.  If I change this to
"-data C:/path_to_workspace", then all of the tests will pass.


Here are the traces from two of the failures:

java.lang.IndexOutOfBoundsException: Index: 2, Size: 1
    at java.util.ArrayList.RangeCheck(ArrayList.java:486)
    at java.util.ArrayList.get(ArrayList.java:302)
    at
org.aspectj.ajde.StructureModelTest.testPointcutName(StructureModelTest.java:93)
-----------------------------------------
junit.framework.ComparisonFailure: expected:<c...> but was:<C...>
    at junit.framework.Assert.assertEquals(Assert.java:81)
    at junit.framework.Assert.assertEquals(Assert.java:87)
    at
org.aspectj.ajdt.ajc.BuildArgParserTestCase.testSourceRootDirWithFiles(BuildArgParserTestCase.java:221)

The filenames that are failing to compare above differ only in the initial
capitalization of the 'c', e.g.
c:\aspectj\workspace\org.aspectj.ajdt.core\testdata\ajc\pkg
    and
C:\aspectj\workspace\org.aspectj.ajdt.core\testdata\ajc\pkg
Comment 1 Jim Hugunin CLA 2003-09-12 13:01:51 EDT
I'm raising this to a P1 bug because someone needs to investigate this bug
before the 1.1.1 release.  It's possibly just an issue with the test code;
however, it might also indicate a subtle and dangerous bug in the structure
model code.
Comment 2 Adrian Colyer CLA 2003-09-12 15:00:18 EDT
I confirm I can reproduce the failures. I've investigated all the 
BuildArgParserTestCase ones and they were harmless, but easy to fix - I hate 
failing test cases.

Now looking at the StructureModelTest failures - potentially more serious.

(Just appending progress to save anyone else duplicating work).
Comment 3 Adrian Colyer CLA 2003-09-12 15:37:21 EDT
Now fixed. The StructureModel test cases were indeed hiding a more subtle and 
serious bug - findNodeForSourceFile and findNodeForSourceLine were using
absolute path instead of canonical path to look for matches - and so not finding
corresponding nodes unless the path happened to match. This is the same problem 
that caused Andy to lose his outline view from AJDT.

I changed three files. If anyone has the time to buddy-check my changes 
(sensible precaution this close to ship) I'd appreciate it. The files are:

org.aspectj.asm.internal.AspectJElementHierarchy
org.aspectj.ajdt.ajc.BuildArgParserTestCase
org.aspectj.util.ConfigParser
Comment 4 Adrian Colyer CLA 2003-09-12 15:37:55 EDT
-
Comment 5 Mik Kersten CLA 2003-09-17 03:06:00 EDT
At one point in the past those find methodhs did use canonical paths, but my 
over-optimistic migration to absolute paths changed that.  

I reviewed these changes and they are all correct.