File: javaTestDriver.java.in

package info (click to toggle)
insighttoolkit4 4.13.3withdata-dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 489,260 kB
  • sloc: cpp: 557,342; ansic: 146,850; fortran: 34,788; python: 16,572; sh: 2,187; lisp: 2,070; tcl: 993; java: 362; perl: 200; makefile: 129; csh: 81; pascal: 69; xml: 19; ruby: 10
file content (67 lines) | stat: -rw-r--r-- 1,970 bytes parent folder | download | duplicates (8)
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

import argparser.*;
import java.io.*;
import java.util.Vector;

class javaTestDriver {

   public static void exec(String command) throws Exception {
      System.out.println( "+ "+command );
      Process p = Runtime.getRuntime().exec( command );
      String line;
      BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
      while ((line = input.readLine()) != null) {
         System.out.println(line);
      }
      input.close();
      input = new BufferedReader(new InputStreamReader(p.getErrorStream()));
      while ((line = input.readLine()) != null) {
         System.err.println(line);
      }
      input.close();
      // to be sure the process have exited
      p.waitFor();
      int exitValue = p.exitValue();
      if( exitValue != 0 ) {
         System.exit( exitValue );
      }
   }




   public static void main(String[] argv) throws Exception {

      String itk_jar = "@JAVA_TEST_ITK_JAR@";
      String java_bin = "@JAVA_RUNTIME@";
      String image_compare = "@IMAGE_COMPARE@";

      Vector compare = new Vector();

      ArgParser parser = new ArgParser("javaTestDriver [--compare image1 image2] test [arg1 [arg2 [...]]]");
      parser.addOption ("--compare %sX2 #compare IMAGE1 and IMAGE2 and exit with an error if the images are different. This options can appear several times to compare several images.", compare);
      String[] args = parser.matchAllArgs (argv, 0, parser.EXIT_ON_ERROR);

      if( args == null || args.length == 0 ) {
         System.err.println( "you must give a command to run" );
         System.exit( 1 );
      }



      String command = java_bin+" -cp .:"+itk_jar;
      for( int i=0; i<args.length; i++ ) {
         command += " "+args[i];
      }
      exec( command );


      for( int i=0; i<compare.size(); i++) {
         String [] r = (String [])compare.elementAt(i);

         command = image_compare+" "+r[0]+" "+r[1];
         exec( command );
      }

   }
}