]> git.lyx.org Git - lyx.git/blobdiff - development/autotests/keytest.py
Add XeTeX tests
[lyx.git] / development / autotests / keytest.py
index 1122e6e7b64ba09dc575b0f4cd82d079b55a800d..b2a89c2d0d63944c101146419e0997950b9b1e58 100755 (executable)
@@ -234,7 +234,7 @@ def RaiseWindow():
     #intr_system("echo x-session-manager open files: `lsof -p $X_PID | grep ICE-unix | wc -l`")
     ####intr_system("wmctrl -l | ( grep '"+lyx_window_name+"' || ( killall lyx ; sleep 1 ; killall -9 lyx ))")
     #intr_system("wmctrl -R '"+lyx_window_name+"' ;sleep 0.1")
-    system_retry(30, "wmctrl -a '"+lyx_window_name+"'")
+    system_retry(30, "wmctrl -i -a '"+lyx_window_name+"'")
 
 
 lyx_pid = os.environ.get('LYX_PID')
@@ -250,9 +250,21 @@ max_loops = os.environ.get('MAX_LOOPS')
 if max_loops is None:
     max_loops = 3
 
+PACKAGE = os.environ.get('PACKAGE')
+if not PACKAGE is None:
+  print "PACKAGE = " + PACKAGE + "\n"
+
+PO_BUILD_DIR = os.environ.get('PO_BUILD_DIR')
+if not PO_BUILD_DIR is None:
+  print "PO_BUILD_DIR = " + PO_BUILD_DIR + "\n"
+
+lyx = os.environ.get('LYX')
+if lyx is None:
+    lyx = "lyx"
+
 lyx_exe = os.environ.get('LYX_EXE')
 if lyx_exe is None:
-    lyx_exe = "lyx"
+    lyx_exe = lyx
 
 xvkbd_exe = os.environ.get('XVKBD_EXE')
 if xvkbd_exe is None:
@@ -318,12 +330,12 @@ while not failed:
         print "Ignoring comment line: " + c
     elif c[0:9] == 'TestBegin':
         print "\n"
-        lyx_pid=os.popen("pidof lyx").read()
+        lyx_pid=os.popen("pidof " + lyx).read()
         if lyx_pid != "":
             print "Found running instance(s) of LyX: " + lyx_pid + ": killing them all\n"
-            intr_system("killall lyx")
+            intr_system("killall " + lyx, True)
             time.sleep(0.5)
-            intr_system("killall -KILL lyx")
+            intr_system("killall -KILL " + lyx, True)
         time.sleep(0.2)
         print "Starting LyX . . ."
         if lyx_userdir is None:
@@ -331,7 +343,7 @@ while not failed:
         else:
             intr_system(lyx_exe + " -userdir " + lyx_userdir + " " + c[9:] + "&")
         while True:
-            lyx_pid=os.popen("pidof lyx").read().rstrip()
+            lyx_pid=os.popen("pidof " + lyx).read().rstrip()
             if lyx_pid != "":
                 lyx_window_name=os.popen("wmctrl -l -p | grep ' " + str(lyx_pid) +  " ' | cut -d ' ' -f 1").read().rstrip()
                 if lyx_window_name != "":
@@ -342,7 +354,7 @@ while not failed:
         print 'lyx_pid: ' + lyx_pid + '\n'
         print 'lyx_win: ' + lyx_window_name + '\n'
     elif c[0:5] == 'Sleep':
-        print "Sleeping for " + c[6:] + "\n"
+        print "Sleeping for " + c[6:] + " seconds\n"
         time.sleep(float(c[6:]))
     elif c[0:4] == 'Exec':
         cmd = c[5:].rstrip()
@@ -359,7 +371,10 @@ while not failed:
             sendKeystring(c[4:], lyx_pid)
         else:
             ##intr_system('killall lyx; sleep 2 ; killall -9 lyx')
-            print 'No path /proc/' + lyx_pid + '/status, exiting'
+            if lyx_pid is None:
+              print 'No path /proc/xxxx/status, exiting'
+            else:
+              print 'No path /proc/' + lyx_pid + '/status, exiting'
             os._exit(1)
     elif c[0:4] == 'KD: ':
         key_delay = c[4:].rstrip('\n')
