Bug 204845 - BatchCompilerTest tests fail when the runtime JRE points to a path containing white spaces
Summary: BatchCompilerTest tests fail when the runtime JRE points to a path containing...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 3.3.2   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-27 14:27 EDT by xcok CLA
Modified: 2008-01-24 06:05 EST (History)
2 users (show)

See Also:


Attachments
correcte file against the v_772a_R33x version (188.37 KB, text/plain)
2007-09-27 14:27 EDT, xcok CLA
no flags Details
Fix of test cases (7.57 KB, patch)
2007-10-11 03:16 EDT, Maxime Daniel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description xcok CLA 2007-09-27 14:27:20 EDT
Created attachment 79305 [details]
correcte file against the v_772a_R33x version

Build ID: v_772a_R33x

Steps To Reproduce:
I am running the RunJDTCoreTests in Eclipse 3.3 using the
build cited above.  On my platform a get a dozen test failures in tests within BatchCompilerTest.java .  These were fixed for me with no harm on a Linux platform by editing the tests to be sure that every directory path given as a command-line argument for a -bootclasspath or
-cp option is fully quoted.  Whether these tests fail may depend on the environment variables loperative when Eclipse is started - in my case they have C: and ; in them which often confuses command-line parsers.  I have attached the working edited test file.
Comment 1 Frederic Fusier CLA 2007-09-27 15:51:04 EDT
IMO, not all the quotes you added in BatchCompilerTest are necessary. I think that adding quotes around the library classes in getLibraryClasses() method would be enough.
Maxime, what do you think?
Comment 2 xcok CLA 2007-09-27 22:31:05 EDT
(In reply to comment #1)
> IMO, not all the quotes you added in BatchCompilerTest are necessary. I think
> that adding quotes around the library classes in getLibraryClasses() method
> would be enough.
> Maxime, what do you think?
> 


It is possible they are not all necessary.  When I started editing I went for
some consistency.  However, I do know that at least some of the arguments to -cp were necessary along with some of the arguments to -bootclasspath.
Comment 3 Maxime Daniel CLA 2007-09-28 02:54:36 EDT
I'll dig into this later, but here are my first thoughts. The rationale behind the existing quoting scheme was: whatever enough to get the tests to run on Windows and Linux (plus all platforms tested by nightly builds), which must leave considerable room for improvement and consistency.
A question though: can you please tell us more about your configuration? I'd rather reproduce the problems before taking action (more exactly, depending how much effort this demands, I'd try to mirror your configuration here to avoid getting this bug showing up every once in a while - the experience we have is that BatchCompilerTest needs to be tested on all platforms more often than other suites, and if your configuration is odd enough to break it, we will get it broken often if we cannot test).
Comment 4 xcok CLA 2007-09-28 10:29:05 EDT
(In reply to comment #3)
> I'll dig into this later, but here are my first thoughts. The rationale behind
> the existing quoting scheme was: whatever enough to get the tests to run on
> Windows and Linux (plus all platforms tested by nightly builds), which must
> leave considerable room for improvement and consistency.
> A question though: can you please tell us more about your configuration? I'd
> rather reproduce the problems before taking action (more exactly, depending how
> much effort this demands, I'd try to mirror your configuration here to avoid
> getting this bug showing up every once in a while - the experience we have is
> that BatchCompilerTest needs to be tested on all platforms more often than
> other suites, and if your configuration is odd enough to break it, we will get
> it broken often if we cannot test).


I'm running Eclipse 3.3, launching it from within Cygwin (rather than directly from Windows).  An example of a failing test was test 008 in BatchCompilerTest.  I can make it fail again by taking away the quotes I added around the argument to -cp.  In my environment that argument turns out to be
C:\Program Files\Java\jre1.5.0_02\lib\jce.jar\r\n
The error message I get as actual output is.

Unrecognized option : Files\Java\jre1.5.0_02\lib\jce.jar\r\n

Thus the relevant piece of information, I think, is that the classpath (and in
my case the bootclasspath) contain directories with spaces in their names.  A
colleague of mine also using Cygwin, complete with C: and ; characters but no
spaces did not see these errors.

My JAVA_HOME and the return from System.getProperty("java.home") do not have "Program Files" in the path.  However, the installed JRE (in the Java
Preferences pages) is C:\Program Files\Java\jre1.5.0_02 . I presume this is where the space is coming from.
Comment 5 Maxime Daniel CLA 2007-09-28 12:05:13 EDT
Thanks for the details. I'll need to dig deeper, since I do the same as you do (at least at the surface level: I launch eclipse from a Cygwin terminal since I switched machines a few months ago). I'll comment here as soon as I reach conclusions.
Comment 6 Maxime Daniel CLA 2007-10-11 03:12:43 EDT
The key here is that the runtime JRE path contains one or more white spaces, and this fails both on Windows and Linux (that consistency is expected, since this is our compiler that analyzes the command line the tests pass, not the shell).
Following the suggestion of Frederique, modifying getLibraryClasses and getJCEJar so that they return quoted strings cures the issue. The attached patch also renames them to getLibraryClassesAsQuotedString and getJCEJarAsQuotedString respectively to make clear what they do.
Comment 7 Maxime Daniel CLA 2007-10-11 03:16:24 EDT
Created attachment 80119 [details]
Fix of test cases

The option suggested by Frederique minimizes the changes and makes writing additional tests easier than explicit quoting throughout BatchCompilerTest.java. It also has better chances to protect us from future failures, as long as no test run of nightly builds uses a runtime JRE with a path including white spaces.
Comment 8 Maxime Daniel CLA 2007-10-11 03:32:30 EDT
Released for 3.4M3.
Comment 9 Maxime Daniel CLA 2007-10-11 03:38:23 EDT
Released for 3.3.2.
Comment 10 Frederic Fusier CLA 2007-10-29 12:56:35 EDT
Verified for 3.4M3 using I20071029-0010 build.
Comment 11 Frederic Fusier CLA 2008-01-24 06:05:30 EST
Verified for 3.3.2 using build M20080123-0800.