mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 07:04:12 +00:00 
			
		
		
		
	Merge pull request #343 from mlk/hdfs-rm-rm_X_Is_a_directory_add_minus_r
hdfs -rm -r /directory and hdfs -mkdir -p /directory/sub support
This commit is contained in:
		| @@ -3,20 +3,29 @@ from thefuck.rules.mkdir_p import match, get_new_command | |||||||
| from tests.utils import Command | from tests.utils import Command | ||||||
|  |  | ||||||
|  |  | ||||||
| def test_match(): | @pytest.mark.parametrize('command', [ | ||||||
|     assert match(Command('mkdir foo/bar/baz', |     Command('mkdir foo/bar/baz', stderr='mkdir: foo/bar: No such file or directory'), | ||||||
|                          stderr='mkdir: foo/bar: No such file or directory'), |     Command('./bin/hdfs dfs -mkdir foo/bar/baz', stderr='mkdir: `foo/bar/baz\': No such file or directory'), | ||||||
|                  None) |     Command('hdfs dfs -mkdir foo/bar/baz', stderr='mkdir: `foo/bar/baz\': No such file or directory') | ||||||
|  |     ]) | ||||||
|  | def test_match(command): | ||||||
|  |     assert match(command, None) | ||||||
|  |  | ||||||
|  |  | ||||||
| @pytest.mark.parametrize('command', [ | @pytest.mark.parametrize('command', [ | ||||||
|     Command('mkdir foo/bar/baz'), |     Command('mkdir foo/bar/baz'), | ||||||
|     Command('mkdir foo/bar/baz', stderr='foo bar baz'), |     Command('mkdir foo/bar/baz', stderr='foo bar baz'), | ||||||
|  |     Command('hdfs dfs -mkdir foo/bar/baz'), | ||||||
|  |     Command('./bin/hdfs dfs -mkdir foo/bar/baz'), | ||||||
|     Command()]) |     Command()]) | ||||||
| def test_not_match(command): | def test_not_match(command): | ||||||
|     assert not match(command, None) |     assert not match(command, None) | ||||||
|  |  | ||||||
|  |  | ||||||
| def test_get_new_command(): | @pytest.mark.parametrize('command, new_command', [ | ||||||
|     assert get_new_command(Command('mkdir foo/bar/baz'), None)\ |     (Command('mkdir foo/bar/baz'), 'mkdir -p foo/bar/baz'), | ||||||
|            == 'mkdir -p foo/bar/baz' |     (Command('hdfs dfs -mkdir foo/bar/baz'), 'hdfs dfs -mkdir -p foo/bar/baz'), | ||||||
|  |     (Command('./bin/hdfs dfs -mkdir foo/bar/baz'), './bin/hdfs dfs -mkdir -p foo/bar/baz')]) | ||||||
|  | def test_get_new_command(command, new_command): | ||||||
|  |     assert get_new_command(command, None) == new_command | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,17 +5,27 @@ from tests.utils import Command | |||||||
|  |  | ||||||
| @pytest.mark.parametrize('command', [ | @pytest.mark.parametrize('command', [ | ||||||
|     Command('rm foo', stderr='rm: foo: is a directory'), |     Command('rm foo', stderr='rm: foo: is a directory'), | ||||||
|     Command('rm foo', stderr='rm: foo: Is a directory')]) |     Command('rm foo', stderr='rm: foo: Is a directory'), | ||||||
|  |     Command('hdfs dfs -rm foo', stderr='rm: `foo`: Is a directory'), | ||||||
|  |     Command('./bin/hdfs dfs -rm foo', stderr='rm: `foo`: Is a directory') | ||||||
|  |     ]) | ||||||
| def test_match(command): | def test_match(command): | ||||||
|     assert match(command, None) |     assert match(command, None) | ||||||
|     assert match(command, None) |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @pytest.mark.parametrize('command', [ | @pytest.mark.parametrize('command', [ | ||||||
|     Command('rm foo'), Command('rm foo'), Command()]) |     Command('rm foo'),  | ||||||
|  |     Command('hdfs dfs -rm foo'), | ||||||
|  |     Command('./bin/hdfs dfs -rm foo'),   | ||||||
|  |     Command()]) | ||||||
| def test_not_match(command): | def test_not_match(command): | ||||||
|     assert not match(command, None) |     assert not match(command, None) | ||||||
|  |  | ||||||
|  |  | ||||||
| def test_get_new_command(): | @pytest.mark.parametrize('command, new_command', [ | ||||||
|     assert get_new_command(Command('rm foo', '', ''), None) == 'rm -rf foo' |     (Command('rm foo'), 'rm -rf foo'), | ||||||
|  |     (Command('hdfs dfs -rm foo'), 'hdfs dfs -rm -r foo')]) | ||||||
|  | def test_get_new_command(command, new_command): | ||||||
|  |     assert get_new_command(command, None) == new_command | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,4 +10,4 @@ def match(command, settings): | |||||||
|  |  | ||||||
| @sudo_support | @sudo_support | ||||||
| def get_new_command(command, settings): | def get_new_command(command, settings): | ||||||
|     return re.sub('^mkdir (.*)', 'mkdir -p \\1', command.script) |     return re.sub('\\bmkdir (.*)', 'mkdir -p \\1', command.script) | ||||||
|   | |||||||
| @@ -10,4 +10,7 @@ def match(command, settings): | |||||||
|  |  | ||||||
| @sudo_support | @sudo_support | ||||||
| def get_new_command(command, settings): | def get_new_command(command, settings): | ||||||
|     return re.sub('^rm (.*)', 'rm -rf \\1', command.script) |     arguments = '-rf' | ||||||
|  |     if 'hdfs' in command.script: | ||||||
|  |         arguments = '-r' | ||||||
|  |     return re.sub('\\brm (.*)', 'rm ' + arguments + ' \\1', command.script) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user