@@ -369,17 +384,20 @@ while not failed:
         sendKeystring(ResetCommand, lyx_pid)
     elif c[0:6] == 'Assert':
         cmd = c[7:].rstrip()
-        print "Executing " + cmd
         result = intr_system(cmd)
         failed = failed or (result != 0)
         print "result=" + str(result) + ", failed=" + str(failed)
     elif c[0:7] == 'TestEnd':
         time.sleep(0.5)
-        print "Terminating lyx instance: " + str(lyx_pid) + "\n"
-        intr_system("kill -9 " + str(lyx_pid));
-        while lyx_exists():
-            print "Waiting for lyx to die...\n"
-            time.sleep(0.5)
+        if not lyx_exists():
+            print "LyX instance not found because of crash or assert !\n"
+            failed = True
+        else:
+            print "Terminating lyx instance: " + str(lyx_pid) + "\n"
+            intr_system("kill -9 " + str(lyx_pid), True);
+            while lyx_exists():
+                print "Waiting for lyx to die...\n"
+                time.sleep(0.5)
         cmd = c[8:].rstrip()
         print "Executing " + cmd
         result = intr_system(cmd)
@@ -389,25 +407,46 @@ while not failed:
         lang = c[5:].rstrip()
         print "Setting LANG=" + lang + "\n"
         os.environ['LANG'] = lang
+        os.environ['LC_ALL'] = lang
+# If it doesn't exist, create a link <locale_dir>/<country-code>/LC_MESSAGES/lyx<version-suffix>.mo
+# pointing to the corresponding .gmo file. Needed to let lyx find the right translation files.
+# See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg165613.html
         idx = lang.rfind(".")
         if idx != -1:
             ccode = lang[0:idx]
         else:
             ccode = lang
+
+        print "Setting LANGUAGE=" + ccode + "\n"
+        os.environ['LANGUAGE'] = ccode
+
         idx = lang.find("_")
         if idx != -1:
             short_code = lang[0:idx]
         else:
             short_code = ccode
         lyx_dir = os.popen("dirname \"" + lyx_exe + "\"").read().rstrip()
+        if PACKAGE is None:
+          # on cmake-build there is no Makefile in this directory
+          # so PACKAGE has to be provided
+          if os.path.exists(lyx_dir + "/Makefile"):
+            print "Executing: grep 'PACKAGE =' " + lyx_dir + "/Makefile | sed -e 's/PACKAGE = \(.*\)/\\1/'"
+            lyx_name = os.popen("grep 'PACKAGE =' " + lyx_dir + "/Makefile | sed -e 's/PACKAGE = \(.*\)/\\1/'").read().rstrip()
+          else:
+            print 'Could not determine PACKAGE name needed for translations\n'
+            failed = True
+        else:
+          lyx_name = PACKAGE
         intr_system("mkdir -p " + locale_dir + "/" + ccode + "/LC_MESSAGES")
-# Append version suffix ?
-        if lyx_dir[0:3] == "../":
-            rel_dir = "../../" + lyx_dir
+        intr_system("rm -f " + locale_dir + "/" + ccode + "/LC_MESSAGES/" + lyx_name + ".mo")
+        if PO_BUILD_DIR is None:
+            if lyx_dir[0:3] == "../":
+                rel_dir = "../../" + lyx_dir
+            else:
+                rel_dir = lyx_dir
+            intr_system("ln -s " + rel_dir + "/../po/" + short_code + ".gmo " + locale_dir + "/" + ccode + "/LC_MESSAGES/" + lyx_name + ".mo")
         else:
-            rel_dir = lyx_dir
-        intr_system("rm -f " + locale_dir + "/" + ccode + "/LC_MESSAGES/lyx.mo")
-        intr_system("ln -s " + rel_dir + "/../po/" + short_code + ".gmo " +  locale_dir + "/" + ccode + "/LC_MESSAGES/lyx.mo")
+            intr_system("ln -s " + PO_BUILD_DIR + "/" + short_code + ".gmo " + locale_dir + "/" + ccode + "/LC_MESSAGES/" + lyx_name + ".mo")
     else:
         print "Unrecognised Command '" + c + "'\n"
         failed = True