To launch java tests with a Makefile
Pierre Marechal [Tue, 29 Nov 2005 10:53:04 +0000 (10:53 +0000)]
tests/java/JavaTests.sce
tests/java/Makefile [new file with mode: 0644]
tests/java/Makefile.mak [new file with mode: 0644]

index 2799b2c..f56c9fa 100644 (file)
@@ -6,80 +6,80 @@ tests = ['clf.java';'disp.java';'Exec.java';'Real1.java';'Real2.java';'Real3.jav
 //---------------------------------------------------------------
 // Compilation du fichier Java
 function ret=BuildJava(filename)
-  if MSDOS then
-    Command='javac -deprecation -d '+SCI+'\bin -classpath '+SCI+'\bin '+filename;
-  else
-    Command='javac -deprecation -d '+SCI+'/bin -classpath '+SCI+'/bin '+filename;
-  end
-  [rep,stat]=unix_g(Command);
-  if ~(stat==0) then
-    disp('error compilation '+filename);
-    ret=%F;
-  else
-       ret=%T;
-  end
+       if MSDOS then
+               Command='javac -deprecation -d '+SCI+'\bin -classpath '+SCI+'\bin '+filename;
+       else
+               Command='javac -deprecation -d '+SCI+'/bin -classpath '+SCI+'/bin '+filename;
+       end
+       [rep,stat]=unix_g(Command);
+       if ~(stat==0) then
+               disp('error compilation '+filename);
+               ret=%F;
+       else
+               ret=%T;
+       end
 endfunction
 //---------------------------------------------------------------
 // Execution du fichier Java
 function ExecJava(filename,buildref)
-  currentdir=pwd();
-  repfilename='';
-  chdir(SCI+'\bin');
-  if ~MSDOS then
-    setenv('LD_LIBRARY_PATH','$LD_LIBRARY_PATH:'+pwd());
-    setenv('CLASSPATH','$CLASSPATH:'+pwd()+':.');
-    setenv('SHLIB_PATH','$SHLIB_PATH:'+pwd()+':.');
-  end
-  [path,fname,extension]=fileparts(filename);
-  if (buildref == %T) then
-       if MSDOS then
-         repfilename=currentdir+'\'+fname+'.dia.ref';
-       else
-               repfilename=currentdir+'/'+fname+'.dia.ref';
-    end
-  else
-       if MSDOS then
-               repfilename=currentdir+'\'+fname+'.dia';
-       else
-               repfilename=currentdir+'/'+fname+'.dia';
-    end
-  end
-  commandline='java '+fname +' > '+repfilename;
-  unix(commandline);
-  chdir(currentdir);
+       currentdir=pwd();
+       repfilename='';
+       chdir(SCI+'\bin');
+       if ~MSDOS then
+               setenv('LD_LIBRARY_PATH','$LD_LIBRARY_PATH:'+pwd());
+               setenv('CLASSPATH','$CLASSPATH:'+pwd()+':.');
+               setenv('SHLIB_PATH','$SHLIB_PATH:'+pwd()+':.');
+       end
+       [path,fname,extension]=fileparts(filename);
+       if (buildref == %T) then
+               if MSDOS then
+                       repfilename=currentdir+'\'+fname+'.dia.ref';
+               else
+                       repfilename=currentdir+'/'+fname+'.dia.ref';
+               end
+       else
+               if MSDOS then
+                       repfilename=currentdir+'\'+fname+'.dia';
+               else
+                       repfilename=currentdir+'/'+fname+'.dia';
+               end
+       end
+       commandline='java '+fname +' > '+repfilename;
+       unix(commandline);
+       chdir(currentdir);
 endfunction
 //---------------------------------------------------------------
 // Nettoyage apres tests du fichier .class généré
 function CleanClass(filename)
        currentdir=pwd();
-  chdir(SCI+'\bin');
-  [path,fname,extension]=fileparts(filename);
-  if MSDOS then
-    unix_s('del '+fname+'.class');
-  else
-       unix_s('rm -f '+fname+'.class');
-  end
-  chdir(currentdir);
+       chdir(SCI+'\bin');
+       [path,fname,extension]=fileparts(filename);
+       if MSDOS then
+               unix_s('del '+fname+'.class');
+       else
+               unix_s('rm -f '+fname+'.class');
+       end
+       chdir(currentdir);
 endfunction
 //---------------------------------------------------------------
 // Comparaison avec la reference
 function CompareDiary(filename)
-  [path,fname,extension]=fileparts(filename);
-  fpdia=mopen(fname+'.dia','r');
-  fpref=mopen(fname+'.dia.ref','r');
-  dia=mgetl(fpdia);
-  mclose(fpdia);
-  ref=mgetl(fpref);
-  mclose(fpref);
-
-  dia=strsubst(dia,' ','');
-  ref=strsubst(ref,' ','');
-
-  if or(ref<>dia) then
-    disp('Test Failed SEE : diff -w  '+fname+'.dia '+fname+'.dia.ref ');
-  else
-    disp('Test '+fname+' passed');
-  end
+       [path,fname,extension]=fileparts(filename);
+       fpdia=mopen(fname+'.dia','r');
+       fpref=mopen(fname+'.dia.ref','r');
+       dia=mgetl(fpdia);
+       mclose(fpdia);
+       ref=mgetl(fpref);
+       mclose(fpref);
+       
+       dia=strsubst(dia,' ','');
+       ref=strsubst(ref,' ','');
+       
+       if or(ref<>dia) then
+               disp('Test Failed SEE : diff -w  '+fname+'.dia '+fname+'.dia.ref ');
+       else
+               disp('Test '+fname+' passed');
+       end
 endfunction
 //---------------------------------------------------------------
 // Construction de la reference
@@ -88,35 +88,36 @@ function BuildRef(filename)
 endfunction
 //---------------------------------------------------------------
 function maketests()
-  Dim=size(tests);
-  i=Dim(1);
+       Dim=size(tests);
+       i=Dim(1);
        lines(0);
-  for indice=1:i
-       disp('//---------------------------------------------------------------');
+       for indice=1:i
+               disp('//---------------------------------------------------------------');
                if ( BuildJava(tests(indice)) ) then
-                 ExecJava(tests(indice),%F);
-                 CleanClass(tests(indice));
-                 CompareDiary(tests(indice));
+                       ExecJava(tests(indice),%F);
+                       CleanClass(tests(indice));
+                       CompareDiary(tests(indice));
                end
-  end
-  disp('//---------------------------------------------------------------');
+       end
+       disp('//---------------------------------------------------------------');
 endfunction
 //---------------------------------------------------------------
 function makeref()
-  Dim=size(tests);
-  i=Dim(1);
+       Dim=size(tests);
+       i=Dim(1);
        lines(0);
-  for indice=1:i
+       for indice=1:i
                if ( BuildJava(tests(indice)) ) then
-                 ExecJava(tests(indice),%T);
-                 CleanClass(tests(indice));
+                       ExecJava(tests(indice),%T);
+                       CleanClass(tests(indice));
                end
-  end
+       end
 endfunction
 //---------------------------------------------------------------
 // Fonction principale
 function main()
-               maketests();
+       maketests();
+       quit
 endfunction
 //---------------------------------------------------------------
 main();
diff --git a/tests/java/Makefile b/tests/java/Makefile
new file mode 100644 (file)
index 0000000..ce288f5
--- /dev/null
@@ -0,0 +1,19 @@
+SHELL = /bin/sh
+
+SCIDIR = ../..
+
+include ../../Makefile.incl
+
+info:
+       @echo "Type \"make tests\" in tests directory"
+       @echo "  to test the  distribution"
+       @echo " SEE THE README FILE (IMPORTANT) "
+
+tests: 
+       $(SCIDIR)/bin/scilab -nw -f JavaTests.sce
+
+clean ::
+       $(RM) *.dia
+
+distclean::
+       $(RM) *.dia
diff --git a/tests/java/Makefile.mak b/tests/java/Makefile.mak
new file mode 100644 (file)
index 0000000..6fcff9c
--- /dev/null
@@ -0,0 +1,13 @@
+
+SCIDIR1 = ..\..
+
+include ..\..\Makefile.incl.mak
+
+tests:
+       $(SCIDIR1)\bin\scilex -nw -f JavaTests.sce
+
+clean ::
+       @del *.dia
+
+distclean::
+       @del *.dia