Commits

Harald Klimach committed 46897ea

Use the waf_unit_test facilities, to run the unit tests

Comments (0)

Files changed (4)

utests/aot_table_test.f90

   integer :: iError
   integer :: i
   character(len=80) :: ErrString
+  logical :: passed
 
   call create_script('aot_table_test_config.lua')
 
   write(*,*)
   write(*,*) 'Running aot_table_test...'
 
+  passed = .true.
   call open_config_file(L = conf, filename = 'aot_table_test_config.lua', &
     &                   ErrCode = iError, ErrString = ErrString)
   if (iError /= 0) then
   if (globhandle == 0) then
     write(*,*) '  : unexpected FATAL Error occured !!!'
     write(*,*) '  : could not open global table primes.'
+    passed = .false.
   else
     write(*,*) '  : success.'
     write(*,*) ' * getting the length of the table'
       write(*,*) '  : unexpected FATAL Error occured !!!'
       write(*,*) '  : found a table length of ', tablen
       write(*,*) '  :    but should have been ', 5
+      passed = .false.
     else
       write(*,*) '  : success.'
       write(*,*) ' * retrieving entries of table by position'
           &                val = tabint, ErrCode = iError)
         if (btest(iError, aoterr_Fatal)) then
           write(*,*) '  : unexpected FATAL Error occured !!!'
+          passed = .false.
           if (btest(iError, aoterr_NonExistent)) &
             &   write(*,*) '  : Variable not existent!'
           if (btest(iError, aoterr_WrongType)) &
           if (tabint /= primes(i)) then
             write(*,*) '  : unexpected ERROR, value mismatch, got: ', tabint
             write(*,*) '  :                             should be: ', primes(i)
+            passed = .false.
             iError = 42
             exit
           end if
       if (btest(iError, aoterr_Fatal)) then
         write(*,*) '  : success.'
       else
+        passed = .false.
         write(*,*) '  : ERROR, unexpected success in reading nonexistent entry'
         if (btest(iError, aoterr_NonExistent)) &
           &   write(*,*) '  : Variable not existent, but should be fatal!'
   call close_config(conf)
   write(*,*) '... Done with aot_table_test.'
 
+  if (passed) then
+    write(*,*) 'PASSED'
+  else
+    write(*,*) 'FAILED'
+  end if
+
 contains
 
   subroutine create_script(filename)

utests/aotus_test.f90

   logical :: glob_log
   character(len=20) :: glob_string
   character(len=80) :: ErrString
+  logical :: passed
+
+  passed = .true.
 
   call create_script('aotus_test_config.lua')
   write(*,*)
       &   write(*,*) '  : Variable not existent!'
     if (btest(iError, aoterr_WrongType)) &
       &   write(*,*) '  : Variable has wrong type!'
+    passed = .false.
   else
     if (glob_int == 5) then
       write(*,*) '  : success.'
     else
       write(*,*) '  : unexpected ERROR, value mismatch, got: ', glob_int
       write(*,*) '  :                             should be: ', 5
+      passed = .false.
     end if
   end if
   ! -------------------------------- !
       &   write(*,*) '  : Variable not existent!'
     if (btest(iError, aoterr_WrongType)) &
       &   write(*,*) '  : Variable has wrong type!'
+    passed = .false.
   else
     if (glob_long == 5000000000_long_k) then
       write(*,*) '  : success.'
       write(*,*) '  : unexpected ERROR, value mismatch, got: ', glob_long
       write(*,*) '  :                             should be: ', &
         &                                         5000000000_long_k
+      passed = .false.
     end if
   end if
   ! -------------------------------- !
       &   write(*,*) '  : Variable not existent!'
     if (btest(iError, aoterr_WrongType)) &
       &   write(*,*) '  : Variable has wrong type!'
+    passed = .false.
   else
     if (glob_real == 0.5) then
       write(*,*) '  : success.'
     else
       write(*,*) '  : unexpected ERROR, value mismatch, got: ', glob_real
       write(*,*) '  :                             should be: ', 0.5
