Skip to content

Commit 876078e

Browse files
committed
Enable Tests for GH action
- execute tests but do not fail the build if tests fails - add badge to readme - collect unit test results - add unit test reporting step For MacOS: - use forkCount=1 to enable option startOnFirsThread ... - replace http by https
1 parent f4ca112 commit 876078e

File tree

5 files changed

+73
-25
lines changed

5 files changed

+73
-25
lines changed

.github/workflows/junit.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish Unit Test Results
2+
3+
on:
4+
workflow_run:
5+
workflows: ["SWT Matrix Build"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
unit-test-results:
11+
name: Unit Test Results
12+
runs-on: ubuntu-latest
13+
if: github.event.workflow_run.conclusion == 'success'
14+
15+
steps:
16+
- name: Download and Extract Artifacts
17+
env:
18+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
19+
run: |
20+
mkdir -p artifacts && cd artifacts
21+
22+
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
23+
24+
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
25+
do
26+
IFS=$'\t' read name url <<< "$artifact"
27+
gh api $url > "$name.zip"
28+
unzip -d "$name" "$name.zip"
29+
done
30+
31+
- name: Publish Unit Test Results
32+
uses: EnricoMi/publish-unit-test-result-action@v1
33+
with:
34+
commit: ${{ github.event.workflow_run.head_sha }}
35+
files: "artifacts/**/*.xml"
36+

.github/workflows/maven.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ jobs:
4242
uses: GabrielBB/xvfb-action@v1
4343
with:
4444
run: >-
45-
mvn --batch-mode
46-
-Pbuild-individual-bundles
47-
-Pbuild-individual-platform
48-
-Dswt.build.platform_cp=${{ matrix.config.cp }}
49-
-DforkCount=0
50-
-Dcompare-version-with-baselines.skip=false
51-
-Dmaven.compiler.failOnWarning=true
52-
-DskipTests
45+
mvn --batch-mode
46+
-Pbuild-individual-bundles
47+
-Pbuild-individual-platform
48+
-Dswt.build.platform_cp=${{ matrix.config.cp }}
49+
-DforkCount=1
50+
-Dcompare-version-with-baselines.skip=false
51+
-Dmaven.compiler.failOnWarning=true
52+
-Dmaven.test.failure.ignore=true
5353
clean verify
5454
working-directory: eclipse.platform.swt
55+
- name: Upload Test Results
56+
uses: actions/upload-artifact@v3
57+
with:
58+
name: test-results-${{ matrix.config.native }}
59+
if-no-files-found: error
60+
path: |
61+
${{ github.workspace }}/**/target/surefire-reports/*.xml

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![SWT Matrix Build](https://github.com/eclipse-platform/eclipse.platform.swt/actions/workflows/maven.yml/badge.svg)](https://github.com/eclipse-platform/eclipse.platform.swt/actions/workflows/maven.yml)
2+
13
Contributing to SWT
24
===================
35

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void test_evalute_Cookies () {
151151
browser.addProgressListener(ProgressListener.completedAdapter(event -> loaded.set(true)));
152152

153153
// Using JavaScript Cookie API on local (file) URL gives DOM Exception 18
154-
browser.setUrl("http://www.eclipse.org/swt");
154+
browser.setUrl("https://www.eclipse.org/swt");
155155
shell.open();
156156
waitForPassCondition(loaded::get);
157157

@@ -175,25 +175,25 @@ public void test_ClearAllSessionCookies () {
175175
browser.addProgressListener(ProgressListener.completedAdapter(event -> loaded.set(true)));
176176

177177
// Using JavaScript Cookie API on local (file) URL gives DOM Exception 18
178-
browser.setUrl("http://www.eclipse.org/swt");
178+
browser.setUrl("https://www.eclipse.org/swt");
179179
shell.open();
180180
waitForPassCondition(loaded::get);
181181

182182
// Set the cookies
183-
Browser.setCookie("cookie1=value1", "http://www.eclipse.org/swt");
184-
Browser.setCookie("cookie2=value2", "http://www.eclipse.org/swt");
183+
Browser.setCookie("cookie1=value1", "https://www.eclipse.org/swt");
184+
Browser.setCookie("cookie2=value2", "https://www.eclipse.org/swt");
185185

186186
// Get the cookies
187-
String v1 = Browser.getCookie("cookie1", "http://www.eclipse.org/swt");
188-
String v2 = Browser.getCookie("cookie2", "http://www.eclipse.org/swt");
187+
String v1 = Browser.getCookie("cookie1", "https://www.eclipse.org/swt");
188+
String v2 = Browser.getCookie("cookie2", "https://www.eclipse.org/swt");
189189
assertEquals("value1", v1);
190190
assertEquals("value2", v2);
191191

192192
Browser.clearSessions();
193193

194194
// Should be empty
195-
String e1 = Browser.getCookie("cookie1", "http://www.eclipse.org/swt");
196-
String e2 = Browser.getCookie("cookie2", "http://www.eclipse.org/swt");
195+
String e1 = Browser.getCookie("cookie1", "https://www.eclipse.org/swt");
196+
String e2 = Browser.getCookie("cookie2", "https://www.eclipse.org/swt");
197197
assertTrue(e1 == null || e1.isEmpty());
198198
assertTrue(e2 == null || e2.isEmpty());
199199
}
@@ -206,18 +206,18 @@ public void test_get_set_Cookies() {
206206
browser.addProgressListener(ProgressListener.completedAdapter(event -> loaded.set(true)));
207207

208208
// Using JavaScript Cookie API on local (file) URL gives DOM Exception 18
209-
browser.setUrl("http://www.eclipse.org/swt");
209+
browser.setUrl("https://www.eclipse.org/swt");
210210
shell.open();
211211
waitForPassCondition(loaded::get);
212212

213213
// Set the cookies
214-
Browser.setCookie("cookie1=value1", "http://www.eclipse.org/swt");
215-
Browser.setCookie("cookie2=value2", "http://www.eclipse.org/swt");
214+
Browser.setCookie("cookie1=value1", "https://www.eclipse.org/swt");
215+
Browser.setCookie("cookie2=value2", "https://www.eclipse.org/swt");
216216

217217
// Get the cookies
218-
String v1 = Browser.getCookie("cookie1", "http://www.eclipse.org/swt");
218+
String v1 = Browser.getCookie("cookie1", "https://www.eclipse.org/swt");
219219
assertEquals("value1", v1);
220-
String v2 = Browser.getCookie("cookie2", "http://www.eclipse.org/swt");
220+
String v2 = Browser.getCookie("cookie2", "https://www.eclipse.org/swt");
221221
assertEquals("value2", v2);
222222
}
223223

@@ -849,7 +849,7 @@ public void test_setUrl_remote() {
849849
// This test sometimes times out if build server has a bad connection. Thus for this test we have a longer timeout.
850850
secondsToWaitTillFail = 35;
851851

852-
String url = "http://example.com"; // example.com loads very quickly and conveniently has a consistent title
852+
String url = "https://example.com"; // example.com loads very quickly and conveniently has a consistent title
853853

854854
// Skip this test if we don't have a working Internet connection.
855855
assumeTrue("Skipping test due to bad internet connection", checkInternet(url));
@@ -1455,7 +1455,7 @@ private void getText_helper(String testString, String expectedOutput) {
14551455
@Test
14561456
public void test_stop() {
14571457
/* THIS TEST REQUIRES WEB ACCESS! How else can we really test the http:// part of a browser widget? */
1458-
browser.setUrl("http://www.eclipse.org/swt");
1458+
browser.setUrl("https://www.eclipse.org/swt");
14591459
waitForMilliseconds(1000);
14601460
browser.stop();
14611461
}
@@ -2266,6 +2266,9 @@ void waitForMilliseconds(final int milliseconds) {
22662266
* @return true if server responded with correct code (200), false otherwise.
22672267
*/
22682268
private static Boolean checkInternet(String url) {
2269+
if (url!=null && url.toLowerCase().startsWith("http://")) {
2270+
throw new IllegalArgumentException("please use https instead, http do not work on mac out of the box and your test will hang there!");
2271+
}
22692272
HttpURLConnection connection = null;
22702273
try {
22712274
connection = (HttpURLConnection) new URL(url).openConnection();
@@ -2274,7 +2277,7 @@ private static Boolean checkInternet(String url) {
22742277
if (code == 200)
22752278
return true;
22762279
} catch (MalformedURLException e) {
2277-
System.err.println("Given url is malformed: " + url + "Try a fully formed url like: http://www.example.com");
2280+
System.err.println("Given url is malformed: " + url + "Try a fully formed url like: https://www.example.com");
22782281
e.printStackTrace();
22792282
} catch (IOException e) {
22802283
// No connection was made.

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/memoryleak/Test_Memory_Leak.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void test_Browser() {
5050

5151
for (int i = 1; i <= count; i++) {
5252
browser = new Browser(shell, SWT.None);
53-
browser.setUrl("http://www.google.com");
53+
browser.setUrl("https://www.google.com");
5454
while (display.readAndDispatch()) {
5555
// This loop is needed because some disposal is delayed and done asynchronously in main loop.
5656
// This loop typically performs ~12 iterations.

0 commit comments

Comments
 (0)