]> git.lyx.org Git - lyx.git/commitdiff
Now the framework works running LyX in the language required by the test
authorTommaso Cucinotta <tommaso@lyx.org>
Thu, 10 Feb 2011 22:33:23 +0000 (22:33 +0000)
committerTommaso Cucinotta <tommaso@lyx.org>
Thu, 10 Feb 2011 22:33:23 +0000 (22:33 +0000)
script (if any) also when LyX is not installed on your system
(using a variant of the trick suggested by Enrico, i.e., create a symlink
locale from the LyX sources root to an autotests/locale folder).
At least, it does on Linux.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37589 a592a061-630c-0410-9148-cb99ea01b6c8

development/autotests/findadv-08-in.txt
development/autotests/hello-world-in.txt
development/autotests/keytest.py
development/autotests/run-tests.sh
development/autotests/stop_autotests.tcl

index 2a8bc3ba2c625cf23250a52154d8a60841dc09d7..3da35417d2e81c41268764b3083531303f3aa2de 100644 (file)
@@ -12,7 +12,10 @@ Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 8\n with len: 8' l
 
 TestBegin test.lyx -dbg find > lyx-log.txt 2>&1
 KK: \CF
-KK: o\CR[[:word:]]* a\Al\Ar\[Return]
+KK: o\CR[[:word:]]* a
+KD: 200
+KK: \Al\Ar\[Return]
+KD: 100
 TestEnd
 Assert pcregrep -M 'Putting selection at .*idx: 0 par: 1 pos: 26\n with len: 6' lyx-log.txt
 
index 95b872b770bc179478bea67b6e08618fb28f9b9e..4c9d45d08bd7f1083efc0fa29c3e3ce597886679 100644 (file)
 # LaTeX, and verifies that the typed characters are indeed present in the
 # exported document.
 #
-Lang it_IT.utf8
 TestBegin test.lyx > lyx-log.txt 2>&1
 KK: Hello World
-KK: \Afs
+KK: \Cs
 KK: \Ax
 KK: buffer-export latex\[Return]
 TestEnd grep "Hello World" test.tex
index c247c01c540298184f307e219be62b9c16eab7fd..1122e6e7b64ba09dc575b0f4cd82d079b55a800d 100755 (executable)
@@ -149,8 +149,6 @@ class CommandSourceFromFile(CommandSource):
         line = self.lines[self.i].rstrip('\n')
         self.count = self.count + 1
         self.i = self.i + 1
-        #print '\nLine read: <<' + line + '>>\n'
-        sys.stdout.write('r')
         return line
 
 def lyx_exists():
@@ -171,10 +169,13 @@ def lyx_sleeping():
 
 
 # Interruptible os.system()
-def intr_system(cmd):
+def intr_system(cmd, ignore_err = False):
+    print "Executing " + cmd + "\n"
     ret = os.system(cmd)
     if os.WIFSIGNALED(ret):
         raise KeyboardInterrupt
+    if ret != 0 and not ignore_err:
+        raise BaseException("command failed.")
     return ret
 
 
@@ -188,7 +189,6 @@ def sendKeystring(keystr, LYX_PID):
     before_secs = time.time()
     while lyx_exists() and not lyx_sleeping():
         time.sleep(0.02)
-        sys.stdout.write('.')
         sys.stdout.flush()
         if time.time() - before_secs > 180:
             print 'Killing due to freeze (KILL_FREEZE)'
@@ -200,7 +200,6 @@ def sendKeystring(keystr, LYX_PID):
     if not screenshot_out is None:
         while lyx_exists() and not lyx_sleeping():
             time.sleep(0.02)
-            sys.stdout.write('.')
             sys.stdout.flush()
         print 'Making Screenshot: ' + screenshot_out + ' OF ' + infilename
         time.sleep(0.2)
@@ -261,6 +260,10 @@ if xvkbd_exe is None:
 
 xvkbd_hacked = os.environ.get('XVKBD_HACKED') != None
 
+locale_dir = os.environ.get('LOCALE_DIR')
+if locale_dir is None:
+    locale_dir = '.'
+
 def_delay = os.environ.get('XVKBD_DELAY')
 if def_delay is None:
     def_delay = '100'
@@ -312,7 +315,7 @@ while not failed:
     outfile.writelines(c + '\n')
     outfile.flush()
     if c[0] == '#':
-        print "\nIgnoring comment line: " + c
+        print "Ignoring comment line: " + c
     elif c[0:9] == 'TestBegin':
         print "\n"
         lyx_pid=os.popen("pidof lyx").read()
@@ -339,11 +342,10 @@ while not failed:
         print 'lyx_pid: ' + lyx_pid + '\n'
         print 'lyx_win: ' + lyx_window_name + '\n'
     elif c[0:5] == 'Sleep':
-        print "\nSleeping for " + c[6:] + "\n"
+        print "Sleeping for " + c[6:] + "\n"
         time.sleep(float(c[6:]))
     elif c[0:4] == 'Exec':
         cmd = c[5:].rstrip()
