[Ecm-commits] r2609 - trunk/build.vc12

cvs commits ecm-commits at lists.gforge.inria.fr
Fri Feb 13 15:08:57 CET 2015


Author: brian_gladman
Date: 2015-02-13 15:08:57 +0100 (Fri, 13 Feb 2015)
New Revision: 2609

Modified:
   trunk/build.vc12/python.bat
   trunk/build.vc12/tests.py
Log:
update testing code for the Visual Studio build

Modified: trunk/build.vc12/python.bat
===================================================================
--- trunk/build.vc12/python.bat	2015-02-13 06:35:19 UTC (rev 2608)
+++ trunk/build.vc12/python.bat	2015-02-13 14:08:57 UTC (rev 2609)
@@ -1,2 +1,2 @@
 @echo off
-"c:\program files\python33\python" %1
+"c:\program files\python34\python" %1

Modified: trunk/build.vc12/tests.py
===================================================================
--- trunk/build.vc12/tests.py	2015-02-13 06:35:19 UTC (rev 2608)
+++ trunk/build.vc12/tests.py	2015-02-13 14:08:57 UTC (rev 2609)
@@ -13,66 +13,88 @@
   def __enter__(self): self.start = clock()
   def __exit__(self, *args): print(' time {:.3f} milliseconds'.format(1000 * (clock() - self.start)))
 
-test_dir = '..\\bin\\x64\\Release\\'
-# test_dir = '..\\bin\\win32\\Release\\'
 test_normal = True
 test_gpu = True
 
+cpath = os.path.dirname(__file__)
+test_dir = '..\\bin\\x64\\Release\\'
+
 def get_tests(filename):
   print('running tests in {:s}'.format(filename))
-  start, sub, tests = True, dict(), []
-  with open(filename) as f:
+  start, sub, tests, c_tests = True, dict(), [], []
+  with open(os.path.join(cpath, filename)) as f:
     lines = f.readlines()
     cnt, lnth = 0, len(lines)
     while cnt < lnth:
-      line = lines[cnt].strip()
-      cnt += 1
-      tkns = line.split()
-      if line.startswith('echo') and len(tkns) > 2 and tkns[2] == '|':
-        if 'checkcode' not in line:
-          while not lines[cnt] and cnt < lnth:
-            cnt += 1 
-          if cnt < lnth and 'checkcode' in lines[cnt]:
-            line += '; ' + lines[cnt]
-            cnt += 1
-        start = False
-      elif start:
-        sp = line.split('="')
-        if len(sp) == 2:
-          if sp[1].startswith('$1'):
-            sub[sp[0]] = sp[1][2:-1]
-          else:
-            sub[sp[0]] = sp[1][:-1]
-        continue
-      else:
-        continue
-      tkns = line.split()
-      cmd =  ''
-      for tok in tkns[3:]:
-        if tok.startswith('"') and tok.endswith('"'):
-          tok = tok[1:-1]
-        if tok[0] == '$' and tok[1:] in sub:
-          tok = tok.replace(tok, sub[tok[1:]])
-        if tok.endswith(';'):
-          cmd += tok[:-1]
-          break
+      try:
+        line = lines[cnt].strip()
+        cnt += 1
+        tkns = line.split()
+        if line.startswith('echo') and len(tkns) > 2 and tkns[2] == '|':
+          while cnt < lnth and 'checkcode' not in line:
+            while cnt < lnth and not lines[cnt]:
+              cnt += 1 
+            if cnt < lnth:
+              line += '|' + lines[cnt]
+              cnt += 1
+          start = False
+        elif start:
+          sp = line.split('="')
+          if len(sp) == 2:
+            if sp[1].startswith('$1'):
+              sub[sp[0]] = sp[1][2:-1]
+            else:
+              sub[sp[0]] = sp[1][:-1]
+          continue
         else:
-          cmd += tok + ' '
-      code = tkns[-1]
-      t = (tkns[1].replace('\"', ''), cmd.strip(), int(tkns[-1]))
-      tests += [t]
-  return tests
+          continue
+        line = line.replace(';', '|')
+        sub_tests = []
+        for line_part in line.split('|'):
+          tkns = line_part.strip().split()
+          cmd =  []
+          for tok in tkns:
+            if tok.startswith('"') and tok.endswith('"'):
+              tok = tok[1:-1]
+            if tok[0] == '$' and tok[1:] in sub:
+              tok = tok.replace(tok, sub[tok[1:]])
+            elif tok == './ecm':
+              tok = ''
+            cmd += [tok]
+          cseq = []
+          if cmd and cmd[0] == 'echo':
+            cseq += [cmd[1]]
+            cmd = cmd[2:]
+          if len(cmd) >= 3 and cmd[-3] == 'checkcode' and cmd[-2] == '$?':
+            cseq += [int(cmd[-1])]
+            cmd = cmd[:-3]
+          cmd = (' '.join(cmd)).strip()
+          if cmd:
+            cseq += [cmd]
+          sub_tests += [cseq]
+        if len(sub_tests) == 3 and all(len(x) == 1 for x in sub_tests):
+          tests += [tuple(x[0] for x in sub_tests)]
+        else:
+          c_tests += [sub_tests]
+      except ValueError:
+        print('parsing error on line {} in text "{}"'.format(cnt, line))        
+  return tests, c_tests
 
 def run_exe(exe, args, inp) :
   al = {'stdin' : PIPE, 'stdout' : PIPE, 'stderr' : STDOUT }
   if sys.platform.startswith('win'):
     al['creationflags'] = 0x08000000
-  p = Popen([exe] + args.split(' '), **al)
+  p = Popen([os.path.join(cpath, exe)] + args.split(' '), **al)
   res = p.communicate(inp.encode())[0].decode()
   ret = p.poll()
   return (ret, res)
 
-def do_tests(tests, gpu=False, out=False):
+def output_complex_tests(x):
+  print('these tests are too complex:')
+  for t in x:
+    print(t)      
+
+def do_tests(tests, ctests, gpu=False, out=False):
   exe  = test_dir + ("ecm_gpu.exe" if gpu else "ecm.exe")
   err_cnt = 0
   for ix, tt in enumerate(tests):
@@ -91,16 +113,26 @@
       for i in op :
         print(i)
 
+  if ctests:
+    output_complex_tests(ctests)    
   if not err_cnt:
-    print('  all tests passed')
-
+    if ctests:
+      print('  all other tests passed')
+    else:
+      print('  all tests passed')
+      
 with Timer():
   if os.path.exists('test.pm1.save'):
     os.remove('test.pm1.save')
   if test_normal:
-    do_tests(get_tests("..\\test.ecm"))
-    do_tests(get_tests("..\\test.pm1"))
-    do_tests(get_tests("..\\test.pp1"))
-    do_tests(get_tests("..\\testlong.pp1"))
+    t, ct = get_tests("..\\test.ecm")
+    do_tests(t, ct)
+    t, ct = get_tests("..\\test.pm1")
+    do_tests(t, ct)
+    t, ct = get_tests("..\\test.pp1")
+    do_tests(t, ct)
+    t, ct = get_tests("..\\testlong.pp1")
+    do_tests(t, ct)
   if test_gpu:
-    do_tests(get_tests("..\\test.gpuecm"), gpu=True)
+    t, ct = get_tests("..\\test.gpuecm")
+    do_tests(t, ct, gpu=True)



More information about the Ecm-commits mailing list