Bug 560211 - Regression: JUnit Test names are no longer encoded
Summary: Regression: JUnit Test names are no longer encoded
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.14   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: 4.16 M1   Edit
Assignee: Julian Honnen CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks: 231099
  Show dependency tree
 
Reported: 2020-02-17 03:49 EST by Ed Willink CLA
Modified: 2020-04-08 08:28 EDT (History)
5 users (show)

See Also:


Attachments
Repro project (3.14 KB, application/octet-stream)
2020-02-17 03:51 EST, Ed Willink CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2020-02-17 03:49:54 EST
To accomodate the diversity of JUnit/JUnitPlugin Interactive/Tycho testing my tests suffix their names with <standalone> / <plugin> / <maven> / <tycho>.

This is ok wrt running / viewing tests but no longer allows a particular failing test to be rerun.

With the attached project, Run the NameBugPlugin.launch.
- test passes and is named "MyTest <plugin>"

Select "MyTest <plugin>" and Run
- dialog pops up

< is an invalid character in resource name 'Rerun NameBug.MyTest <plugin>.launch'.

Since this used to work, I presume the encoding of awkward characters has been removed.
Comment 1 Ed Willink CLA 2020-02-17 03:51:09 EST
Created attachment 281833 [details]
Repro project

Maybe the attachment will attach this time.
Comment 2 Sarika Sinha CLA 2020-02-17 04:01:24 EST
Since which Eclipse version do you see it broken?
Comment 3 Ed Willink CLA 2020-02-17 06:18:08 EST
I think it is new in 2019-12, but can't be sure since mostly I relaunch Junit rather than JUnitPlugin tests.

Going back to 2019-03, it works (once I disable MalformedURLExceptions that occur for the "." on the bad start path).
Comment 4 Ed Willink CLA 2020-02-17 06:51:57 EST
I don't have a 4.13 (2018-09) to hand but using 4.13RC1, the re-Run of

"testOkAssignPrecedences <plugin>" from the "org.eclipse.ocl.examples.xtext.tests (plugin)" launch

JUnit View works.