-        print "\nExecuting " + cmd + "\n"
         intr_system(cmd)
     elif c == 'Loop':
         outfile.close()
@@ -361,32 +363,51 @@ while not failed:
             os._exit(1)
     elif c[0:4] == 'KD: ':
         key_delay = c[4:].rstrip('\n')
-        print 'Setting DELAY to ' + key_delay + '.'
+        print 'Setting DELAY to ' + key_delay + '.\n'
     elif c == 'Loop':
         RaiseWindow()
         sendKeystring(ResetCommand, lyx_pid)
     elif c[0:6] == 'Assert':
         cmd = c[7:].rstrip()
-        print "\nExecuting " + cmd
+        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 "\nTerminating lyx instance: " + str(lyx_pid) + "\n"
-        intr_system("kill -9 " + str(lyx_pid) + "\n");
+        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)
         cmd = c[8:].rstrip()
-        print "\nExecuting " + cmd
+        print "Executing " + cmd
         result = intr_system(cmd)
         failed = failed or (result != 0)
         print "result=" + str(result) + ", failed=" + str(failed)
     elif c[0:4] == 'Lang':
         lang = c[5:].rstrip()
-        print "\nSetting LANG=" + lang
+        print "Setting LANG=" + lang + "\n"
         os.environ['LANG'] = lang
+        idx = lang.rfind(".")
+        if idx != -1:
+            ccode = lang[0:idx]
+        else:
+            ccode = lang
+        idx = lang.find("_")
+        if idx != -1:
+            short_code = lang[0:idx]
+        else:
+            short_code = ccode
+        lyx_dir = os.popen("dirname \"" + lyx_exe + "\"").read().rstrip()
+        intr_system("mkdir -p " + locale_dir + "/" + ccode + "/LC_MESSAGES")
+# Append version suffix ?
+        if lyx_dir[0:3] == "../":
+            rel_dir = "../../" + lyx_dir
+        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")
     else:
         print "Unrecognised Command '" + c + "'\n"
         failed = True
index 1b3ab651c4bdfc49b7bd11b8a561fa99f3e2b8a8..6cbbbe563b708da2010ae4741c1a9150cf625693 100755 (executable)
@@ -4,23 +4,42 @@
 # Tests are identified as having a file name of *-in.txt
 # For failed tests, the collected output is kept in the corresponding folder
 
-if [ ! -x xvkbd/xvkbd ]; then
-    echo "You need to build XVKBD first, try: cd xvkbd && xmkmf && make"
-    exit -1;
-fi
-
 export LYX_EXE=../../../src/lyx
 
 if [ "$XVKBD_HACKED" != "" ]; then
-    export XVKBD_EXE=${XVKBD:-../xvkbd/xvkbd};
+    export XVKBD_EXE=${XVKBD:-./xvkbd/xvkbd};
+    if [ ! -x $XVKBD_EXE ]; then
+       echo "You need to build XVKBD first, try: cd xvkbd && xmkmf && make"
+       exit -1;
+    fi
 fi
 
+export XVKBD_EXE=../$XVKBD_EXE
 export KEYTEST=../keytest.py
 LYX_HOME=out-home
 export LYX_USERDIR=$(pwd)/$LYX_HOME/.lyx
+# Create locale links 
+export LOCALE_DIR=../locale
+
+if [ ! -d ../../locale ]; then
+    echo "Some tests may require the GUI showing up in a specified language."
+    echo "In order to make it work, I'm going to run this command:"
+    mkdir -p locale
+    cmd="ln -s `pwd`/locale ../../"
+    echo "  $cmd"
+    ans=""
+    while [ "$ans" != "y" -a "$ans" != "n" ]; do
+       echo "Should I proceed (y/n) ?"
+       read ans;
+    done
+    if [ "$ans" == "y" ]; then
+       $cmd;
+    fi;
+fi
 
 if [ "$#" -eq 0 ]; then
-    TESTS=$(ls *-in.txt | sed -e 's/hello-world-in.txt\|first-time-in.txt//');
+    TESTS=$(ls *-in.txt | sed -e 's/hello-world-in.txt\|first-time-in.txt//')
+    rm -rf out-*;
 else
     TESTS=$*
 fi
@@ -28,7 +47,9 @@ fi
 echo
 
 if [ ! -d $LYX_HOME ]; then
-    mkdir $LYX_HOME
+    mkdir -p $LYX_HOME
+#    mkdir -p $LYX_USERDIR
+#    cp preferences $LYX_USERDIR
     cd $LYX_HOME
     echo "Initializing testing environment . . ."
     if ! ../single-test.sh "../first-time-in.txt" > keytest-log.txt 2>&1; then
index 5784e8ea936acdf7d2c3553ddb0df8d49012af3b..5b15c682a61ef45d40f2b5db465ab1d90741dce6 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/wish8.5
+#!/usr/bin/wish8.5
 
 wm attributes . -topmost 1