diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 613addba..84607ec8 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,6 +1,6 @@ [bumpversion] commit = True -current_version = 0.13.0 +current_version = 0.14.0 files = plugin/pymode.vim tag = True tag_name = {new_version} @@ -8,3 +8,7 @@ tag_name = {new_version} [bumpversion:file:doc/pymode.txt] search = Version: {current_version} replace = Version: {new_version} + +[bumpversion:file:CHANGELOG.md] +search = Version: {current_version} +replace = Version: {new_version} diff --git a/.gitmodules b/.gitmodules index 4874edc5..59d00541 100644 --- a/.gitmodules +++ b/.gitmodules @@ -48,3 +48,12 @@ [submodule "submodules/toml"] path = submodules/toml url = https://github.com/uiri/toml.git +[submodule "submodules/pytoolconfig"] + path = submodules/pytoolconfig + url = https://github.com/bagel897/pytoolconfig.git +[submodule "submodules/tomli"] + path = submodules/tomli + url = https://github.com/hukkin/tomli.git +[submodule "submodules/appdirs"] + path = submodules/appdirs + url = https://github.com/ActiveState/appdirs.git diff --git a/CHANGELOG.md b/CHANGELOG.md index 001a9194..4e7668dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,38 @@ ## TODO +## 2023-07-02 0.14.0 + +- Update submodules + - Fix Errors related to these updates +- Improve tests outputs +- Fix Global and Module MoveRefactoring (#1141) Thanks to @lieryan +- Text object/operator/motion mapping to select logical line (#1145). Thanks to + @lieryan +- Remove dead keywords and builtins; add match, case (#1149). Thanks to + @NeilGirdhar +- Add syntax highlight for walrus (#1147) Thanks to @fpob +- Add configurable prefix for rope commands (#1137) TThanks to @NathanTP +- Add option g:pymode_indent_hanging_width for different hanging indentation + width (#1138). Thanks to @wookayin + +## 2020-10-08 0.13.0 + +- Add toml submodule + +## 2020-10-08 0.12.0 + +- Improve breakpoint feature +- Improve debugging script +- Update submodules +- Improve tests + +## 2020-05-28 0.11.0 + - Move changelog rst syntax to markdown - `pymode_rope`: check disables -- Remove supoort for python 2. From 0.11.0 on we will focus on supporting - python 3+ (probably 3.5+). +- BREAKING CHANGE: Remove supoort for python 2. From 0.11.0 on we will focus on + supporting python 3+ (probably 3.5+). - Inspect why files starting with the following code do not get loaded: ```python @@ -16,6 +44,12 @@ main() ``` +- added github actions test suit and remove travis +- improved submodules cloning (shallow) +- Removes `six` submodule +- Fix motion mapping +- Fix breakpoint feature + ## 2019-05-11 0.10.0 After many changes, including moving most of our dependencies from copied diff --git a/doc/pymode.txt b/doc/pymode.txt index 65f3e9a4..7235b5d5 100644 --- a/doc/pymode.txt +++ b/doc/pymode.txt @@ -6,7 +6,7 @@ (__) (__) (__) (_) (_)(_____)(_)\_) (_/\/\_)(_____)(____/(____) ~ - Version: 0.13.0 + Version: 0.14.0 =============================================================================== CONTENTS *pymode-contents* @@ -293,7 +293,7 @@ Manually set breakpoint command (leave empty for automatic detection) 3. Code checking ~ *pymode-lint* -Pymode supports `pylint`, `pep257`, `pep8`, `pyflakes`, `mccabe` code +Pymode supports `pylint`, `pep257`, `pycodestyle`, `pyflakes`, `mccabe` code checkers. You could run several similar checkers. Pymode uses Pylama library for code checking. Many options like skip @@ -330,9 +330,9 @@ Show error message if cursor placed at the error line *'g:pymode_lint_message' Default code checkers (you could set several) *'g:pymode_lint_checkers'* > - let g:pymode_lint_checkers = ['pyflakes', 'pep8', 'mccabe'] + let g:pymode_lint_checkers = ['pyflakes', 'pycodestyle', 'mccabe'] -Values may be chosen from: `pylint`, `pep8`, `mccabe`, `pep257`, `pyflakes`. +Values may be chosen from: `pylint`, `pycodestyle`, `mccabe`, `pep257`, `pyflakes`. Skip errors and warnings *'g:pymode_lint_ignore'* E.g. ["W", "E2"] (Skip all Warnings and the Errors starting with E2) etc. @@ -376,9 +376,9 @@ Definitions for |signs| Pymode has the ability to set code checkers options from pymode variables: -Set PEP8 options *'g:pymode_lint_options_pep8'* +Set PEP8 options *'g:pymode_lint_options_pycodestyle'* > - let g:pymode_lint_options_pep8 = + let g:pymode_lint_options_pycodestyle = \ {'max_line_length': g:pymode_options_max_line_length} See https://pep8.readthedocs.org/en/1.4.6/intro.html#configuration for more @@ -618,14 +618,31 @@ code to call it instead. let g:pymode_rope_use_function_bind = 'ru' -Move method/fields ~ +Move refactoring ~ *pymode-rope-move* +Moving method/fields + It happens when you perform move refactoring on a method of a class. In this refactoring, a method of a class is moved to the class of one of its attributes. The old method will call the new method. If you want to change all of the occurrences of the old method to use the new method you can inline it afterwards. + +Moving global variable/class/function into another module + +It happens when you perform move refactoring on global variable/class/function. +In this refactoring, the object being refactored will be moved to a destination +module. All references to the object being moved will be updated to point to +the new location. + +Moving module variable/class/function into a package + +It happens when you perform move refactoring on a name referencing a module. +In this refactoring, the module being refactored will be moved to a destination +package. All references to the object being moved will be updated to point to +the new location. + > let g:pymode_rope_move_bind = 'rv' diff --git a/plugin/pymode.vim b/plugin/pymode.vim index 232dc2af..b0d99270 100644 --- a/plugin/pymode.vim +++ b/plugin/pymode.vim @@ -1,5 +1,5 @@ " vi: fdl=1 -let g:pymode_version = "0.13.0" +let g:pymode_version = "0.14.0" " Enable pymode by default :) @@ -122,8 +122,8 @@ call pymode#default("g:pymode_lint_on_fly", 0) " Show message about error in command line call pymode#default("g:pymode_lint_message", 1) -" Choices are: pylint, pyflakes, pep8, mccabe and pep257 -call pymode#default("g:pymode_lint_checkers", ['pyflakes', 'pep8', 'mccabe']) +" Choices are: pylint, pyflakes, pycodestyle, mccabe and pep257 +call pymode#default("g:pymode_lint_checkers", ['pyflakes', 'pycodestyle', 'mccabe']) " Skip errors and warnings (e.g. E4,W) call pymode#default("g:pymode_lint_ignore", []) @@ -152,8 +152,8 @@ call pymode#default("g:pymode_lint_info_symbol", "II") call pymode#default("g:pymode_lint_pyflakes_symbol", "FF") " Code checkers options -" TODO: check if most adequate name name is pep8 or pycodestyle. -call pymode#default("g:pymode_lint_options_pep8", +" TODO: check if most adequate name name is pycodestyle. +call pymode#default("g:pymode_lint_options_pycodestyle", \ {'max_line_length': g:pymode_options_max_line_length}) call pymode#default("g:pymode_lint_options_pylint", diff --git a/pymode/__init__.py b/pymode/__init__.py index aba22870..906d7059 100644 --- a/pymode/__init__.py +++ b/pymode/__init__.py @@ -6,7 +6,13 @@ import vim # noqa if not hasattr(vim, 'find_module'): - vim.find_module = _PathFinder.find_module + try: + vim.find_module = _PathFinder.find_module # deprecated + except AttributeError: + def _find_module(package_name): + spec = _PathFinder.find_spec(package_name) + return spec.loader if spec else None + vim.find_module = _find_module def auto(): diff --git a/pymode/libs/appdirs.py b/pymode/libs/appdirs.py new file mode 120000 index 00000000..da7cbf20 --- /dev/null +++ b/pymode/libs/appdirs.py @@ -0,0 +1 @@ +../../submodules/appdirs/appdirs.py \ No newline at end of file diff --git a/pymode/libs/pytoolconfig b/pymode/libs/pytoolconfig new file mode 120000 index 00000000..0a2d520c --- /dev/null +++ b/pymode/libs/pytoolconfig @@ -0,0 +1 @@ +../../submodules/pytoolconfig/pytoolconfig/ \ No newline at end of file diff --git a/pymode/libs/tomli b/pymode/libs/tomli new file mode 120000 index 00000000..2413e2b5 --- /dev/null +++ b/pymode/libs/tomli @@ -0,0 +1 @@ +../../submodules/tomli/src/tomli \ No newline at end of file diff --git a/pymode/lint.py b/pymode/lint.py index ba187558..b0103a50 100644 --- a/pymode/lint.py +++ b/pymode/lint.py @@ -6,7 +6,7 @@ import os.path -from pylama.lint.extensions import LINTERS +from pylama.lint import LINTERS try: from pylama.lint.pylama_pylint import Linter @@ -35,13 +35,19 @@ def code_check(): # Fixed in v0.9.3: these two parameters may be passed as strings. # DEPRECATE: v:0.10.0: need to be set as lists. if isinstance(env.var('g:pymode_lint_ignore'), str): - raise ValueError ('g:pymode_lint_ignore should have a list type') + raise ValueError('g:pymode_lint_ignore should have a list type') else: ignore = env.var('g:pymode_lint_ignore') if isinstance(env.var('g:pymode_lint_select'), str): - raise ValueError ('g:pymode_lint_select should have a list type') + raise ValueError('g:pymode_lint_select should have a list type') else: select = env.var('g:pymode_lint_select') + if 'pep8' in linters: + # TODO: Add a user visible deprecation warning here + env.message('pep8 linter is deprecated, please use pycodestyle.') + linters.remove('pep8') + linters.append('pycodestyle') + options = parse_options( linters=linters, force=1, ignore=ignore, @@ -65,7 +71,8 @@ def code_check(): return env.stop() if env.options.get('debug'): - from pylama.core import LOGGER, logging + import logging + from pylama.core import LOGGER LOGGER.setLevel(logging.DEBUG) errors = run(path, code='\n'.join(env.curbuf) + '\n', options=options) @@ -83,11 +90,16 @@ def __sort(e): env.debug("Find sorting: ", sort_rules) errors = sorted(errors, key=__sort) + errors_list = [] for e in errors: - e._info['bufnr'] = env.curbuf.number - if e._info['col'] is None: - e._info['col'] = 1 - - env.run('g:PymodeLocList.current().extend', [e._info for e in errors]) + if e.col is None: + e.col = 1 + err_dict = e.to_dict() + err_dict['bufnr'] = env.curbuf.number + err_dict['type'] = e.etype + err_dict['text'] = e.message + errors_list.append(err_dict) + + env.run('g:PymodeLocList.current().extend', errors_list) # pylama:ignore=W0212,E1103 diff --git a/pymode/rope.py b/pymode/rope.py index c34817b2..65c54257 100644 --- a/pymode/rope.py +++ b/pymode/rope.py @@ -463,10 +463,11 @@ def run(self): if not input_str: return False + code_actions = self.get_code_actions() action = env.user_input_choices( - 'Choose what to do:', 'perform', 'preview', - 'perform in class hierarchy', - 'preview in class hierarchy') + 'Choose what to do:', + *code_actions, + ) in_hierarchy = action.endswith("in class hierarchy") @@ -492,6 +493,12 @@ def run(self): except Exception as e: # noqa env.error('Unhandled exception in Pymode: %s' % e) + def get_code_actions(self): + return [ + 'perform', + 'preview', + ] + @staticmethod def get_refactor(ctx): """ Get refactor object. """ @@ -546,6 +553,14 @@ def get_input_str(self, refactor, ctx): return newname + def get_code_actions(self): + return [ + 'perform', + 'preview', + 'perform in class hierarchy', + 'preview in class hierarchy', + ] + @staticmethod def get_changes(refactor, input_str, in_hierarchy=False): """ Get changes. @@ -701,6 +716,15 @@ def get_refactor(ctx): offset = None return move.create_move(ctx.project, ctx.resource, offset) + @staticmethod + def get_changes(refactor, input_str, in_hierarchy=False): + with RopeContext() as ctx: + if isinstance(refactor, (move.MoveGlobal, move.MoveModule)): + dest = ctx.project.pycore.find_module(input_str) + else: + dest = input_str + return super(MoveRefactoring, MoveRefactoring).get_changes(refactor, dest) + class ChangeSignatureRefactoring(Refactoring): @@ -728,6 +752,14 @@ def get_refactor(ctx): return change_signature.ChangeSignature( ctx.project, ctx.resource, offset) + def get_code_actions(self): + return [ + 'perform', + 'preview', + 'perform in class hierarchy', + 'preview in class hierarchy', + ] + def get_changes(self, refactor, input_string, in_hierarchy=False): """ Function description. diff --git a/submodules/appdirs b/submodules/appdirs new file mode 160000 index 00000000..193a2cbb --- /dev/null +++ b/submodules/appdirs @@ -0,0 +1 @@ +Subproject commit 193a2cbba58cce2542882fcedd0e49f6763672ed diff --git a/submodules/astroid b/submodules/astroid index 36dda3fc..8523ba82 160000 --- a/submodules/astroid +++ b/submodules/astroid @@ -1 +1 @@ -Subproject commit 36dda3fc8a5826b19a33a0ff29402b61d6a64fc2 +Subproject commit 8523ba827006d56a770a1f6efa77215718ef26c0 diff --git a/submodules/autopep8 b/submodules/autopep8 index 32c78a3a..6e6d4ba4 160000 --- a/submodules/autopep8 +++ b/submodules/autopep8 @@ -1 +1 @@ -Subproject commit 32c78a3a07d7ee35500e6f20bfcd621f3132c42e +Subproject commit 6e6d4ba4a043da1a56ca0ec7280a7d4f40283215 diff --git a/submodules/mccabe b/submodules/mccabe index 2d4dd943..85185224 160000 --- a/submodules/mccabe +++ b/submodules/mccabe @@ -1 +1 @@ -Subproject commit 2d4dd9435fcb05aaa89ba0392a84cb1d30a87dc9 +Subproject commit 851852240f2fa4453c226ccc5ae88bc03b467388 diff --git a/submodules/pycodestyle b/submodules/pycodestyle index 930e2cad..21abd9b6 160000 --- a/submodules/pycodestyle +++ b/submodules/pycodestyle @@ -1 +1 @@ -Subproject commit 930e2cad15df3661306740c30a892a6f1902ef1d +Subproject commit 21abd9b6dcbfa38635bc85a2c2327ec11ad91ffc diff --git a/submodules/pyflakes b/submodules/pyflakes index 95fe313b..b37f91a1 160000 --- a/submodules/pyflakes +++ b/submodules/pyflakes @@ -1 +1 @@ -Subproject commit 95fe313ba5ca384041472cd171ea60fad910c207 +Subproject commit b37f91a1ae25cfc242d5043985b05159e152091a diff --git a/submodules/pylama b/submodules/pylama index f436ccc6..53ad214d 160000 --- a/submodules/pylama +++ b/submodules/pylama @@ -1 +1 @@ -Subproject commit f436ccc6b55b33381a295ded753e467953cf4379 +Subproject commit 53ad214de0aa9534e59bcd5f97d9d723d16cfdb8 diff --git a/submodules/pylint b/submodules/pylint index 3eb0362d..fc34a4b6 160000 --- a/submodules/pylint +++ b/submodules/pylint @@ -1 +1 @@ -Subproject commit 3eb0362dc42642e3e2774d7523a1e73d71394064 +Subproject commit fc34a4b6abe56f3ac07ca15d846b1c1955545f85 diff --git a/submodules/pytoolconfig b/submodules/pytoolconfig new file mode 160000 index 00000000..549787fa --- /dev/null +++ b/submodules/pytoolconfig @@ -0,0 +1 @@ +Subproject commit 549787fa7d100c93333f48aaa9b07619f171736e diff --git a/submodules/rope b/submodules/rope index 62af070a..b0c8a5fc 160000 --- a/submodules/rope +++ b/submodules/rope @@ -1 +1 @@ -Subproject commit 62af070aa5ed3505a2629a76778003ce7fd383f0 +Subproject commit b0c8a5fc03ecbc94bd85dff46fc8b3f98f26a91e diff --git a/submodules/tomli b/submodules/tomli new file mode 160000 index 00000000..7e563eed --- /dev/null +++ b/submodules/tomli @@ -0,0 +1 @@ +Subproject commit 7e563eed5286b5d46b8290a9f56a86d955b23a9a diff --git a/tests/test.sh b/tests/test.sh index fe9fcae1..eb4ec018 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -4,7 +4,7 @@ set -e which vim 1>/dev/null 2>/dev/null -cd $(dirname $0) +cd "$(dirname "$0")" # Source common variables. source ./test_helpers_bash/test_variables.sh @@ -22,38 +22,37 @@ declare -a TEST_ARRAY=( "./test_bash/test_folding.sh" "./test_bash/test_textobject.sh" ) +MAIN_RETURN=0 ## now loop through the above array set +e -for ONE_TEST in "${TEST_ARRAY[@]}" +for TEST in "${TEST_ARRAY[@]}" do - echo "Starting test: $ONE_TEST" >> $VIM_OUTPUT_FILE - bash -x "$ONE_TEST" - echo -e "\n$ONE_TEST: Return code: $?" >> $VIM_OUTPUT_FILE + echo "Starting test: ${TEST}" | tee -a "${VIM_OUTPUT_FILE}" + bash "${TEST}" + R=$? + MAIN_RETURN=$(( MAIN_RETURN + R )) + echo -e "${TEST}: Return code: ${R}\n" | tee -a "${VIM_OUTPUT_FILE}" bash ./test_helpers_bash/test_prepare_between_tests.sh done -# Show errors: -E1=$(grep -E "^E[0-9]+:" $VIM_OUTPUT_FILE) -E2=$(grep -E "^Error" $VIM_OUTPUT_FILE) -E3="$E1\n$E2" -if [ "$E3" = "\n" ] -then - echo "No errors." -else - echo "Errors:" - echo -e "$E3\n" -fi +echo "=========================================================================" +echo " RESULTS" +echo "=========================================================================" # Show return codes. -RETURN_CODES=$(cat $VIM_OUTPUT_FILE | grep -i "Return code") +RETURN_CODES=$(grep -i "Return code" < "${VIM_OUTPUT_FILE}" | grep -v "Return code: 0") echo -e "${RETURN_CODES}" -# Exit the script with error if there are any return codes different from 0. -if echo $RETURN_CODES | grep -E "Return code: [1-9]" 1>/dev/null 2>/dev/null -then - exit 1 +# Show errors: +E1=$(grep -E "^E[0-9]+:" "${VIM_OUTPUT_FILE}") +E2=$(grep -Ei "^Error" "${VIM_OUTPUT_FILE}") +if [[ "${MAIN_RETURN}" == "0" ]]; then + echo "No errors." else - exit 0 + echo "Errors:" + echo -e "${E1}\n${E2}" fi +# Exit the script with error if there are any return codes different from 0. +exit ${MAIN_RETURN} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_autocommands.sh b/tests/test_bash/test_autocommands.sh index bc46b9d5..89d8a70d 100644 --- a/tests/test_bash/test_autocommands.sh +++ b/tests/test_bash/test_autocommands.sh @@ -15,20 +15,24 @@ declare -a TEST_PYMODE_COMMANDS_ARRAY=( ### FOR PINPOINT TESTING ### "./test_procedures_vimscript/pymoderun.vim" ### FOR PINPOINT TESTING ### ) +RETURN_CODE=0 + ## now loop through the above array set +e for ONE_PYMODE_COMMANDS_TEST in "${TEST_PYMODE_COMMANDS_ARRAY[@]}" do - echo "Starting test: $0:$ONE_PYMODE_COMMANDS_TEST" >> $VIM_OUTPUT_FILE - RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) + CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ${ONE_PYMODE_COMMANDS_TEST}" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" ### Enable the following to execute one test at a time. ### FOR PINPOINT TESTING ### vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE ### FOR PINPOINT TESTING ### exit 1 - RETURN_CODE=$? - echo -e "\n$0:$ONE_PYMODE_COMMANDS_TEST: Return code: $RETURN_CODE" >> $VIM_OUTPUT_FILE + SUB_TEST_RETURN_CODE=$? + echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" + RETURN_CODE=$(( RETURN_CODE + SUB_TEST_RETURN_CODE )) + echo -e "\tSubTest: $0:${ONE_PYMODE_COMMANDS_TEST}: Return code: ${SUB_TEST_RETURN_CODE}" | tee -a "${VIM_OUTPUT_FILE}" bash ./test_helpers_bash/test_prepare_between_tests.sh done +exit ${RETURN_CODE} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_autopep8.sh b/tests/test_bash/test_autopep8.sh index 05585725..2a70072a 100644 --- a/tests/test_bash/test_autopep8.sh +++ b/tests/test_bash/test_autopep8.sh @@ -2,9 +2,10 @@ # Source file. set +e -RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/autopep8.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) +CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/autopep8.vim" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" RETURN_CODE=$? +echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" set -e -exit $RETURN_CODE +exit ${RETURN_CODE} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_folding.sh b/tests/test_bash/test_folding.sh index d0ac884a..60e60c42 100644 --- a/tests/test_bash/test_folding.sh +++ b/tests/test_bash/test_folding.sh @@ -2,35 +2,24 @@ # Note: a solution with unix 'timeout' program was tried but it was unsuccessful. The problem with folding 4 is that in the case of a crash one expects the folding to just stay in an infinite loop, thus never existing with error. An improvement is suggested to this case. -# Source file. -set +e -source ./test_helpers_bash/test_prepare_between_tests.sh -vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding1.vim" $VIM_DISPOSABLE_PYFILE > /dev/null -R1=$? -source ./test_helpers_bash/test_prepare_between_tests.sh -vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding2.vim" $VIM_DISPOSABLE_PYFILE > /dev/null -R2=$? -source ./test_helpers_bash/test_prepare_between_tests.sh -# TODO: enable folding3.vim script back. -# vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding3.vim" $VIM_DISPOSABLE_PYFILE > /dev/null -# R3=$? -source ./test_helpers_bash/test_prepare_between_tests.sh -vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding4.vim" $VIM_DISPOSABLE_PYFILE > /dev/null -R4=$? -set -e +declare -a TEST_PYMODE_FOLDING_TESTS_ARRAY=( + "./test_procedures_vimscript/folding1.vim" + "./test_procedures_vimscript/folding2.vim" + # "./test_procedures_vimscript/folding3.vim" + "./test_procedures_vimscript/folding4.vim" + ) + +RETURN_CODE=0 -if [[ "$R1" -ne 0 ]] -then - exit 1 -elif [[ "$R2" -ne 0 ]] -then - exit 2 -# elif [[ "$R3" -ne 0 ]] -# then -# exit 3 -elif [[ "$R4" -ne 0 ]] -then - exit 4 -fi +set +e +for SUB_TEST in "${TEST_PYMODE_FOLDING_TESTS_ARRAY[@]}"; do + CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ${SUB_TEST}" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" + SUB_TEST_RETURN_CODE=$? + echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" + RETURN_CODE=$(( RETURN_CODE + SUB_TEST_RETURN_CODE )) + echo -e "\tSubTest: $0:${SUB_TEST}: Return code: ${SUB_TEST_RETURN_CODE}" | tee -a "${VIM_OUTPUT_FILE}" + bash ./test_helpers_bash/test_prepare_between_tests.sh +done +exit ${RETURN_CODE} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_pymodelint.sh b/tests/test_bash/test_pymodelint.sh index 583d0774..9f903955 100644 --- a/tests/test_bash/test_pymodelint.sh +++ b/tests/test_bash/test_pymodelint.sh @@ -5,10 +5,11 @@ # Source file. set +e -vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodelint.vim" $VIM_DISPOSABLE_PYFILE -# RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodeversion.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) -# RETURN_CODE=$? +# vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/pymodelint.vim" "${VIM_DISPOSABLE_PYFILE}" >> "${VIM_OUTPUT_FILE}" 2>&1 +CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/pymodeversion.vim" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" +RETURN_CODE=$? +echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" set -e -# exit $RETURN_CODE +exit ${RETURN_CODE} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_textobject.sh b/tests/test_bash/test_textobject.sh index 43a799f9..cf90c87a 100644 --- a/tests/test_bash/test_textobject.sh +++ b/tests/test_bash/test_textobject.sh @@ -2,14 +2,12 @@ # Source file. set +e +# shellcheck source=../test_helpers_bash/test_prepare_between_tests.sh source ./test_helpers_bash/test_prepare_between_tests.sh -vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/textobject.vim" $VIM_DISPOSABLE_PYFILE > /dev/null -R1=$? +CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/textobject.vim" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" +RETURN_CODE=$? +echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" set -e -if [[ "$R1" -ne 0 ]] -then - exit 1 -fi - +exit ${RETURN_CODE} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_helpers_bash/test_createvimrc.sh b/tests/test_helpers_bash/test_createvimrc.sh index ae763b95..d816df98 100644 --- a/tests/test_helpers_bash/test_createvimrc.sh +++ b/tests/test_helpers_bash/test_createvimrc.sh @@ -1,26 +1,27 @@ #! /bin/bash # Create minimal vimrc. -echo -e "syntax on\nfiletype plugin indent on\nset nocompatible" >> $VIM_TEST_VIMRC -echo "call has('python3')" >> $VIM_TEST_VIMRC -echo "set paste" >> $VIM_TEST_VIMRC -echo "set shortmess=at" >> $VIM_TEST_VIMRC -echo "set cmdheight=10" >> $VIM_TEST_VIMRC -echo "set ft=python" >> $VIM_TEST_VIMRC -echo "set shell=bash" >> $VIM_TEST_VIMRC -echo "set noswapfile" >> $VIM_TEST_VIMRC -echo "set backupdir=" >> $VIM_TEST_VIMRC -echo "set undodir=" >> $VIM_TEST_VIMRC -echo "set viewdir=" >> $VIM_TEST_VIMRC -echo "set directory=" >> $VIM_TEST_VIMRC -echo -e "set runtimepath=" >> $VIM_TEST_VIMRC -echo -e "set runtimepath+=$(dirname $PWD)\n" >> $VIM_TEST_VIMRC -echo -e "set packpath+=/tmp\n" >> $VIM_TEST_VIMRC -# echo -e "redir! >> $VIM_OUTPUT_FILE\n" >> $VIM_TEST_VIMRC -echo -e "set verbosefile=$VIM_OUTPUT_FILE\n" >> $VIM_TEST_VIMRC -echo -e "let g:pymode_debug = 1" >> $VIM_TEST_VIMRC - -echo "set nomore" >> $VIM_TEST_VIMRC - - +cat <<-EOF >> "${VIM_TEST_VIMRC}" + syntax on + filetype plugin indent on + set nocompatible + call has('python3') + set paste + set shortmess=at + set cmdheight=10 + set ft=python + set shell=bash + set noswapfile + set backupdir= + set undodir= + set viewdir= + set directory= + set runtimepath= + set runtimepath+="$(dirname "${PWD}")" + set packpath+=/tmp + " redir! >> "${VIM_OUTPUT_FILE}" + set verbosefile="${VIM_OUTPUT_FILE}" + let g:pymode_debug = 1 + set nomore +EOF # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_helpers_bash/test_prepare_between_tests.sh b/tests/test_helpers_bash/test_prepare_between_tests.sh index cdce9869..7a8f52e7 100644 --- a/tests/test_helpers_bash/test_prepare_between_tests.sh +++ b/tests/test_helpers_bash/test_prepare_between_tests.sh @@ -2,11 +2,12 @@ # Prepare tests. set +e -if [ -f $VIM_DISPOSABLE_PYFILE ]; then - rm $VIM_DISPOSABLE_PYFILE +if [ -f "${VIM_DISPOSABLE_PYFILE}" ]; then + rm "${VIM_DISPOSABLE_PYFILE}" fi -export VIM_DISPOSABLE_PYFILE=`mktemp /tmp/pymode.tmpfile.XXXXXXXXXX.py` +VIM_DISPOSABLE_PYFILE="$(mktemp /tmp/pymode.tmpfile.XXXXXXXXXX.py)" +export VIM_DISPOSABLE_PYFILE set -e -touch $VIM_DISPOSABLE_PYFILE +touch "${VIM_DISPOSABLE_PYFILE}" # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_helpers_bash/test_prepare_once.sh b/tests/test_helpers_bash/test_prepare_once.sh index dad77182..da986b53 100644 --- a/tests/test_helpers_bash/test_prepare_once.sh +++ b/tests/test_helpers_bash/test_prepare_once.sh @@ -2,11 +2,11 @@ # Prepare tests. set +e -rm $VIM_OUTPUT_FILE $VIM_TEST_VIMRC $VIM_TEST_PYMODECOMMANDS $VIM_DISPOSABLE_PYFILE 2&>/dev/null +rm "${VIM_OUTPUT_FILE}" "${VIM_TEST_VIMRC}" "${VIM_TEST_PYMODECOMMANDS}" "${VIM_DISPOSABLE_PYFILE}" 2&>/dev/null rm /tmp/*pymode* 2&>/dev/null rm -rf /tmp/pack mkdir -p /tmp/pack/test_plugins/start -ln -s $(dirname $(pwd)) /tmp/pack/test_plugins/start/ +ln -s "$(dirname "$(pwd)")" /tmp/pack/test_plugins/start/ set -e # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_helpers_bash/test_variables.sh b/tests/test_helpers_bash/test_variables.sh index 53edb5e5..f1995022 100644 --- a/tests/test_helpers_bash/test_variables.sh +++ b/tests/test_helpers_bash/test_variables.sh @@ -3,9 +3,13 @@ # Define variables for common test scripts. # Set variables. -export VIM_DISPOSABLE_PYFILE=`mktemp /tmp/pymode.tmpfile.XXXXXXXXXX.py` -export VIM_OUTPUT_FILE=/tmp/pymode.out -export VIM_TEST_VIMRC=/tmp/pymode_vimrc -export VIM_TEST_PYMODECOMMANDS=/tmp/pymode_commands.txt +VIM_DISPOSABLE_PYFILE="$(mktemp /tmp/pymode.tmpfile.XXXXXXXXXX.py)" +export VIM_DISPOSABLE_PYFILE +VIM_OUTPUT_FILE=/tmp/pymode.out +export VIM_OUTPUT_FILE +VIM_TEST_VIMRC=/tmp/pymode_vimrc +export VIM_TEST_VIMRC +VIM_TEST_PYMODECOMMANDS=/tmp/pymode_commands.txt +export VIM_TEST_PYMODECOMMANDS # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/utils/pymoderc b/tests/utils/pymoderc index 222c6ceb..3a8477ea 100644 --- a/tests/utils/pymoderc +++ b/tests/utils/pymoderc @@ -25,7 +25,7 @@ let g:pymode_lint_on_write = 1 let g:pymode_lint_unmodified = 0 let g:pymode_lint_on_fly = 0 let g:pymode_lint_message = 1 -let g:pymode_lint_checkers = ['pyflakes', 'pep8', 'mccabe'] +let g:pymode_lint_checkers = ['pyflakes', 'pycodestyle', 'mccabe'] let g:pymode_lint_ignore = ["E501", "W",] let g:pymode_lint_select = ["E501", "W0011", "W430"] let g:pymode_lint_sort = [] @@ -37,7 +37,7 @@ let g:pymode_lint_visual_symbol = 'RR' let g:pymode_lint_error_symbol = 'EE' let g:pymode_lint_info_symbol = 'II' let g:pymode_lint_pyflakes_symbol = 'FF' -let g:pymode_lint_options_pep8 = +let g:pymode_lint_options_pycodestyle = \ {'max_line_length': g:pymode_options_max_line_length} let g:pymode_lint_options_pyflakes = { 'builtins': '_' } let g:pymode_lint_options_mccabe = { 'complexity': 12 }