Bug 518379 - Allow platform specific JUnit tests
Summary: Allow platform specific JUnit tests
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.8   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 4.8 M1   Edit
Assignee: Conrad Groth CLA
QA Contact:
URL:
Whiteboard:
Keywords: test
Depends on:
Blocks:
 
Reported: 2017-06-16 09:25 EDT by Conrad Groth CLA
Modified: 2017-08-01 10:48 EDT (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Conrad Groth CLA 2017-06-16 09:25:58 EDT
I wrote a test for the FileTransfer class, which is platform independent; but to provide some test TransferData, I need to instantiate platform specific classes, e.g. org.eclipse.swt.internal.ole.win32.FORMATETC for windows.

It would be nice, to have additional test artifacts for the three supported platforms, e.g.:
org.eclipse.swt.tests.gtk
org.eclipse.swt.tests.win32
org.eclipse.swt.tests.cocoa
Comment 1 Conrad Groth CLA 2017-06-16 09:30:54 EDT
Is there anybody, who knows how to add a new module, that doesn't crashes the integration builds because of platform dependent code?

I think, we should use this bug to provide the 'infrastructure' for platform specific tests. Right now, I only have one test class for Windows. But I know that Leo Ufimtsev has some gtk specific tests to share.
Comment 2 Conrad Groth CLA 2017-06-16 09:33:13 EDT
(In reply to Conrad Groth from comment #1)
> But I know that Leo Ufimtsev has some gtk specific tests to share.
It wasn't Leo, but Eric Williams
Comment 3 Ian Pun CLA 2017-06-16 10:11:24 EDT
I've added Eric to CC on this
Comment 4 Eclipse Genie CLA 2017-06-17 09:34:08 EDT
New Gerrit change created: https://git.eclipse.org/r/99534
Comment 5 Conrad Groth CLA 2017-06-17 09:35:34 EDT
The patch is ready for review.
Comment 6 Eric Williams CLA 2017-06-19 10:01:23 EDT
Leo and I have been discussing this for awhile. One/both of us will take a look at your patch within the next few days.
Comment 7 Leo Ufimtsev CLA 2017-06-19 10:58:52 EDT
I like the patch you submitted. Looks good to me.

I'm not sure if it breaks builds, I don't see why it would, but I'm not a builder guy.
Comment 8 Niraj Modi CLA 2017-06-20 02:17:48 EDT
(In reply to Eclipse Genie from comment #4)
> New Gerrit change created: https://git.eclipse.org/r/99534

Looks good, few suggestions:
Similar to org.eclipse.swt.tests.junit.AllTests.java we should add below parent test suite class per platform:
AllWindowsTests.java
AllGTKTests.java
AllCocoaTests.java

Also, it would be interesting if we could trigger above platform specific tests directly from AllTests.java [Note: SwtTestUtil.java helps identify the platforms]
Comment 9 Eric Williams CLA 2017-06-20 10:18:19 EDT
(In reply to Niraj Modi from comment #8)
> (In reply to Eclipse Genie from comment #4)
> Similar to org.eclipse.swt.tests.junit.AllTests.java we should add below
> parent test suite class per platform:
> AllWindowsTests.java
> AllGTKTests.java
> AllCocoaTests.java
> 
> Also, it would be interesting if we could trigger above platform specific
> tests directly from AllTests.java [Note: SwtTestUtil.java helps identify the
> platforms]

+1 to this idea.
Comment 10 Leo Ufimtsev CLA 2017-06-22 11:35:58 EDT
(In reply to Niraj Modi from comment #8)
> (In reply to Eclipse Genie from comment #4)
> > New Gerrit change created: https://git.eclipse.org/r/99534
> 
> Looks good, few suggestions:
> Similar to org.eclipse.swt.tests.junit.AllTests.java we should add below
> parent test suite class per platform:
> AllWindowsTests.java
> AllGTKTests.java
> AllCocoaTests.java

I added these three to the patch.

> Also, it would be interesting if we could trigger above platform specific
> tests directly from AllTests.java [Note: SwtTestUtil.java helps identify the
> platforms]

I experimented with this. Technically sort of possible, but the only way I got it to work involves having all projects open at all times. Where as I imagine a Gtk developer would probably only want AllTests and AllGtkTests and not Cocoa/Win32 tests to be around.

Like, I can't think of a 'dynamic' way of achieving this in such a way that only all.tests and gtk.test would be open without all.tests complaining about missing dependencies? (Mind you I don't know plugin dependency model that well).
~Suggestions are welcome.

With that said, this can be achieved via LaunchGroups. With one launch group launch AllTests and AllGtk tests.

If there are no objections, I'll go ahead and merge the patch. Further enhancements can be added as we go.
Comment 11 Eric Williams CLA 2017-06-22 11:38:15 EDT
(In reply to Leo Ufimtsev from comment #10)
> (In reply to Niraj Modi from comment #8)
> > (In reply to Eclipse Genie from comment #4)
> > > New Gerrit change created: https://git.eclipse.org/r/99534
> > 
> > Looks good, few suggestions:
> > Similar to org.eclipse.swt.tests.junit.AllTests.java we should add below
> > parent test suite class per platform:
> > AllWindowsTests.java
> > AllGTKTests.java
> > AllCocoaTests.java
> 
> I added these three to the patch.
> 
> > Also, it would be interesting if we could trigger above platform specific
> > tests directly from AllTests.java [Note: SwtTestUtil.java helps identify the
> > platforms]
> 
> I experimented with this. Technically sort of possible, but the only way I
> got it to work involves having all projects open at all times. Where as I
> imagine a Gtk developer would probably only want AllTests and AllGtkTests
> and not Cocoa/Win32 tests to be around.
> 
> Like, I can't think of a 'dynamic' way of achieving this in such a way that
> only all.tests and gtk.test would be open without all.tests complaining
> about missing dependencies? (Mind you I don't know plugin dependency model
> that well).
> ~Suggestions are welcome.
> 
> With that said, this can be achieved via LaunchGroups. With one launch group
> launch AllTests and AllGtk tests.
> 
> If there are no objections, I'll go ahead and merge the patch. Further
> enhancements can be added as we go.

+1 for merging now, we can add additional functionality later.
Comment 13 Leo Ufimtsev CLA 2017-06-22 12:35:20 EDT
Patch merged. Tests can now be added to those projects. (I would suggest new bug submissions.

@Conrad, thank you for your work on this.
Comment 14 Eclipse Genie CLA 2017-06-24 03:29:01 EDT
New Gerrit change created: https://git.eclipse.org/r/99988
Comment 16 Leo Ufimtsev CLA 2017-07-04 17:05:00 EDT
Hey ya, 

I think there may be an issue with the root pom:

    <profile>
      <id>unix</id>
      <activation>
        <os>
          <family>unix</family>
        </os>
      </activation>
	  <modules>
	    <module>tests/org.eclipse.swt.tests.gtk</module>
	  </modules>
    </profile>

Cocoa is categorized as "Unix", and thus this profile is activated on Cocoa, where as it should only run on Linux.

@Conrad, I don't know much about pom/os.family. Is there a "Linux" os family? Maybe we should change that to be linux instead of unix? Thoughts?
Comment 17 Eclipse Genie CLA 2017-07-07 12:15:53 EDT
New Gerrit change created: https://git.eclipse.org/r/100934
Comment 19 Leo Ufimtsev CLA 2017-07-07 12:20:39 EDT
(In reply to Leo Ufimtsev from comment #16)
> Hey ya, 
> 
> I think there may be an issue with the root pom:
> 
>     <profile>
>       <id>unix</id>
>       <activation>
>         <os>
>           <family>unix</family>
>         </os>
>       </activation>
> 	  <modules>
> 	    <module>tests/org.eclipse.swt.tests.gtk</module>
> 	  </modules>
>     </profile>
> 
> Cocoa is categorized as "Unix", and thus this profile is activated on Cocoa,
> where as it should only run on Linux.
> 
> @Conrad, I don't know much about pom/os.family. Is there a "Linux" os
> family? Maybe we should change that to be linux instead of unix? Thoughts?

I fixed it in:

(In reply to Eclipse Genie from comment #18)
> Gerrit change https://git.eclipse.org/r/100934 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=e2b6b9c9d7134d4747c6389573923e6efa92b1de

We're good to go.