+      passed = .false.
     end if
   end if
   ! -------------------------------- !
       &   write(*,*) '  : Variable not existent!'
     if (btest(iError, aoterr_WrongType)) &
       &   write(*,*) '  : Variable has wrong type!'
+    passed = .false.
   else
     if (glob_log) then
       write(*,*) '  : success.'
     else
       write(*,*) '  : unexpected ERROR, value mismatch, got: ', glob_log
       write(*,*) '  :                             should be: ', .true.
+      passed = .false.
     end if
   end if
   ! -------------------------------- !
       &   write(*,*) '  : Variable not existent!'
     if (btest(iError, aoterr_WrongType)) &
       &   write(*,*) '  : Variable has wrong type!'
+    passed = .false.
   else
     if (trim(glob_string) == 'last words') then
       write(*,*) '  : success.'
     else
       write(*,*) '  : unexpected ERROR, value mismatch, got: ', glob_string
       write(*,*) '  :                             should be: ', 'last words'
+      passed = .false.
     end if
   end if
   ! -------------------------------- !
 
   if (btest(iError, aoterr_Fatal)) then
     write(*,*) '  : unexpected FATAL Error occured !!!'
+    passed = .false.
   else
     if (btest(iError, aoterr_WrongType)) then
       write(*,*) '  : unexpected ERROR, found WrongType !!!'
+      passed = .false.
     else
       if (btest(iError, aoterr_NonExistent)) then
         if (glob_int == 1) then
         else
           write(*,*) '  : unexpected ERROR, value mismatch, got: ', glob_int
           write(*,*) '  :                             should be: ', 1
+          passed = .false.
         end if
       else
         write(*,*) '  : ERROR: missing aoterr_NonExistent !!!'
         write(*,*) '  :        should receive error when looking up "nonexist"'
+        passed = .false.
       end if
     end if
   end if
       write(*,*) '  : success.'
     else
       write(*,*) '  : ERROR no aoterr_NonExistent returned !!!'
+      passed = .false.
     end if
   else
     write(*,*) '  : ERROR unexpectly no fatal Error code returned !!!'
+    passed = .false.
   end if
   ! -------------------------------- !
 
       write(*,*) '  : success.'
     else
       write(*,*) '  : ERROR no aoterr_WrongType returned !!!'
+      passed = .false.
     end if
   else
     write(*,*) '  : ERROR unexpectly no fatal Error code returned !!!'
+    passed = .false.
   end if
   ! -------------------------------- !
 
   call close_config(conf)
   write(*,*) '  : success.'
   write(*,*) '... Done with aotus_test.'
+  if (passed) then
+    write(*,*) 'PASSED'
+  else
+    write(*,*) 'FAILED'
+  end if
 
 contains
 
Binary file modified.
     from waflib.Tools.compiler_fc import fc_compiler
     opt.load('compiler_fc')
     opt.load('compiler_c')
+    opt.load('waf_unit_test')
+    opt.load('utest_results')
 
 def configure(conf):
     from waflib import Logs
     # Load the compiler informations
     conf.load('compiler_fc')
     conf.load('compiler_c')
+    conf.load('waf_unit_test')
+
     conf.env.stash()
     try:
         conf.load('doxygen')
         use = 'flu',
         target = 'flu_sample')
 
-    if bld.cmd == 'test':
-        for utest in bld.path.ant_glob('utests/*_test.f90'):
-            bld(
-                features = 'fc fcprogram',
-                source = utest,
-                use = 'aotus',
-                target = utest.change_ext(''))
+    for utest in bld.path.ant_glob('utests/*_test.f90'):
+        bld(
+            features = 'fc fcprogram test',
+            source = utest,
+            use = 'aotus',
+            target = utest.change_ext(''))
+    from waflib.extras import utest_results
+    bld.add_post_fun(utest_results.summary)
 
     if bld.cmd == 'doxy':
         bld(features = 'doxygen',