Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert error when running pabot using variables.py with ;-separator #37

Closed
jiuweigui opened this issue Aug 14, 2015 · 2 comments
Closed

Comments

@jiuweigui
Copy link

I noticed that when using --variablefile variables.py with ;-separator that quotes don't work the same way they work with pybot. When using either "- or '-quotes (i.e. "variables.py;arg1;arg2" or 'variables.py;arg1;arg2') pabot crashes with AssertError.

I have a simple test.robot:

(robot)# cat test.robot
*** TEST CASES ***
test0001
  Log To Console      ${TEST1}
  Log To Console      ${TEST2}

variables.py

(robot)# cat variables.py
def get_variables(arg1, arg2):
    variables = {   "TEST1": arg1,
                    "TEST2": arg2
                }
    return variables

my environment:

(robot)# python --version
Python 2.7.10
(robot)# pip list|grep robotframework
robotframework (2.9)
robotframework-pabot (0.16)

When I run the test with pybot:

(robot)# pybot --variablefile "variables.py;http://www.google.com;http://www.yahoo.com" test.robot
==============================================================================
Test
==============================================================================
test0001                                                              http://www.google.com
.http://www.yahoo.com
test0001                                                              | PASS |
------------------------------------------------------------------------------
Test                                                                  | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output:  /Users/jiuweigui/Examples/robot/output.xml
Log:     /Users/jiuweigui/Examples/robot/log.html
Report:  /Users/jiuweigui/Examples/robot/report.html

When I try to run the same thing with pabot:

(robot)# pabot --variablefile "variables.py;http://google.com;http://www.yahoo.com" test.robot
[PID:2310] EXECUTING Test
FAILED Test
Elapsed time: 0 minutes 0.454 seconds
Traceback (most recent call last):
  File "/Users/jiuweigui/.virtualenvs/robot/bin/pabot", line 6, in <module>
    main(sys.argv[1:])
  File "/Users/jiuweigui/.virtualenvs/robot/lib/python2.7/site-packages/pabot/pabot.py", line 354, in main
    sys.exit(_report_results(outs_dir, options, start_time_string, _get_suite_root_name(suite_names)))
  File "/Users/jiuweigui/.virtualenvs/robot/lib/python2.7/site-packages/pabot/pabot.py", line 286, in _report_results
    merge(sorted(glob(os.path.join(outs_dir, '**/*.xml'))), options, tests_root_name).save(output_path)
  File "/Users/jiuweigui/.virtualenvs/robot/lib/python2.7/site-packages/pabot/result_merger.py", line 116, in merge
    assert len(result_files) > 0
AssertionError
(robot)#

and 

(robot)# pabot --variablefile 'variables.py;http://google.com;http://www.yahoo.com' test.robot
[PID:2319] EXECUTING Test
FAILED Test
Elapsed time: 0 minutes 0.450 seconds
Traceback (most recent call last):
  File "/Users/jiuweigui/.virtualenvs/robot/bin/pabot", line 6, in <module>
    main(sys.argv[1:])
  File "/Users/jiuweigui/.virtualenvs/robot/lib/python2.7/site-packages/pabot/pabot.py", line 354, in main
    sys.exit(_report_results(outs_dir, options, start_time_string, _get_suite_root_name(suite_names)))
  File "/Users/jiuweigui/.virtualenvs/robot/lib/python2.7/site-packages/pabot/pabot.py", line 286, in _report_results
    merge(sorted(glob(os.path.join(outs_dir, '**/*.xml'))), options, tests_root_name).save(output_path)
  File "/Users/jiuweigui/.virtualenvs/robot/lib/python2.7/site-packages/pabot/result_merger.py", line 116, in merge
    assert len(result_files) > 0
AssertionError
(robot)#

However if I use both quotes everything passes and there's no assert:

(robot)# pabot --variablefile "'variables.py;http://google.com;http://www.yahoo.com'" test.robot
[PID:2328] EXECUTING Test
PASSED Test
Output:  /Users/jiuweigui/Examples/robot/output.xml
Log:     /Users/jiuweigui/Examples/robot/log.html
Report:  /Users/jiuweigui/Examples/robot/report.html
Elapsed time: 0 minutes 0.487 seconds
(robot)# cat pabot_results/Test/stdout.txt
==============================================================================
Test
==============================================================================
test0001                                                              http://google.com
http://www.yahoo.com
| PASS |
------------------------------------------------------------------------------
Test                                                                  | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output:  /Users/jiuweigui/Examples/robot/pabot_results/Test/output.xml
(robot)#

Based on the errors seen it looks like pabot interprets variables with ;-separator as shell commands and doesn't seem to honour quotes as pybot does. Using double and single quotes combined seems to solve the problem but is most likely not the intended way.

@mkorpela
Copy link
Owner

Thanks for a very clear bug report!

mkorpela added a commit that referenced this issue Aug 16, 2015
@mkorpela
Copy link
Owner

Fixed in:
c7b4e4e

Interesting bug! ";" is a special character that starts a new command in bash - thus needs to set quotes if parameter contains ";".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants