3 new revisions:
Revision: bba210bb2ddc
Author: Robot Framework Developers <[email protected]>
Date: Fri Jan 13 05:46:27 2012
Log: TidyLib: renamed keyword
http://code.google.com/p/robotframework/source/detail?r=bba210bb2ddc
Revision: 2a6caad5de4e
Author: Robot Framework Developers <[email protected]>
Date: Fri Jan 13 05:47:07 2012
Log: OperatingSystem: fix incorrect docs
http://code.google.com/p/robotframework/source/detail?r=2a6caad5de4e
Revision: 9bd8b712c416
Author: Robot Framework Developers <[email protected]>
Date: Fri Jan 13 05:47:36 2012
Log: tidy: handle directories recursively
http://code.google.com/p/robotframework/source/detail?r=9bd8b712c416
==============================================================================
Revision: bba210bb2ddc
Author: Robot Framework Developers <[email protected]>
Date: Fri Jan 13 05:46:27 2012
Log: TidyLib: renamed keyword
http://code.google.com/p/robotframework/source/detail?r=bba210bb2ddc
Modified:
/atest/robot/tidy/TidyLib.py
=======================================
--- /atest/robot/tidy/TidyLib.py Fri Jan 13 04:28:56 2012
+++ /atest/robot/tidy/TidyLib.py Fri Jan 13 05:46:27 2012
@@ -13,7 +13,7 @@
def __init__(self, interpreter):
self._cmd = [interpreter, '-m', 'robot.tidy']
- def run_tidy_and_return_output(self, input, options):
+ def run_tidy(self, input, options):
options = options.split(' ') if options else []
with tempfile.TemporaryFile() as output:
rc = call(self._cmd + options + [self._path(input)],
@@ -25,13 +25,13 @@
raise RuntimeError(content)
return content
- def _path(self, path):
- return path.replace('/', os.sep)
-
def run_tidy_and_check_result(self, input, options, expected):
- result = self.run_tidy_and_return_output(input, options)
+ result = self.run_tidy(input, options)
self._assert_result(result, open(self._path(expected)).read())
+ def _path(self, path):
+ return path.replace('/', os.sep)
+
def _assert_result(self, result, expected):
for line1, line2 in zip(result.split(), expected.split()):
msg = "\n%s\n!=\n%s\n" % (result, expected)
==============================================================================
Revision: 2a6caad5de4e
Author: Robot Framework Developers <[email protected]>
Date: Fri Jan 13 05:47:07 2012
Log: OperatingSystem: fix incorrect docs
http://code.google.com/p/robotframework/source/detail?r=2a6caad5de4e
Modified:
/src/robot/libraries/OperatingSystem.py
=======================================
--- /src/robot/libraries/OperatingSystem.py Thu Jul 21 03:26:50 2011
+++ /src/robot/libraries/OperatingSystem.py Fri Jan 13 05:47:07 2012
@@ -1114,13 +1114,13 @@
return count
def count_files_in_directory(self, path, pattern=None):
- """A wrapper for `Count Items In Directory` returning onlyt
directory count."""
+ """A wrapper for `Count Items In Directory` returning only file
count."""
count = len(self._list_files_in_dir(path, pattern))
self._info("%s file%s." % (count, plural_or_not(count)))
return count
def count_directories_in_directory(self, path, pattern=None):
- """A wrapper for `Count Items In Directory` returning only file
count."""
+ """A wrapper for `Count Items In Directory` returning only
directory count."""
count = len(self._list_dirs_in_dir(path, pattern))
self._info("%s director%s." % (count, 'y' if count == 1
else 'ies'))
return count
==============================================================================
Revision: 9bd8b712c416
Author: Robot Framework Developers <[email protected]>
Date: Fri Jan 13 05:47:36 2012
Log: tidy: handle directories recursively
http://code.google.com/p/robotframework/source/detail?r=9bd8b712c416
Added:
/atest/testdata/tidy/tests/__init__.txt
/atest/testdata/tidy/tests/sub/sub1.txt
/atest/testdata/tidy/tests/suite1.txt
Modified:
/atest/robot/tidy/tidy.txt
/src/robot/tidy.py
=======================================
--- /dev/null
+++ /atest/testdata/tidy/tests/__init__.txt Fri Jan 13 05:47:36 2012
@@ -0,0 +1,2 @@
+*** Settings ***
+Force Tags tag1 tag2
=======================================
--- /dev/null
+++ /atest/testdata/tidy/tests/sub/sub1.txt Fri Jan 13 05:47:36 2012
@@ -0,0 +1,3 @@
+*** Test Cases ***
+A Failing test
+ Fail some failure
=======================================
--- /dev/null
+++ /atest/testdata/tidy/tests/suite1.txt Fri Jan 13 05:47:36 2012
@@ -0,0 +1,15 @@
+*** Variables ***
+${MyVar} a value
+
+*** Test Cases ***
+My Test Case
+ [Documentation] This is an example test case
+ Log ${MyVar}
+
+Another Test
+ My Keyword
+
+*** Keywords ***
+My Keyword
+ : FOR ${i} IN RANGE 10
+ \ Log ${i}
=======================================
--- /atest/robot/tidy/tidy.txt Fri Jan 13 04:28:56 2012
+++ /atest/robot/tidy/tidy.txt Fri Jan 13 05:47:36 2012
@@ -2,6 +2,7 @@
Force Tags pybot jybot
Library TidyLib.py ${INTERPRETER}
Library OperatingSystem
+Resource atest_resource.txt
*** Variables ***
${DATADIR} ${CURDIR}/../../testdata/tidy
@@ -24,6 +25,16 @@
Tidying single init file
Run tidy and check result ${DATADIR}/__init__.txt ${EMPTY}
${DATADIR}/__init__.txt
+Tidying directory
+ [Setup] Copy Directory ${DATADIR}/tests ${TEMPDIR}/tests
+ ${output_before}= Run Robot Directly ${DATADIR}/tests
+ Run Tidy ${TEMPDIR}/tests --recursive --format tsv
+ Check file count ${TEMPDIR}/tests *.tsv 2
+ Check file count ${TEMPDIR}/tests *.txt 0
+ ${output_after}= Run Robot Directly ${TEMPDIR}/tests
+ Should Be Equal ${output_before} ${output_after}
+ [Teardown] Remove Directory ${TEMPDIR}/tests recurisive=True
+
*** Keywords ***
Run tidy with golden file and check result
[Arguments] ${options} ${expected_result_file}
@@ -33,3 +44,8 @@
[Arguments] ${options} ${expected_result_file}
Run tidy and check result ${DATADIR}/golden_resource.txt
${options} ${expected_result_file}
+Check file count
+ [Arguments] ${directory} ${pattern} ${expected count}
+ ${files}= Count Files In Directory ${directory} ${pattern}
+ Should Be Equal As Numbers ${files} ${expected count}
+
=======================================
--- /src/robot/tidy.py Fri Jan 13 04:26:24 2012
+++ /src/robot/tidy.py Fri Jan 13 05:47:36 2012
@@ -29,7 +29,7 @@
from robot import utils
from robot.errors import DataError
-from robot.parsing import TestCaseFile, ResourceFile, TestDataDirectory
+from robot.parsing import TestData, ResourceFile, TestDataDirectory
from robot.parsing.populators import FromFilePopulator
def _exit(message, status):
@@ -52,13 +52,23 @@
FromFilePopulator(data).populate(source)
return data
try:
- return TestCaseFile(source=source).populate()
+ return TestData(source=source)
except DataError, err:
try:
return ResourceFile(source=source).populate()
except DataError:
_exit("Invalid data source '%s': %s" % (source, unicode(err)),
1)
+def _save_recursively(data, **options):
+ init_file = getattr(data, 'initfile', None)
+ if init_file or not hasattr(data, 'initfile'):
+ data.save(**options)
+ if os.path.isfile(data.source):
+ os.remove(data.source)
+ if init_file:
+ os.remove(init_file)
+ for child in data.children:
+ _save_recursively(child, **options)
if __name__ == '__main__':
opts, args = _parse_args()
@@ -68,4 +78,7 @@
datafile.save(output=output, format=opts['format'],
pipe_separated=opts['use-pipes'])
print output.getvalue()
+ if opts['recursive']:
+ _save_recursively(datafile, format=opts['format'],
+ pipe_separated=opts['use-pipes'])
_exit("", 0)