-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git push origin masterMerge branch 'mlk-35_mvn'
- Loading branch information
Showing
7 changed files
with
173 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
from thefuck.rules.mvn_no_command import match, get_new_command | ||
from tests.utils import Command | ||
|
||
|
||
@pytest.mark.parametrize('command', [ | ||
Command(script='mvn', stdout='[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]')]) | ||
def test_match(command): | ||
assert match(command, None) | ||
|
||
|
||
@pytest.mark.parametrize('command', [ | ||
Command(script='mvn clean', stdout=""" | ||
[INFO] Scanning for projects...[INFO] | ||
[INFO] ------------------------------------------------------------------------ | ||
[INFO] Building test 0.2 | ||
[INFO] ------------------------------------------------------------------------ | ||
[INFO] | ||
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test --- | ||
[INFO] Deleting /home/mlk/code/test/target | ||
[INFO] ------------------------------------------------------------------------ | ||
[INFO] BUILD SUCCESS | ||
[INFO] ------------------------------------------------------------------------ | ||
[INFO] Total time: 0.477s | ||
[INFO] Finished at: Wed Aug 26 13:05:47 BST 2015 | ||
[INFO] Final Memory: 6M/240M | ||
[INFO] ------------------------------------------------------------------------ | ||
"""), | ||
Command(script='mvn --help'), | ||
Command(script='mvn -v') | ||
]) | ||
def test_not_match(command): | ||
assert not match(command, None) | ||
|
||
@pytest.mark.parametrize('command, new_command', [ | ||
(Command(script='mvn', stdout='[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn clean package', 'mvn clean install']), | ||
(Command(script='mvn -N', stdout='[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn -N clean package', 'mvn -N clean install'])]) | ||
def test_get_new_command(command, new_command): | ||
assert get_new_command(command, None) == new_command | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
from thefuck.rules.mvn_unknown_lifecycle_phase import match, get_new_command | ||
from tests.utils import Command | ||
|
||
|
||
@pytest.mark.parametrize('command', [ | ||
Command(script='mvn cle', stdout='[ERROR] Unknown lifecycle phase "cle". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]')]) | ||
def test_match(command): | ||
assert match(command, None) | ||
|
||
|
||
@pytest.mark.parametrize('command', [ | ||
Command(script='mvn clean', stdout=""" | ||
[INFO] Scanning for projects...[INFO] | ||
[INFO] ------------------------------------------------------------------------ | ||
[INFO] Building test 0.2 | ||
[INFO] ------------------------------------------------------------------------ | ||
[INFO] | ||
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test --- | ||
[INFO] Deleting /home/mlk/code/test/target | ||
[INFO] ------------------------------------------------------------------------ | ||
[INFO] BUILD SUCCESS | ||
[INFO] ------------------------------------------------------------------------ | ||
[INFO] Total time: 0.477s | ||
[INFO] Finished at: Wed Aug 26 13:05:47 BST 2015 | ||
[INFO] Final Memory: 6M/240M | ||
[INFO] ------------------------------------------------------------------------ | ||
"""), | ||
Command(script='mvn --help'), | ||
Command(script='mvn -v') | ||
]) | ||
def test_not_match(command): | ||
assert not match(command, None) | ||
|
||
@pytest.mark.parametrize('command, new_command', [ | ||
(Command(script='mvn cle', stdout='[ERROR] Unknown lifecycle phase "cle". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn clean', 'mvn compile']), | ||
(Command(script='mvn claen package', stdout='[ERROR] Unknown lifecycle phase "claen". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn clean package'])]) | ||
def test_get_new_command(command, new_command): | ||
assert get_new_command(command, None) == new_command | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from thefuck.utils import for_app | ||
|
||
|
||
@for_app('mvn') | ||
def match(command, settings): | ||
return 'No goals have been specified for this build' in command.stdout | ||
|
||
|
||
def get_new_command(command, settings): | ||
return [command.script + ' clean package', | ||
command.script + ' clean install'] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from thefuck.utils import replace_command, for_app | ||
from difflib import get_close_matches | ||
import re | ||
|
||
|
||
def _get_failed_lifecycle(command): | ||
return re.search(r'\[ERROR\] Unknown lifecycle phase "(.+)"', | ||
command.stdout) | ||
|
||
|
||
def _getavailable_lifecycles(command): | ||
return re.search( | ||
r'Available lifecycle phases are: (.+) -> \[Help 1\]', command.stdout) | ||
|
||
|
||
@for_app('mvn') | ||
def match(command, settings): | ||
failed_lifecycle = _get_failed_lifecycle(command) | ||
available_lifecycles = _getavailable_lifecycles(command) | ||
return available_lifecycles and failed_lifecycle | ||
|
||
|
||
def get_new_command(command, settings): | ||
failed_lifecycle = _get_failed_lifecycle(command) | ||
available_lifecycles = _getavailable_lifecycles(command) | ||
if available_lifecycles and failed_lifecycle: | ||
selected_lifecycle = get_close_matches( | ||
failed_lifecycle.group(1), available_lifecycles.group(1).split(", "), | ||
3, 0.6) | ||
return replace_command(command, failed_lifecycle.group(1), selected_lifecycle) | ||
else: | ||
return [] |
This file contains 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