Luxoft / Twister

Twister Test Automation Framework
http://www.twistertesting.com/
Apache License 2.0
38 stars 21 forks source link

Stack trace isn't printed for Perl tests #146

Closed jashanka closed 9 years ago

jashanka commented 9 years ago

I'm trying to run some demo/sample Perl tests in Twister, and noticed that when there is any syntax error, stack trace isn't printed for Perl (like we get it for Python tests). It simply prints like "Perl returned code 255 " Could you please suggest any process to get it or may point it in the document.

croqaz commented 9 years ago

Hello @jashanka, You are right, it was impossible to debug Perl tests, but now with the commit today if something crashes (for example: an unused variable, if you forget to put ; at the end of the line, etc) you will see exactly where is the problem. Please update with the latest version.

jashanka commented 9 years ago

Fantastic! Thanks for update. I'll try it soon I can.

jashanka commented 9 years ago

Hi Cristi,

I checked your fix it's working.

JFYI, the line number what it prints in the error message is not really same as original Perl scripts but it's of temporary Perl script that gets generated during the run at ".twister_cache" path.

Also few quick questions, (as I couldn't or missed to spot any info in documentation)

1). When we call 'get_resource()' (or any such) function within Perl, the output is a dictionary, which is basically a Python data structure. So how could we iterate over them in Perl? Do we need to parse it using regex or should we use any module?

2) In Twister user guide, under "15 How to write tests" section it's given as "Twister framework can run Python, TCL and Perl (limited) tests." Could you please briefly explain what limitations we may have for Perl.

BTW, just going through your blog "Tech, Spirit, Art" it's interesting :)

Thanks,

croqaz commented 9 years ago

Hello,

You are right, the line number in Perl tests is offset by about 16 lines, because a header is added to the test automatically.

When you call get_resource, the Python dictionary can be considered a JSON string that you could parse using a JSON library for Perl. There are cases when this will fail, for example if you have ' or " characters inside the resource names, or values, depending of the case ...

Unfortunately I don't know Perl enough to help you much, BUT if you call a long path to your resource, you shouldn't need to parse the dictionary. For example, if your resource is like Testbed1 > Module1 > Resource1 > property_1, you can call get_resource('/Testbed1/Module1/Resource1:property_1') which is a normal Perl string.

About the Perl tests being "limited", this is no longer the case! The documentation must be updated there.

PS: Thank you very much, about my blog :)