2 new revisions:

Revision: 0e4fa14f28c9
Branch:   default
Author:   Pekka Klärck
Date:     Wed Sep 12 11:49:10 2012
Log:      atest/robot/cli/rebot/status_rc.txt: cleanup
http://code.google.com/p/robotframework/source/detail?r=0e4fa14f28c9

Revision: 17efc16eac8d
Branch:   default
Author:   Pekka Klärck
Date:     Wed Sep 12 12:51:26 2012
Log: run_atests.py: Own result and temp dirs for different interpreters....
http://code.google.com/p/robotframework/source/detail?r=17efc16eac8d

==============================================================================
Revision: 0e4fa14f28c9
Branch:   default
Author:   Pekka Klärck
Date:     Wed Sep 12 11:49:10 2012
Log:      atest/robot/cli/rebot/status_rc.txt: cleanup
http://code.google.com/p/robotframework/source/detail?r=0e4fa14f28c9

Modified:
 /atest/robot/cli/rebot/status_rc.txt

=======================================
--- /atest/robot/cli/rebot/status_rc.txt        Mon Jun 18 00:57:01 2012
+++ /atest/robot/cli/rebot/status_rc.txt        Wed Sep 12 11:49:10 2012
@@ -1,16 +1,13 @@
 *** Settings ***
-Suite Setup     Set Runners and generate input files
+Suite Setup     Generate input files
 Suite Teardown  Remove input files
 Test Template   Run Rebot and Verify RC
 Force Tags      regression  pybot  jybot
 Resource        rebot_cli_resource.txt

 *** Variables ***
-${PASSING}         ${TEMPDIR}/rebot-testing-passing.xml
-${FAILING}         ${TEMPDIR}/rebot-testing-failing.xml
-${MISCDIR}         ${CURDIR}/../../../testdata/misc
-${PASSING TESTS}   ${MISCDIR}/normal.txt
-${FAILING TESTS}   ${MISCDIR}/pass_and_fail.txt
+${PASSING}         ${TEMPDIR}${/}rebot-testing-passing.xml
+${FAILING}         ${TEMPDIR}${/}rebot-testing-failing.xml
 ${REPORT}          ${TEMPDIR}${/}robot-testing-report.html
${NO OUTPUTS} [ ERROR ] No outputs created.\n\nTry --help for usage information.

@@ -37,11 +34,10 @@


 *** Keywords ***
-Set runners and generate input files
-    Set runners
-    Run Tests Without Processing Output  ${EMPTY}  ${PASSING TESTS}
+Generate input files
+    Run Tests Without Processing Output  ${EMPTY}  misc/normal.txt
     Move File  ${OUTFILE}  ${PASSING}
-    Run Tests Without Processing Output  ${EMPTY}  ${FAILING TESTS}
+    Run Tests Without Processing Output  ${EMPTY}  misc/pass_and_fail.txt
     Move File  ${OUTFILE}  ${FAILING}

 Remove input files
@@ -51,6 +47,5 @@
[Arguments] ${options & source} ${rc}= ${output}= ${report}=${REPORT}
     ${returned rc}  ${returned output} =  Run And Return RC And Output
     ...  ${REBOT} --log NONE --report ${report} ${options & source}
-    Run Keyword If  ${rc} != ${returned rc}  Log  ${output}
     Should Be Equal As Integers  ${returned rc}  ${rc}
Run Keyword If """${output}""" Should Be Equal ${returned output} ${output}

==============================================================================
Revision: 17efc16eac8d
Branch:   default
Author:   Pekka Klärck
Date:     Wed Sep 12 12:51:26 2012
Log: run_atests.py: Own result and temp dirs for different interpreters.

This allows running tests simultaneously using different interpreters.
Running them simultaneously with same interpreter is explicitly denied.

To be able to safely run tests simultaneously, the new %{TEMPDIR} needs to
be taken into use in tests. This commit only contains that change for one
file that was used for testing that this approach works.

