diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a81fcc8..ef445a1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,5 +33,5 @@ jobs: npm install --location=global bats - name: Run tests and generate coverage report run: | - coverage run -m unittest discover ./tests/ + PYTHONPATH="$(pwd):$PYTHONPATH" coverage run -m unittest discover ./tests/ coverage xml diff --git a/batspp/__version__.py b/batspp/__version__.py index 180b521..111fae0 100755 --- a/batspp/__version__.py +++ b/batspp/__version__.py @@ -11,4 +11,4 @@ """Version""" -__version__ = '2.1.1' +__version__ = '2.1.2' diff --git a/batspp/_ast_nodes.py b/batspp/_ast_nodes.py index 03815ed..3fd6aed 100644 --- a/batspp/_ast_nodes.py +++ b/batspp/_ast_nodes.py @@ -12,7 +12,7 @@ # Local modules -from _tokens import TokenData +from batspp._token import TokenData class AST: diff --git a/batspp/_interpreter.py b/batspp/_interpreter.py index 946ad56..b31fd74 100755 --- a/batspp/_interpreter.py +++ b/batspp/_interpreter.py @@ -25,9 +25,9 @@ # Local modules -from batspp_opts import BatsppOpts -from batspp_args import BatsppArgs -from _ast_nodes import ( +from batspp.batspp_opts import BatsppOpts +from batspp.batspp_args import BatsppArgs +from batspp._ast_nodes import ( TestsSuite, Test, Assertion, AssertionType ) diff --git a/batspp/_lexer.py b/batspp/_lexer.py index d50718d..26c2609 100755 --- a/batspp/_lexer.py +++ b/batspp/_lexer.py @@ -25,8 +25,8 @@ # Local modules -from _exceptions import error -from _tokens import ( +from batspp._exceptions import error +from batspp._token import ( TokenData, TokenType, Token ) diff --git a/batspp/_parser.py b/batspp/_parser.py index d427bfe..f84ccdb 100755 --- a/batspp/_parser.py +++ b/batspp/_parser.py @@ -18,7 +18,6 @@ # Standard packages -from enum import Enum # Installed packages @@ -26,11 +25,11 @@ # Local modules -from _exceptions import error -from _tokens import ( +from batspp._exceptions import error +from batspp._token import ( TokenType, Token ) -from _ast_nodes import ( +from batspp._ast_nodes import ( AST, TestsSuite, Test, Assertion, AssertionType ) diff --git a/batspp/_tokens.py b/batspp/_token.py similarity index 100% rename from batspp/_tokens.py rename to batspp/_token.py diff --git a/batspp/batspp b/batspp/batspp index 5b32258..60de8e9 100755 --- a/batspp/batspp +++ b/batspp/batspp @@ -45,10 +45,10 @@ from mezcla import text_utils # Local modules -from __version__ import __version__ -from batspp_opts import BatsppOpts -from batspp_args import BatsppArgs -from batspp_test import BatsppTest +from batspp.__version__ import __version__ +from batspp.batspp_opts import BatsppOpts +from batspp.batspp_args import BatsppArgs +from batspp.batspp_test import BatsppTest # Command-line labels and diff --git a/batspp/batspp_args.py b/batspp/batspp_args.py index 1958fef..50c7179 100644 --- a/batspp/batspp_args.py +++ b/batspp/batspp_args.py @@ -8,7 +8,7 @@ # Local modules -from _exceptions import assert_type +from batspp._exceptions import assert_type class BatsppArgs: diff --git a/batspp/batspp_opts.py b/batspp/batspp_opts.py index e5da2e0..47156ee 100644 --- a/batspp/batspp_opts.py +++ b/batspp/batspp_opts.py @@ -8,7 +8,7 @@ # Local modules -from _exceptions import assert_type +from batspp._exceptions import assert_type class BatsppOpts: diff --git a/batspp/batspp_test.py b/batspp/batspp_test.py index 78e86c8..6e18786 100644 --- a/batspp/batspp_test.py +++ b/batspp/batspp_test.py @@ -20,14 +20,14 @@ # Local modules -from _lexer import Lexer -from _parser import Parser -from _interpreter import Interpreter -from _settings import ( +from batspp._lexer import Lexer +from batspp._parser import Parser +from batspp._interpreter import Interpreter +from batspp._settings import ( BATSPP_EXTENSION, BATS_EXTENSION ) -from batspp_opts import BatsppOpts -from batspp_args import BatsppArgs +from batspp.batspp_opts import BatsppOpts +from batspp.batspp_args import BatsppArgs class BatsppTest: diff --git a/setup.py b/setup.py index ff80980..7b207f0 100755 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ "Operating System :: OS Independent", ], scripts=['batspp/batspp'], - package_dir={"": "batspp"}, + packages=['batspp'], python_requires=">=3.8", install_requires=required, ) diff --git a/tests/run_all.bash b/tests/run_all.bash index 6022b31..48a3da4 100755 --- a/tests/run_all.bash +++ b/tests/run_all.bash @@ -5,6 +5,7 @@ ## TODO: save older runned htmlcovs. tests=$(dirname $(realpath -s $0)) +export PYTHONPATH="$tests/../:$PYTHONPATH" echo -e "Running tests on $tests\n" coverage run -m unittest discover $tests coverage html --directory $tests/htmlcov diff --git a/tests/test_batspp.py b/tests/test_batspp.py index d23c1eb..b8a42b6 100755 --- a/tests/test_batspp.py +++ b/tests/test_batspp.py @@ -2,6 +2,9 @@ # # Tests for batspp script # +# This test must be runned with the command: +# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_batspp.py +# """Tests for batspp script""" diff --git a/tests/test_end_usage.py b/tests/test_end_usage.py index 23896d9..5e34638 100755 --- a/tests/test_end_usage.py +++ b/tests/test_end_usage.py @@ -10,6 +10,9 @@ # output files can be updated automatically # running: $ docs/examples/run_examples.bash # +# This test must be runned with the command: +# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_end_usage.py +# """Tests for Batspp end usage""" diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 6198fa2..f5efd0d 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -2,6 +2,9 @@ # # Tests for exceptions.py module # +# This test must be runned with the command: +# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_exceptions.py +# """Tests for exceptions.py module""" @@ -19,7 +22,7 @@ # Module being tested sys.path.insert(0, './batspp') -from _exceptions import ( # type: ignore +from batspp._exceptions import ( error, assert_type ) diff --git a/tests/test_interpreter.py b/tests/test_interpreter.py index 09a73f6..a61a44a 100755 --- a/tests/test_interpreter.py +++ b/tests/test_interpreter.py @@ -2,6 +2,9 @@ # # Tests for interpreter.py module # +# This test must be runned with the command: +# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_interpreter.py +# """Tests for interpreter.py module""" @@ -19,12 +22,12 @@ # Local modules sys.path.insert(0, './batspp') -from _tokens import TokenData # type: ignore -from _ast_nodes import ( # type: ignore +from batspp._token import TokenData +from batspp._ast_nodes import ( AssertionType, Assertion, Test, TestsSuite ) -from _interpreter import ( # type: ignore +from batspp._interpreter import ( NodeVisitor, Interpreter ) diff --git a/tests/test_lexer.py b/tests/test_lexer.py index c314e11..3921d0d 100755 --- a/tests/test_lexer.py +++ b/tests/test_lexer.py @@ -2,6 +2,9 @@ # # Tests for lexer.py module # +# This test must be runned with the command: +# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_lexer.py +# """Tests for lexer.py module""" @@ -19,10 +22,10 @@ # Module being tested sys.path.insert(0, './batspp') -from _lexer import ( # type: ignore +from batspp._lexer import ( TextLiner, Lexer ) -from _tokens import ( # type: ignore +from batspp._token import ( Token, TokenType ) diff --git a/tests/test_parser.py b/tests/test_parser.py index 5f7ebc2..0fa03da 100755 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -2,6 +2,9 @@ # # Tests for parser.py module # +# This test must be runned with the command: +# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_parser.py +# """Tests for parser.py module""" @@ -19,9 +22,9 @@ # Local modules sys.path.insert(0, './batspp') -from _tokens import Token, TokenType # type: ignore -from _parser import Parser # type: ignore -from _ast_nodes import ( # type: ignore +from batspp._token import Token, TokenType +from batspp._parser import Parser +from batspp._ast_nodes import ( AssertionType, Assertion, TestsSuite, Test ) diff --git a/upload_dist.bash b/upload_dist.bash index 010bdf0..25ae90b 100755 --- a/upload_dist.bash +++ b/upload_dist.bash @@ -7,37 +7,83 @@ # - upload dist to PyPi # -echo "build - checking the required tools..." -# Make sure your build tool is up to date -pip install build +function install_required_tools () { + echo "build - checking the required tools..." -# Setuptools is a package development process library designed -# for creating and distributing Python packages. -pip install setuptools + # Make sure your build tool is up to date + pip install build -# The Wheel package provides a bdist_wheel command for setuptools. -# It creates .whl file which is directly installable through the pip install command. -pip install wheel + # Setuptools is a package development process library designed + # for creating and distributing Python packages. + pip install setuptools -# This is a smart progress meter used internally by Twine. -pip install tqdm + # The Wheel package provides a bdist_wheel command for setuptools. + # It creates .whl file which is directly installable through the pip install command. + pip install wheel -# The Twine package provides a secure, authenticated, -# and verified connection between your system and PyPi over HTTPS. -pip install twine + # This is a smart progress meter used internally by Twine. + pip install tqdm -echo "build - checking dependencies..." -pip install -r ./requirements.txt + # The Twine package provides a secure, authenticated, + # and verified connection between your system and PyPi over HTTPS. + pip install twine +} -echo "build - compiling package..." -# This will create build, dist and project.egg.info folders -python3 setup.py bdist_wheel -echo "build - uploading dist/* to PyPi..." -twine upload dist/* --verbose +function install_dependencies () { + echo "build - checking dependencies..." + pip install -r ./requirements.txt +} -echo "build - cleaning" -rm -rf ./build/ ./dist/ ./batspp/batspp.egg-info -echo "build - finish!" +# Upload to pypi +# +# $1 -> "test" or "main" +function upload_pypi () { + echo "build - compiling package..." + # This will create build, dist and project.egg.info folders + python3 setup.py bdist_wheel + + echo "build - uploading to PyPi..." + + # Uploading to Test Pypi + # + # More information here + # https://packaging.python.org/en/latest/guides/using-testpypi/ + if [ "$1" == 'main' ] + then + twine upload dist/* --verbose + elif [ "$1" == 'test' ] + then + twine upload --repository testpypi dist/* --verbose + else + echo "no Pypi main|test selected" + fi +} + + +function clean () { + echo "build - cleaning" + rm -rf ./build/ ./dist/ ./batspp/batspp.egg-info +} + + +function main () { + if [[ "$1" == "main"|| "$1" == "test" ]] + then + install_required_tools + install_dependencies + upload_pypi "$1" + clean + else + echo 'Upload Batspp dist' + echo '' + echo 'Usage:' + echo "- upload main Pypi: $ $0 main" + echo "- upload test Pypi: $ $0 test" + echo '' + fi +} + +main $@