/hg/gfx-test: Added support for "filtering" tests by pattern con...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Tue Jan 15 02:55:41 PST 2013


changeset 5fa3a63c40a8 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=5fa3a63c40a8
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Jan 15 11:58:47 2013 +0100

	Added support for "filtering" tests by pattern containing part of its names.


diffstat:

 ChangeLog                                           |   8 ++++
 src/org/gfxtest/common/Configuration.java           |   2 +-
 src/org/gfxtest/framework/GfxTest.java              |  17 +++++++-
 src/org/gfxtest/framework/GfxTestConfiguration.java |  41 ++++++++++++++++++++-
 4 files changed, 64 insertions(+), 4 deletions(-)

diffs (146 lines):

diff -r 2a073104d1e2 -r 5fa3a63c40a8 ChangeLog
--- a/ChangeLog	Mon Jan 14 11:13:54 2013 +0100
+++ b/ChangeLog	Tue Jan 15 11:58:47 2013 +0100
@@ -1,3 +1,11 @@
+2013-01-15  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/common/Configuration.java:
+	* src/org/gfxtest/framework/GfxTest.java:
+	* src/org/gfxtest/framework/GfxTestConfiguration.java:
+	Added support for "filtering" tests by pattern containing part of its
+	names.
+
 2013-01-14  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/testsuites/BitBltUsingBgColor.java:
diff -r 2a073104d1e2 -r 5fa3a63c40a8 src/org/gfxtest/common/Configuration.java
--- a/src/org/gfxtest/common/Configuration.java	Mon Jan 14 11:13:54 2013 +0100
+++ b/src/org/gfxtest/common/Configuration.java	Tue Jan 15 11:58:47 2013 +0100
@@ -1,7 +1,7 @@
 /*
   Java gfx-test framework
 
-   Copyright (C) 2010, 2011, 2012  Red Hat
+   Copyright (C) 2010, 2011, 2012, 2013  Red Hat
 
 This file is part of IcedTea.
 
diff -r 2a073104d1e2 -r 5fa3a63c40a8 src/org/gfxtest/framework/GfxTest.java
--- a/src/org/gfxtest/framework/GfxTest.java	Mon Jan 14 11:13:54 2013 +0100
+++ b/src/org/gfxtest/framework/GfxTest.java	Tue Jan 15 11:58:47 2013 +0100
@@ -1,7 +1,7 @@
 /*
   Java gfx-test framework
 
-   Copyright (C) 2010, 2011, 2012  Red Hat
+   Copyright (C) 2010, 2011, 2012, 2013  Red Hat
 
 This file is part of IcedTea.
 
@@ -460,8 +460,21 @@
      */
     private void tryToInvokeTestMethod(TestType testType, GfxTestConfiguration configuration, Method method)
     {
+        // read method name
         String methodName = method.getName();
-        if (method.getName().startsWith("test")) //$NON-NLS-1$
+        // read test filter
+        String filter = configuration.getFilter();
+
+        // filter out test methods whose names don't contain given pattern
+        if (filter != null)
+        {
+            // test name does not contains given pattern
+            if (!methodName.contains(filter))
+            {
+                return;
+            }
+        }
+        if (methodName.startsWith("test")) //$NON-NLS-1$
         {
             this.log.logBegin(methodName);
             switch (testType.value())
diff -r 2a073104d1e2 -r 5fa3a63c40a8 src/org/gfxtest/framework/GfxTestConfiguration.java
--- a/src/org/gfxtest/framework/GfxTestConfiguration.java	Mon Jan 14 11:13:54 2013 +0100
+++ b/src/org/gfxtest/framework/GfxTestConfiguration.java	Tue Jan 15 11:58:47 2013 +0100
@@ -1,7 +1,7 @@
 /*
   Java gfx-test framework
 
-   Copyright (C) 2010, 2011  Red Hat
+   Copyright (C) 2010, 2011, 2012, 2013  Red Hat
 
 This file is part of IcedTea.
 
@@ -105,6 +105,12 @@
     private int imageType;
 
     /**
+     * Filter, ie. part of test name. Only tests which contains this pattern
+     * in its names will be run.
+     */
+    private String filter;
+
+    /**
      * Constructor called indirectly when the test suite are started.
      * 
      * @param args
@@ -132,6 +138,7 @@
         this.imageHeight = processImageHeightArgument(options);
         this.imageType = processImageTypeArgument(options);
         this.outputPath = processOutputPathArgument(options);
+        this.filter = processFilter(options);
     }
 
     /**
@@ -224,6 +231,27 @@
     }
 
     /**
+     * Process argument used for setting test filter.
+     *
+     * @param options
+     *            command line options
+     * @return test filter
+     * @throws ConfigurationException when configuration is wrong
+     */
+    private String processFilter(Map<String, String> options) throws ConfigurationException
+    {
+        try
+        {
+            return getStringParameter(options, "f"); //$NON-NLS-1$
+        }
+        catch (ParameterNotFoundException e)
+        {
+            this.log.logWarning("filter not specified in command line, using default setting: null");
+            return null;
+        }
+    }
+
+    /**
      * This method prints all test suite parameters.
      */
     @Override
@@ -234,6 +262,7 @@
         this.log.logSet("image width", Integer.valueOf(this.imageWidth));
         this.log.logSet("image height", Integer.valueOf(this.imageHeight));
         this.log.logSet("image type", Integer.valueOf(this.imageType));
+        this.log.logSet("filter", this.filter);
     }
 
     /**
@@ -310,4 +339,14 @@
         return this.imageType;
     }
 
+    /**
+     * Getter for filter attribute.
+     * 
+     * @return current value of attribute filter.
+     */
+    public String getFilter()
+    {
+        return this.filter;
+    }
+
 }



More information about the distro-pkg-dev mailing list