mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
Merge pull request #4 from ericsnowcurrently/meta-cleanup
Fill in some gaps in the project files.
This commit is contained in:
commit
4cdd5f5622
5 changed files with 135 additions and 0 deletions
25
.travis.yml
Normal file
25
.travis.yml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
language: python
|
||||
cache: pip
|
||||
python:
|
||||
- "2.7"
|
||||
- "3.6"
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- python: 3.6
|
||||
env: TARGET=lint
|
||||
- python: 3.6
|
||||
env: TARGET=coverage
|
||||
after_success:
|
||||
- if [ $TRAVIS_UPLOAD_COVERAGE == "true" ]; then
|
||||
bash <(curl -s https://codecov.io/bash);
|
||||
fi
|
||||
- python: 2.7
|
||||
env: TARGET=test
|
||||
|
||||
install:
|
||||
- make depends
|
||||
|
||||
script:
|
||||
#- make $TARGET PYTHON=python$TRAVIS_PYTHON_VERSION
|
||||
- make $TARGET PYTHON=$TRAVIS_PYTHON_PATH
|
||||
22
Makefile
Normal file
22
Makefile
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
PYTHON ?= python3
|
||||
|
||||
.PHONY: help
|
||||
help: ## Print help about available targets.
|
||||
@grep -h -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
.PHONY: depends
|
||||
depends:
|
||||
$(PYTHON) -m pip install flake8
|
||||
$(PYTHON) -m pip install coverage
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
$(PYTHON) -m flake8 --ignore E24,E121,E123,E125,E126,E221,E226,E266,E704,E265 $(CURDIR)
|
||||
|
||||
.PHONY: test
|
||||
test: ## Run the test suite.
|
||||
$(PYTHON) -m tests
|
||||
|
||||
.PHONY: coverage
|
||||
coverage: ## Check line coverage.
|
||||
$(PYTHON) -m coverage run -m tests
|
||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
42
tests/__main__.py
Normal file
42
tests/__main__.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
||||
TEST_ROOT = os.path.dirname(__file__)
|
||||
PROJECT_ROOT = os.path.dirname(TEST_ROOT)
|
||||
|
||||
|
||||
def convert_argv(argv):
|
||||
args = []
|
||||
modules = set()
|
||||
for arg in argv:
|
||||
# Unittest's main has only flags and positional args.
|
||||
# So we don't worry about options with values.
|
||||
if not arg.startswith('-'):
|
||||
# It must be the name of a test, case, module, or file.
|
||||
# We convert filenames to module names. For filenames
|
||||
# we support specifying a test name by appending it to
|
||||
# the filename with a ":" in between.
|
||||
mod, _, test = arg.partition(':')
|
||||
if mod.endswith(os.sep):
|
||||
mod = mod.rsplit(os.sep, 1)[0]
|
||||
mod = mod.rsplit('.py', 1)[0]
|
||||
mod = mod.replace(os.sep, '.')
|
||||
arg = mod if not test else mod + '.' + test
|
||||
modules.add(mod)
|
||||
args.append(arg)
|
||||
|
||||
if not modules:
|
||||
# Do discovery.
|
||||
args = ['discover',
|
||||
'--start-directory', PROJECT_ROOT,
|
||||
] + args
|
||||
return [sys.executable + ' -m unittest'] + args
|
||||
#return [sys.executable, '-m', 'unittest'] + args
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
argv = convert_argv(sys.argv[1:])
|
||||
unittest.main(module=None, argv=argv)
|
||||
46
tests/test_test_main.py
Normal file
46
tests/test_test_main.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import os
|
||||
import os.path
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
from .__main__ import convert_argv
|
||||
|
||||
|
||||
PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
|
||||
class ConvertArgsTests(unittest.TestCase):
|
||||
|
||||
def test_discovery(self):
|
||||
argv = convert_argv(['-v', '--failfast'])
|
||||
|
||||
self.assertEqual(argv, [
|
||||
sys.executable + ' -m unittest',
|
||||
'discover',
|
||||
'--start-directory', PROJECT_ROOT,
|
||||
'-v', '--failfast',
|
||||
])
|
||||
|
||||
def test_modules(self):
|
||||
argv = convert_argv(['-v', '--failfast',
|
||||
'w',
|
||||
'x/y.py:Spam.test_spam'.replace('/', os.sep),
|
||||
'z:Eggs',
|
||||
])
|
||||
|
||||
self.assertEqual(argv, [
|
||||
sys.executable + ' -m unittest',
|
||||
'-v', '--failfast',
|
||||
'w',
|
||||
'x.y.Spam.test_spam',
|
||||
'z.Eggs',
|
||||
])
|
||||
|
||||
def test_no_args(self):
|
||||
argv = convert_argv([])
|
||||
|
||||
self.assertEqual(argv, [
|
||||
sys.executable + ' -m unittest',
|
||||
'discover',
|
||||
'--start-directory', PROJECT_ROOT,
|
||||
])
|
||||
Loading…
Add table
Add a link
Reference in a new issue