Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ec1d4f50ebb2fe4144072ed5432a30cf41224af2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package org.eclipse.swt.tests.junit;

import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;


/**
 * This java file is intended to be used with the bash script "gtk_version_tests.sh" normally found in:
 * ~/git/eclipse.platform.swt/tests/org.eclipse.swt.tests/
 *
 * To run this from the command line:
 * 1) Ensure 'junit' package is installed on your system. (ex: sudo dnf install junit junit-javadoc)
 * 2) Run via: (Assuming your eclipse git repositories are in $HOME/git)
REPO=$HOME/git
ARG=AllNonBrowserTests
java -Djava.library.path=$REPO/eclipse.platform.swt.binaries/bundles/org.eclipse.swt.gtk.linux.x86_64   -Dfile.encoding=UTF-8   -classpath /usr/share/java/junit.jar:/usr/share/java/hamcrest/core.jar:$REPO/eclipse.platform.swt/bundles/org.eclipse.swt/bin:$REPO/eclipse.platform.swt/tests/org.eclipse.swt.tests/bin org.eclipse.swt.tests.junit.CmdLineInterface $ARG

 * TODO someday: generalize this so that any class#method can be ran:
 * http://stackoverflow.com/questions/9288107/run-single-test-from-a-junit-class-using-command-line
 *
 * It is intended to run SWT JUnit tests on multiple GTK versions in batch. Ex GTK2.24, GTK3.14 GTK3.16 etc..
 * This is convenient for patch submissions/reviews.
 *
 * For more details, see: https://wiki.eclipse.org/SWT/Devel/Gtk/JUnitTests#Running_jUnit_tests_across_multiple_versions_of_GTK
 *
 * @author For questions/bug reports: Leo Ufimtsev lufimtse@redhat.com, 2016.
 */
public class CmdLineInterface {

	public static void main(String[] args) {

		Result result = null;

		result = runTests(args, result);

		printResults(result);
	}

	private static Result runTests(String[] args, Result result) {
		if (args[0].equals("AllNonBrowserTests")) {
			result = JUnitCore.runClasses(AllNonBrowserTests.class);
		} else {
			System.out.println("ERROR: Incorrect paramaters were given. See file. ex: AllNonBrowserTests");
		}
		return result;
	}

	private static void printResults(Result result) {
		System.out.println("    ~~ SUMMARY ~~");

		String gtkVersion = System.getProperty("org.eclipse.swt.internal.gtk.version");

		if (result.wasSuccessful()) {
			System.out.println("    " + gtkVersion + " GTK_TEST_RESULT : ALL TESTS PASS");
		} else {
			System.out.println("    " + gtkVersion + " GTK_TEST_RESULT : SOME TESTS FAIL: " + result.getFailureCount() + " / " + result.getRunCount());
			int i = 1;
			for (Failure failure : result.getFailures()) {
				System.out.print("    " + i + ": ");
				System.out.println(failure.toString());
				i++;
			}
		}
		System.out.println("");
	}




}

Back to the top