public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
* new -file option to SimpleTestHarness
@ 2002-12-19  3:33 Raif S. Naffah
  2002-12-19  8:04 ` Brian Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Raif S. Naffah @ 2002-12-19  3:33 UTC (permalink / raw)
  To: Mauve

-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

hello there,

i'd like to propose the following patch to SimpleTestHarness to
allow invoking the harness with the test classes file as one of its
arguments.  i.e. in addition to:

echo test_classes | \
$(JAVA) -cp ... gnu.testlet.SimpleTestHarness -verbose -debug

one can also do

$(JAVA) -cp ... gnu.testlet.SimpleTestHarness -file test_classes



$ diff -u -wb -B \
../mauve/mauve/gnu/testlet/SimpleTestHarness.java \
source/gnu/testlet/SimpleTestHarness.java
- --- ../mauve/mauve/gnu/testlet/SimpleTestHarness.java   2002-11-15 20:05:47.000000000 +1100
+++ source/gnu/testlet/SimpleTestHarness.java   2002-12-17 20:20:08.000000000 +1100
@@ -286,6 +286,7 @@
       boolean verbose = false;
       boolean debug = false;
       boolean results_only = false;
+      String file = null;
       int i;

       for (i = 0; i < args.length; i++)
@@ -300,6 +301,17 @@
              verbose = false;
              debug = false;
            }
+          else if (args[i].equalsIgnoreCase("-file"))
+            try
+            {
+              file = args[++i];
+            }
+            catch (Exception x)
+            {
+              if (verbose)
+                System.err.println ("Exception while processing '-file' option: "
+                    +String.valueOf(x)+". Ignored");
+            }
          else
            break;
         }
@@ -307,8 +319,22 @@
       SimpleTestHarness harness
        = new SimpleTestHarness (verbose, debug, results_only);

- -      BufferedReader r
- -       = new BufferedReader (new InputStreamReader (System.in));
+      BufferedReader r = null;
+      boolean ok = false;
+      if (file != null)
+        try
+        {
+          r = new BufferedReader (new FileReader (file));
+          ok = true;
+        }
+        catch (FileNotFoundException x)
+        {
+          if (verbose)
+            System.err.println ("File not found: "+String.valueOf(file)
+                +". Revert to stdin");
+        }
+      if (!ok)
+        r = new BufferedReader (new InputStreamReader (System.in));
       while (true)
        {
          String cname = null;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Que du magnifique

iD8DBQE+Aa6v+e1AKnsTRiERA1W5AKCCknNAyVALWbTmi0SArijzY0RgAgCfTCJm
2nln26oLuKGi5kO7j2PNQcM=
=iNwl
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: new -file option to SimpleTestHarness
  2002-12-19  3:33 new -file option to SimpleTestHarness Raif S. Naffah
@ 2002-12-19  8:04 ` Brian Jones
  2002-12-19 10:21   ` Raif S. Naffah
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Jones @ 2002-12-19  8:04 UTC (permalink / raw)
  To: raif; +Cc: Mauve

"Raif S. Naffah" <raif@fl.net.au> writes:

> hello there,
> 
> i'd like to propose the following patch to SimpleTestHarness to
> allow invoking the harness with the test classes file as one of its
> arguments.  i.e. in addition to:

Ok.

> 
> echo test_classes | \
> $(JAVA) -cp ... gnu.testlet.SimpleTestHarness -verbose -debug
> 
> one can also do
> 
> $(JAVA) -cp ... gnu.testlet.SimpleTestHarness -file test_classes
> 
> 
> 
> $ diff -u -wb -B \
> ../mauve/mauve/gnu/testlet/SimpleTestHarness.java \
> source/gnu/testlet/SimpleTestHarness.java
> --- ../mauve/mauve/gnu/testlet/SimpleTestHarness.java   2002-11-15 20:05:47.000000000 +1100
> +++ source/gnu/testlet/SimpleTestHarness.java   2002-12-17 20:20:08.000000000 +1100
> @@ -286,6 +286,7 @@
>        boolean verbose = false;
>        boolean debug = false;
>        boolean results_only = false;
> +      String file = null;
>        int i;
> 
>        for (i = 0; i < args.length; i++)
> @@ -300,6 +301,17 @@
>               verbose = false;
>               debug = false;
>             }
> +          else if (args[i].equalsIgnoreCase("-file"))
> +            try
> +            {
> +              file = args[++i];
> +            }
> +            catch (Exception x)
> +            {
> +              if (verbose)
> +                System.err.println ("Exception while processing '-file' option: "
> +                    +String.valueOf(x)+". Ignored");
> +            }
>           else
>             break;
>          }
> @@ -307,8 +319,22 @@
>        SimpleTestHarness harness
>         = new SimpleTestHarness (verbose, debug, results_only);

You need to get rid of this BufferedReader r = new ... before your additions.
If the file argument is given and the file does not exist, report the
error and exit maybe... ?  Failing over to stdin doesn't seem logical.

> 
>      BufferedReader r
>       = new BufferedReader (new InputStreamReader (System.in));
> +      BufferedReader r = null;
> +      boolean ok = false;
> +      if (file != null)
> +        try
> +        {
> +          r = new BufferedReader (new FileReader (file));
> +          ok = true;
> +        }
> +        catch (FileNotFoundException x)
> +        {
> +          if (verbose)
> +            System.err.println ("File not found: "+String.valueOf(file)
> +                +". Revert to stdin");
> +        }
> +      if (!ok)
> +        r = new BufferedReader (new InputStreamReader (System.in));
>        while (true)
>         {
>           String cname = null;
> 
> 

-- 
Brian Jones <cbj@gnu.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: new -file option to SimpleTestHarness
  2002-12-19  8:04 ` Brian Jones
