Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make LwjglTestStarter accept a test name on the command line #102

Merged
merged 1 commit into from

2 participants

@ttencate

This saves us a click or press of the Enter key when running the same
test over and over again.

@ttencate ttencate Make LwjglTestStarter accept a test name on the command line
This saves us a click or press of the Enter key when running the same
test over and over again.
0bb9127
@badlogic
Owner

Makes sense, though i want to point out there's also LwjglDebugStarter which i use to rerun a specific test :)

@badlogic badlogic merged commit 7c7be46 into libgdx:master
@ttencate

Thanks! Yeah, but I don't like modifying code and then having to remember not to check it in. Command line args for run/debug configurations are stored in the Eclipse settings somewhere and don't end up in the repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 3, 2012
  1. @ttencate

    Make LwjglTestStarter accept a test name on the command line

    ttencate authored
    This saves us a click or press of the Enter key when running the same
    test over and over again.
This page is out of date. Refresh to see the latest.
View
46 tests/gdx-tests-lwjgl/src/com/badlogic/gdx/tests/lwjgl/LwjglTestStarter.java
@@ -54,6 +54,27 @@ public LwjglTestStarter () throws HeadlessException {
setVisible(true);
}
+ /**
+ * Runs the {@link GdxTest} with the given name.
+ *
+ * @param testName the name of a test class
+ * @return {@code true} if the test was found and run, {@code false} otherwise
+ */
+ public static boolean runTest (String testName) {
+ GdxTest test = GdxTests.newTest(testName);
+ if (test == null) {
+ return false;
+ }
+ LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
+ config.width = 640;
+ config.height = 480;
+ config.title = testName;
+ config.useGL20 = test.needsGL20();
+ config.forceExit = false;
+ new LwjglApplication(test, config);
+ return true;
+ }
+
class TestList extends JPanel {
public TestList () {
setLayout(new BorderLayout());
@@ -88,17 +109,10 @@ public void keyPressed (KeyEvent e) {
@Override
public void actionPerformed (ActionEvent e) {
String testName = (String)list.getSelectedValue();
- GdxTest test = GdxTests.newTest(testName);
- dispose();
- LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
- config.width = 640;
- config.height = 480;
- config.title = testName;
- config.useGL20 = test.needsGL20();
- config.forceExit = false;
- new LwjglApplication(test, config);
prefs.putString("last", testName);
prefs.flush();
+ dispose();
+ runTest(testName);
}
});
@@ -110,7 +124,21 @@ public void actionPerformed (ActionEvent e) {
}
}
+ /**
+ * Runs a libgdx test.
+ *
+ * If no arguments are provided on the command line, shows a list of tests to choose from.
+ * If an argument is present, the test with that name will immediately be run.
+ *
+ * @param argv command line arguments
+ */
public static void main (String[] argv) throws Exception {
+ if (argv.length > 0) {
+ if (runTest(argv[0])) {
+ return;
+ // Otherwise, fall back to showing the list
+ }
+ }
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
new LwjglTestStarter();
}
Something went wrong with that request. Please try again.