So 4.11 ok, 4.13RC1 ok, 4.14 bad encoding.
Comment 5 Sarika Sinha CLA 2020-02-17 09:33:18 EST
@Andrey,
Looks impact of some platform change ? Are you aware of any change?
Comment 6 Andrey Loskutov CLA 2020-02-17 09:58:13 EST
(In reply to Sarika Sinha from comment #5)
> @Andrey,
> Looks impact of some platform change ? Are you aware of any change?

Not immediately (of course we've updated JUnit may be).

But my problem is that I can't reproduce this bug on RHEL 7.4 / Java 8 + Java 11.

I run the "selected" test both as "JUNit test", and "JUnit Plug-in test" without issues.

Ed, do you see some errors reported in the error log? Can you attach it?
Comment 7 Ed Willink CLA 2020-02-17 11:09:36 EST
There is tons in the error log but nothing that seems related.

To me the problem is very simple.

Once "testOkAssignPrecedences <plugin>" is naively turned into a Windows file name for an internal launch file, it is illegal and that causes the failure.

The regression is whether the internal launch file is new, or whether the internal file was never exposed to Windows, or whether it was actually 'encoded'.

Since IIRC my choice of <> as delimiters was driven by [] being mis-understood as parameters and () as bad Windows characters, it may just be that JUnit5 introduces a change in the <> treatment.
Comment 8 Sarika Sinha CLA 2020-02-27 00:18:25 EST
It works on Mac as well. Will try on Windows 10 to see if I can reproduce.
Comment 9 Sarika Sinha CLA 2020-02-27 00:39:34 EST
It works on Windows with 4.12 and 4.13 but I was able to reproduce on the latest build. 
So looks like a regression from 4.14.
Comment 10 Sarika Sinha CLA 2020-02-28 06:11:30 EST
From org.eclipse.core.internal.resources.OS :
if (INSTALLED_PLATFORM.equals(Platform.OS_WIN32)) {
			//valid names and characters taken from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/naming_a_file.asp
			INVALID_RESOURCE_CHARACTERS = new char[] {'\\', '/', ':', '*', '?', '"', '<', '>', '|'};


I did not investigate as to how it was working before, may be some bug but I think "<" is not a valid resource character and hence org.eclipse.core.internal.resources.LocationValidator.validateName(String, int) throws this error.

I don't think this can be fixed, if anyone else has any suggestion please reopen the bug with details.
Comment 11 Ed Willink CLA 2020-02-28 06:54:26 EST
It did work before so it is a regression.

There is no Microsoft specification on the spelling of JUnit test names.

The problem lies in one of

- The naive assumption that the test name can be used unchecked as a Microsoft file name.

- The naive assumption that a test name can be saved in a file such as a *.launch without checking.

This is a very well known problem. Whenever any arbitrary text is stored in XML it must be encoded using e.g. &lt; to satisfy the XML specification. Here too when the test name is used in a restrictive context, it must be adequately encoded.

Presumably it worked before because

- a longstanding encoding failure is only now detected

- a new encoding opportunity has been introduced and overlooked
Comment 12 Sarika Sinha CLA 2020-02-28 14:50:44 EST
It is actually no encoding change which has caused this.
It is caused by a change in Bug 231099.

org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper.migrateLaunchConfiguration(ILaunchConfiguration)

is now saving the Launching working copy if it was dirty instead of the previous check :
if (save && (value != null || value2 != null || upgrade))

Moving to PDE UI .
Comment 13 Vikas Chandra CLA 2020-03-02 00:06:13 EST
Julian, can you please have a look?
Comment 14 Julian Honnen CLA 2020-03-02 03:45:28 EST
The issue is that PDE saves a launch configuration that was meant to be temporary. Apart from the invalid character issue, this also pollutes the workspace with temporary launch configs.

That could have happened before, when a migration was necessary, but is now triggered every time making this issue more apparent.


I don't see a safe quickfix here for RC2. We need to remove the saving completely during launch and always migrate on-the-fly. Only in the launch config dialog can the migrated config be saved.
Comment 15 Vikas Chandra CLA 2020-03-02 04:17:00 EST
(In reply to Julian Honnen from comment #14)
> The issue is that PDE saves a launch configuration that was meant to be
> temporary. Apart from the invalid character issue, this also pollutes the
> workspace with temporary launch configs.
> 
> That could have happened before, when a migration was necessary, but is now
> triggered every time making this issue more apparent.
> 
> 
> I don't see a safe quickfix here for RC2. We need to remove the saving
> completely during launch and always migrate on-the-fly. Only in the launch
> config dialog can the migrated config be saved.

Thanks Julian, for your investigation and quick assessment for this bug.
Comment 16 Eclipse Genie CLA 2020-03-20 05:05:52 EDT
New Gerrit change created: https://git.eclipse.org/r/159776
Comment 17 Eclipse Genie CLA 2020-03-20 05:05:54 EDT
New Gerrit change created: https://git.eclipse.org/r/159775
Comment 20 Andrey Loskutov CLA 2020-03-24 12:00:33 EDT
(In reply to Julian Honnen from comment #14)
> The issue is that PDE saves a launch configuration that was meant to be
> temporary. Apart from the invalid character issue, this also pollutes the
> workspace with temporary launch configs.
> 
> That could have happened before, when a migration was necessary, but is now
> triggered every time making this issue more apparent.

The "now" is caused by which change? 

I see a crazy error in 4.15 where previously saved launch configs with tracing enabled are automatically re-written on first time opening the launch config dialog, and all the tracing data is gone.
Comment 21 Julian Honnen CLA 2020-03-24 12:15:54 EDT
(In reply to Andrey Loskutov from comment #20)
> The "now" is caused by which change? 
bug 231099, specifically https://git.eclipse.org/r/c/151702/6/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/BundleLauncherHelper.java#590

> I see a crazy error in 4.15 where previously saved launch configs with
> tracing enabled are automatically re-written on first time opening the
> launch config dialog, and all the tracing data is gone.
I think that's a different issue. Opening the launch config dialog does (and did before) also trigger a save when dirty. The bigger question is, why the tracing data is lost, not why the config is saved, I think.
Comment 22 Andrey Loskutov CLA 2020-03-24 13:17:49 EDT
(In reply to Julian Honnen from comment #21)
> (In reply to Andrey Loskutov from comment #20)
> > The "now" is caused by which change? 
> bug 231099, specifically
> https://git.eclipse.org/r/c/151702/6/ui/org.eclipse.pde.launching/src/org/
> eclipse/pde/internal/launching/launcher/BundleLauncherHelper.java#590
> 
> > I see a crazy error in 4.15 where previously saved launch configs with
> > tracing enabled are automatically re-written on first time opening the
> > launch config dialog, and all the tracing data is gone.
> I think that's a different issue. Opening the launch config dialog does (and
> did before) also trigger a save when dirty. The bigger question is, why the
> tracing data is lost, not why the config is saved, I think.

I've created bug 561424.
Comment 23 Vikas Chandra CLA 2020-04-08 08:13:33 EDT
Julian, can you please verify this fix?
Comment 24 Julian Honnen CLA 2020-04-08 08:28:33 EDT
verified with project from comment 1 on
Version: 2020-06 (4.16)
Build id: I20200407-1800