I have already updated our CI jobs to read results from atests/results/<interpreter>
http://code.google.com/p/robotframework/source/detail?r=17efc16eac8d

Modified:
 /atest/robot/cli/rebot/status_rc.txt
 /atest/run_atests.py

=======================================
--- /atest/robot/cli/rebot/status_rc.txt        Wed Sep 12 11:49:10 2012
+++ /atest/robot/cli/rebot/status_rc.txt        Wed Sep 12 12:51:26 2012
@@ -6,9 +6,9 @@
 Resource        rebot_cli_resource.txt

 *** Variables ***
-${PASSING}         ${TEMPDIR}${/}rebot-testing-passing.xml
-${FAILING}         ${TEMPDIR}${/}rebot-testing-failing.xml
-${REPORT}          ${TEMPDIR}${/}robot-testing-report.html
+${PASSING}         %{TEMPDIR}${/}rebot-testing-passing.xml
+${FAILING}         %{TEMPDIR}${/}rebot-testing-failing.xml
+${REPORT}          %{TEMPDIR}${/}robot-testing-report.html
${NO OUTPUTS} [ ERROR ] No outputs created.\n\nTry --help for usage information.

 *** Test Cases ***
=======================================
--- /atest/run_atests.py        Mon Sep 10 05:32:13 2012
+++ /atest/run_atests.py        Wed Sep 12 12:51:26 2012
@@ -21,15 +21,16 @@
 """

 import os
+import shutil
 import signal
 import subprocess
 import sys
-from os.path import abspath, basename, dirname, isdir, join, normpath
-from shutil import rmtree
+import tempfile
+from os.path import abspath, basename, dirname, exists, join, normpath, splitext
+

 CURDIR = dirname(abspath(__file__))
 RUNNER = normpath(join(CURDIR, '..', 'src', 'robot', 'run.py'))
-RESULTS = join(CURDIR, 'results')
 ARGUMENTS = ' '.join('''
 --doc RobotSPFrameworkSPacceptanceSPtests
 --reporttitle RobotSPFrameworkSPTestSPReport
@@ -60,11 +61,10 @@


 def atests(interpreter, *params):
-    if isdir(RESULTS):
-        rmtree(RESULTS)
+    resultdir, tempdir = _get_result_and_temp_dirs(interpreter)
     args = ARGUMENTS % {
         'PYTHONPATH' : join(CURDIR, 'resources'),
-        'OUTPUTDIR' : RESULTS,
+        'OUTPUTDIR' : resultdir,
         'INTERPRETER': interpreter,
         'PLATFORM': sys.platform,
'INCLUDE': 'jybot' if 'jython' in basename(interpreter) else 'pybot'
@@ -74,10 +74,29 @@
     if sys.platform == 'darwin' and 'python' in basename(interpreter):
         args += ' --exclude x-exclude-on-osx-python'
command = '%s %s %s %s' % (sys.executable, RUNNER, args, ' '.join(params))
+    environ = dict(os.environ, TEMPDIR=tempdir)
     print 'Running command\n%s\n' % command
     sys.stdout.flush()
     signal.signal(signal.SIGINT, signal.SIG_IGN)
-    return subprocess.call(command.split())
+    try:
+        return subprocess.call(command.split(), env=environ)
+    finally:
+        shutil.rmtree(tempdir)
+
+
+def _get_result_and_temp_dirs(interpreter):
+    interpreter = splitext(basename(interpreter))[0]
+    resultdir = join(CURDIR, 'results', interpreter)
+    tempdir = join(tempfile.gettempdir(), 'robottests', interpreter)
+    if os.path.exists(tempdir):
+ print 'Temp directory for this interpreter already exists:', tempdir
+        print 'Cannot run tests simultaneously with same interpreter.'
+        print 'Remove the directory if it is left from an interrupted run.'
+        sys.exit(255)
+    if exists(resultdir):
+        shutil.rmtree(resultdir)
+    os.mkdir(tempdir)
+    return resultdir, tempdir


 if __name__ == '__main__':

Reply via email to