Created
December 13, 2011 12:45
-
-
Save brickZA/1472011 to your computer and use it in GitHub Desktop.
Tests for quoting with fabric.contrib.files.append. original.txt is generated using 6c483ef261ab8ed243b39a337b0382a8c84e5994, patched version using 6d91ffff8cb1c9ed468475a6ca4d167751f4dff0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test (one) | |
test '(' \ ) two | |
test "'three)' '' the | |
test \'a\'$ four | |
test ""'""'' five | |
^six $(('")"((thing)it's)'\'')'' test$ | |
_test%(seven')') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import with_statement | |
from fabric.api import cd, hosts, run, settings | |
from fabric.contrib import files | |
import tempfile | |
import shutil | |
@hosts('localhost') | |
def test_compare(delete_tmp='yes'): | |
test_lines = [s.replace('\n', '') for s in open('examples.txt').readlines()] | |
td = tempfile.mkdtemp() | |
print 'tmpdir: %s' % td | |
with cd(td): | |
with settings(warn_only=True): | |
for i in range(len(test_lines)): | |
tl = test_lines[i] | |
tf = 'example%d.txt' % (i+1) | |
files.append(tf, tl) | |
files.append(tf, tl) | |
run('cat %s' % tf) | |
if delete_tmp == 'yes': | |
shutil.rmtree(td) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[localhost] Executing task 'test_compare' | |
tmpdir: /tmp/tmpkGR7dB | |
[localhost] run: echo 'test (one)' >> example1.txt | |
[localhost] run: cat example1.txt | |
[localhost] out: test (one) | |
[localhost] run: echo 'test \'(\' \ ) two' >> example2.txt | |
[localhost] out: /bin/bash: -c: line 0: syntax error near unexpected token `(' | |
[localhost] out: /bin/bash: -c: line 0: `cd /tmp/tmpkGR7dB && echo 'test \'(\' \ ) two' >> example2.txt' | |
Warning: run() encountered an error (return code 1) while executing 'echo 'test \'(\' \ ) two' >> example2.txt' | |
[localhost] run: echo 'test \'(\' \ ) two' >> example2.txt | |
[localhost] out: /bin/bash: -c: line 0: syntax error near unexpected token `(' | |
[localhost] out: /bin/bash: -c: line 0: `cd /tmp/tmpkGR7dB && echo 'test \'(\' \ ) two' >> example2.txt' | |
Warning: run() encountered an error (return code 1) while executing 'echo 'test \'(\' \ ) two' >> example2.txt' | |
[localhost] run: cat example2.txt | |
[localhost] out: cat: example2.txt: No such file or directory | |
Warning: run() encountered an error (return code 1) while executing 'cat example2.txt' | |
[localhost] run: echo 'test "\'three)\' \'\' the' >> example3.txt | |
[localhost] out: /bin/bash: -c: line 0: syntax error near unexpected token `)' | |
[localhost] out: /bin/bash: -c: line 0: `cd /tmp/tmpkGR7dB && echo 'test "\'three)\' \'\' the' >> example3.txt' | |
Warning: run() encountered an error (return code 1) while executing 'echo 'test "\'three)\' \'\' the' >> example3.txt' | |
[localhost] run: echo 'test "\'three)\' \'\' the' >> example3.txt | |
[localhost] out: /bin/bash: -c: line 0: syntax error near unexpected token `)' | |
[localhost] out: /bin/bash: -c: line 0: `cd /tmp/tmpkGR7dB && echo 'test "\'three)\' \'\' the' >> example3.txt' | |
Warning: run() encountered an error (return code 1) while executing 'echo 'test "\'three)\' \'\' the' >> example3.txt' | |
[localhost] run: cat example3.txt | |
[localhost] out: cat: example3.txt: No such file or directory | |
Warning: run() encountered an error (return code 1) while executing 'cat example3.txt' | |
[localhost] run: echo 'test \\'a\\'$ four' >> example4.txt | |
[localhost] out: /bin/bash: -c: line 0: unexpected EOF while looking for matching `'' | |
[localhost] out: /bin/bash: -c: line 1: syntax error: unexpected end of file | |
Warning: run() encountered an error (return code 1) while executing 'echo 'test \\'a\\'$ four' >> example4.txt' | |
[localhost] run: echo 'test \\'a\\'$ four' >> example4.txt | |
[localhost] out: /bin/bash: -c: line 0: unexpected EOF while looking for matching `'' | |
[localhost] out: /bin/bash: -c: line 1: syntax error: unexpected end of file | |
Warning: run() encountered an error (return code 1) while executing 'echo 'test \\'a\\'$ four' >> example4.txt' | |
[localhost] run: cat example4.txt | |
[localhost] out: cat: example4.txt: No such file or directory | |
Warning: run() encountered an error (return code 1) while executing 'cat example4.txt' | |
[localhost] run: echo 'test ""\'""\'\' five' >> example5.txt | |
[localhost] out: /bin/bash: -c: line 0: unexpected EOF while looking for matching `'' | |
[localhost] out: /bin/bash: -c: line 1: syntax error: unexpected end of file | |
Warning: run() encountered an error (return code 1) while executing 'echo 'test ""\'""\'\' five' >> example5.txt' | |
[localhost] run: echo 'test ""\'""\'\' five' >> example5.txt | |
[localhost] out: /bin/bash: -c: line 0: unexpected EOF while looking for matching `'' | |
[localhost] out: /bin/bash: -c: line 1: syntax error: unexpected end of file | |
Warning: run() encountered an error (return code 1) while executing 'echo 'test ""\'""\'\' five' >> example5.txt' | |
[localhost] run: cat example5.txt | |
[localhost] out: cat: example5.txt: No such file or directory | |
Warning: run() encountered an error (return code 1) while executing 'cat example5.txt' | |
[localhost] run: echo '^six $((\'")"((thing)it\'s)\'\\'\')\'\' test$' >> example6.txt | |
[localhost] out: /bin/bash: -c: line 0: syntax error near unexpected token `(' | |
[localhost] out: /bin/bash: -c: line 0: `cd /tmp/tmpkGR7dB && echo '^six $((\'")"((thing)it\'s)\'\'\')\'\' test$' >> example6.txt' | |
Warning: run() encountered an error (return code 1) while executing 'echo '^six $((\'")"((thing)it\'s)\'\\'\')\'\' test$' >> example6.txt' | |
[localhost] run: echo '^six $((\'")"((thing)it\'s)\'\\'\')\'\' test$' >> example6.txt | |
[localhost] out: /bin/bash: -c: line 0: syntax error near unexpected token `(' | |
[localhost] out: /bin/bash: -c: line 0: `cd /tmp/tmpkGR7dB && echo '^six $((\'")"((thing)it\'s)\'\'\')\'\' test$' >> example6.txt' | |
Warning: run() encountered an error (return code 1) while executing 'echo '^six $((\'")"((thing)it\'s)\'\\'\')\'\' test$' >> example6.txt' | |
[localhost] run: cat example6.txt | |
[localhost] out: cat: example6.txt: No such file or directory | |
Warning: run() encountered an error (return code 1) while executing 'cat example6.txt' | |
[localhost] run: echo '_test%(seven\')\')' >> example7.txt | |
[localhost] out: /bin/bash: -c: line 0: syntax error near unexpected token `)' | |
[localhost] out: /bin/bash: -c: line 0: `cd /tmp/tmpkGR7dB && echo '_test%(seven\')\')' >> example7.txt' | |
Warning: run() encountered an error (return code 1) while executing 'echo '_test%(seven\')\')' >> example7.txt' | |
[localhost] run: echo '_test%(seven\')\')' >> example7.txt | |
[localhost] out: /bin/bash: -c: line 0: syntax error near unexpected token `)' | |
[localhost] out: /bin/bash: -c: line 0: `cd /tmp/tmpkGR7dB && echo '_test%(seven\')\')' >> example7.txt' | |
Warning: run() encountered an error (return code 1) while executing 'echo '_test%(seven\')\')' >> example7.txt' | |
[localhost] run: cat example7.txt | |
[localhost] out: cat: example7.txt: No such file or directory | |
Warning: run() encountered an error (return code 1) while executing 'cat example7.txt' | |
Done. | |
Disconnecting from localhost... done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[localhost] Executing task 'test_compare' | |
tmpdir: /tmp/tmpXt5cpS | |
[localhost] run: echo 'test (one)' >> example1.txt | |
[localhost] run: cat example1.txt | |
[localhost] out: test (one) | |
[localhost] run: echo 'test '\\''('\\'' \ ) two' >> example2.txt | |
[localhost] run: cat example2.txt | |
[localhost] out: test '(' \ ) two | |
[localhost] run: echo 'test "'\\''three)'\\'' '\\'''\\'' the' >> example3.txt | |
[localhost] run: cat example3.txt | |
[localhost] out: test "'three)' '' the | |
[localhost] run: echo 'test \'\\''a\'\\''$ four' >> example4.txt | |
[localhost] run: cat example4.txt | |
[localhost] out: test \'a\'$ four | |
[localhost] run: echo 'test ""'\\''""'\\'''\\'' five' >> example5.txt | |
[localhost] run: cat example5.txt | |
[localhost] out: test ""'""'' five | |
[localhost] run: echo '^six $(('\\''")"((thing)it'\\''s)'\\''\'\\'''\\'')'\\'''\\'' test$' >> example6.txt | |
[localhost] run: cat example6.txt | |
[localhost] out: ^six $(('")"((thing)it's)'\'')'' test$ | |
[localhost] run: echo '_test%(seven'\\'')'\\'')' >> example7.txt | |
[localhost] run: cat example7.txt | |
[localhost] out: _test%(seven')') | |
Done. | |
Disconnecting from localhost... done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment