Directing output logs to folders

1,660 views
Skip to first unread message

Rajaraman

unread,
Nov 24, 2010, 4:44:27 AM11/24/10
to robotframework-users, sudip...@mindtree.com
I have created a folder structure in my Test Results\ directory which
corresponds to my tree folder structure in my Test Cases\ directory

Test Cases\
Suite A
Suite A1
A2.html

Rajaraman

unread,
Nov 24, 2010, 4:54:48 AM11/24/10
to robotframework-users, sudip...@mindtree.com
I want to direct my output log files after splitting outputs to
different folders. Let us say my folder structure in Test Results\
corresponds to the Test Cases\ folder structure as follows:

Test Cases\
<Application Name>
Suite A
Suite A1
A2.html
A3.html
Suite B
Suite B1
B2.html
B3.html

Test Results\
Run <TimeStamp>
<Application Name>
Suite A
Suite A1
A2
A3
Suite B
Suite B1
B2
B3

I want to create the Test Results folder structure dynamically as the
test cases are being run from Robot and direct the split output logs
at each level to the corresponding folders. The TimeStamp will also be
generated on the fly. Is there a way we can direct outputs to folders
keeping the --outputdir / ---log / --output paths as
variables instead of keeping them fixed apriori?


Please let me know....


Thanks,

Rajaraman.

Pekka Klärck

unread,
Nov 28, 2010, 9:54:33 AM11/28/10
to rajaraman_...@mindtree.com, robotframework-users, sudip...@mindtree.com
2010/11/24 Rajaraman <rajaraman_...@mindtree.com>:

> I want to direct my output log files after splitting outputs to
> different folders.

Unfortunately that's not possible. The current output splitting logic
is already so complicated that adding more features into it would be
pretty hard. We have, in fact, been thinking about simplifying it a
little some time in the future.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Rajaraman Swaminathan

unread,
Nov 28, 2010, 11:28:15 PM11/28/10
to Pekka Klärck, robotframework-users, Sudip Naha
Hi,

I found a way to direct output to folders. It is a little complex but possible. For those interested I provide the following info with code.

We can store the test suites as they are run with full path in a text file in the order in which they were executed using ${SUITESOURCE}. We sort this file using a python program which looks at the length of the array with respect to split operation on these suite paths using '\\'.

We exchange 2 elements in the file if a path of length which is lower occurs later (below). We then use a recursive function call to the sort function to ensure that no path with higher length occurs later. This order of the newly sorted suite paths file it turns out is the same as what we can do using splitoutputs with rebot at each tree level.

Whatever output and log files are generated from splitoutputs using rebot we sort alphabetically and move to the sorted suite file path dirs which are created in a separate test results folder now in that order.


Please find attached the several files used for running this operation.

Thanks & Regards,

Rajaraman.

________________________________

http://www.mindtree.com/email/disclaimer.html

MoveFiles.py
Sort.py
Run.txt

Rajaraman Swaminathan

unread,
Nov 28, 2010, 11:55:30 PM11/28/10
to Rajaraman Swaminathan, Pekka Klärck, robotframework-users, Sudip Naha
Please find also attached the batch file used for the below purpose as discussed.


Regards,

Rajaraman.


-----Original Message-----
From: Rajaraman Swaminathan
Sent: Monday, November 29, 2010 9:58 AM
To: 'Pekka Klärck'
Cc: robotframework-users; Sudip Naha
Subject: RE: Directing output logs to folders

Hi,

I found a way to direct output to folders. It is a little complex but possible. For those interested I provide the following info with code.

We can store the test suites as they are run with full path in a text file in the order in which they were executed using ${SUITESOURCE}. We sort this file using a python program which looks at the length of the array with respect to split operation on these suite paths using '\\'.

We exchange 2 elements in the file if a path of length which is lower occurs later (below). We then use a recursive function call to the sort function to ensure that no path with higher length occurs later. This order of the newly sorted suite paths file it turns out is the same as what we can do using splitoutputs with rebot at each tree level.

Whatever output and log files are generated from splitoutputs using rebot we sort alphabetically and move to the sorted suite file path dirs which are created in a separate test results folder now in that order.


Please find attached the several files used for running this operation.

Thanks & Regards,

Rajaraman.

-----Original Message-----
From: pekka....@gmail.com [mailto:pekka....@gmail.com] On Behalf Of Pekka Klärck
Sent: Sunday, November 28, 2010 8:25 PM
To: Rajaraman Swaminathan
Cc: robotframework-users; Sudip Naha
Subject: Re: Directing output logs to folders

________________________________

http://www.mindtree.com/email/disclaimer.html

Batch File.zip

mb963

unread,
Jun 15, 2015, 3:44:55 PM6/15/15
to robotframe...@googlegroups.com, pe...@iki.fi, rajaraman_...@mindtree.com, Sudip...@mindtree.com, Rajaraman_...@mindtree.com
I am trying to find better documentation for the 'Process Library', so that I can route the test results to the folders of my choice and happened to encounter Rajaraman's post. I am extremely new to Robot Framework and the Selenium world, this elaborate and neat logic to create dynamic folders structure is very cool. However, I need insight into the basic version to simple redirect results into custom folders for now, as we don't have a huge suite currently. 

The keywords from the Process library that I am trying to use are: 

Standard output and error streams

By default processes are run so that their standard output and standard error streams are kept in the memory. This works fine normally, but if there is a lot of output, the output buffers may get full and the program can hang. Additionally on Jython, everything written to these in-memory buffers can be lost if the process is terminated.

To avoid the above mentioned problems, it is possible to use stdout and stderr arguments to specify files on the file system where to redirect the outputs. This can also be useful if other processes or other keywords need to read or manipulate the outputs somehow.

Given stdout and stderr paths are relative to the current working directory. Forward slashes in the given paths are automatically converted to backslashes on Windows.

As a special feature, it is possible to redirect the standard error to the standard output by using stderr=STDOUT.

Regardless are outputs redirected to files or not, they are accessible through the result object returned when the process ends.

Examples:

${result} =Run Processprogramstdout=${TEMPDIR}/stdout.txtstderr=${TEMPDIR}/stderr.txt
Log Manystdout: ${result.stdout}stderr: ${result.stderr}
${result} =Run Processprogramstderr=STDOUT
Logall output: ${result.stdout}

Note that the created output files are not automatically removed after the test run. The user is responsible to remove them if needed.

I am not sure where and how I can specify my folder hierarchy using these keywords. I am open to using other options that would serve this purpose too. 

Thank you,

MB
Reply all
Reply to author
Forward
0 new messages