@ 2002-12-19 10:21   ` Raif S. Naffah
  0 siblings, 0 replies; 3+ messages in thread
From: Raif S. Naffah @ 2002-12-19 10:21 UTC (permalink / raw)
  To: Brian Jones; +Cc: Mauve

-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

On Friday 20 December 2002 03:04, Brian Jones wrote:
> ...
> You need to get rid of this BufferedReader r = new ... before your
> additions. If the file argument is given and the file does not exist,
> report the error and exit maybe... ?  Failing over to stdin doesn't
> seem logical.

diff -u -wb -B ../mauve/mauve/gnu/testlet/SimpleTestHarness.java source/gnu/testlet/SimpleTestHarness.java
- --- ../mauve/mauve/gnu/testlet/SimpleTestHarness.java   2002-11-15 20:05:47.000000000 +1100
+++ source/gnu/testlet/SimpleTestHarness.java   2002-12-20 05:16:26.000000000 +1100
@@ -286,6 +286,7 @@
       boolean verbose = false;
       boolean debug = false;
       boolean results_only = false;
+      String file = null;
       int i;

       for (i = 0; i < args.length; i++)
@@ -300,6 +301,15 @@
              verbose = false;
              debug = false;
            }
+          else if (args[i].equalsIgnoreCase("-file"))
+            try
+            {
+              file = args[++i];
+            }
+            catch (Exception x)
+            {
+              throw new RuntimeException ("Missing file path after '-file'. Exit");
+            }
          else
            break;
         }
@@ -307,8 +317,18 @@
       SimpleTestHarness harness
        = new SimpleTestHarness (verbose, debug, results_only);

- -      BufferedReader r
- -       = new BufferedReader (new InputStreamReader (System.in));
+      BufferedReader r = null;
+      if (file != null)
+        try
+        {
+          r = new BufferedReader (new FileReader (file));
+        }
+        catch (FileNotFoundException x)
+        {
+          throw new RuntimeException ("Unable to find \""+file+"\". Exit");
+        }
+      else
+        r = new BufferedReader (new InputStreamReader (System.in));
       while (true)
        {
          String cname = null;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Que du magnifique

iD8DBQE+Ag5X+e1AKnsTRiERAzISAJ9gWfVRDzj1uEggEywtej4QLaSeUQCeIl+W
/bMYMGPahQ3YGPKj3aS45M8=
=r+Gb
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-12-19 18:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-19  3:33 new -file option to SimpleTestHarness Raif S. Naffah
2002-12-19  8:04 ` Brian Jones
2002-12-19 10:21   ` Raif S. Naffah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).