Skip to content

Commit

Permalink
Merge 1792864 into 8c4da3a
Browse files Browse the repository at this point in the history
  • Loading branch information
liskin committed Jul 1, 2020
2 parents 8c4da3a + 1792864 commit 679faa7
Show file tree
Hide file tree
Showing 16 changed files with 221 additions and 378 deletions.
9 changes: 3 additions & 6 deletions .coveragerc
@@ -1,6 +1,3 @@
[report]
omit = */python2.7/*,*/test*,*/__init__.py
[paths]
source =
.
/root/.vim/bundle/taskwiki
[run]
source = taskwiki
data_file = /tmp/taskwiki-coverage/.coverage
22 changes: 2 additions & 20 deletions .travis.yml
@@ -1,5 +1,4 @@
sudo: required
language: python
language: minimal
env:
- TASK_VERSION=v2.4.0
- TASK_VERSION=v2.4.1
Expand All @@ -8,28 +7,11 @@ env:
- TASK_VERSION=v2.4.4
- TASK_VERSION=v2.5.0
- TASK_VERSION=v2.5.1
python:
- "3.6"
- "3.7"
- "3.8"
services:
- docker
before_install:
# Setup virtual framebuffer
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
install:
# Install coverage dependencies
- pip install coverage coveralls
# Build the docker container
- pushd $TRAVIS_BUILD_DIR
- docker-compose build --build-arg TASK_VERSION=$TASK_VERSION tests
script:
- xhost +local:root
- make test
after_success:
- ls /tmp/taskwiki-coverage
- mv /tmp/taskwiki-coverage/.coverage.* . || echo ok
- coverage combine
- coverage report
- coveralls
- make test PYTEST_FLAGS="-n8"
9 changes: 5 additions & 4 deletions Dockerfile
Expand Up @@ -2,7 +2,7 @@ FROM fedora:27
ARG TASK_VERSION

RUN dnf update -y
RUN dnf install procps-ng psmisc which vim curl git gvim gcc gcc-c++ cmake make gnutls-devel libuuid-devel -y
RUN dnf install procps-ng psmisc which vim curl git gvim gcc gcc-c++ cmake make gnutls-devel libuuid-devel xorg-x11-server-Xvfb -y

# Setup language environment
ENV LC_ALL en_US.UTF-8
Expand All @@ -28,10 +28,11 @@ RUN cd /root/.vim/bundle; git clone https://github.com/vimwiki/vimwiki.git
RUN cd /root/.vim/bundle/vimwiki/; git checkout dev

# Setup taskwiki
RUN pip3 install nose pytest coveralls coverage vimrunner
RUN pip3 install \
pytest pytest-xdist \
coveralls coverage \
https://github.com/liskin/vimrunner-python/archive/8c19ff88050c09236e7519425bfae33c687483df.zip
ADD requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
RUN mkdir /root/.vim/bundle/taskwiki
WORKDIR /root/.vim/bundle/taskwiki

CMD ["sh", "-c", "python3 -m pytest -vv tests/"]
18 changes: 16 additions & 2 deletions Makefile
@@ -1,3 +1,17 @@
export LC_ALL := en_US.UTF-8

PYTHON ?= python3

test:
mkdir -p /tmp/taskwiki-coverage
docker-compose up --exit-code-from tests
docker-compose run --rm tests

pytest:
$(PYTHON) -m pytest -vv $(PYTEST_FLAGS) tests/

cover-pytest: pytest
coverage combine
coverage report
if [ "$$TRAVIS" ]; then coveralls; fi

xvfb-%:
xvfb-run --server-args=-noreset $(MAKE) $*
17 changes: 8 additions & 9 deletions docker-compose.yml
Expand Up @@ -3,16 +3,15 @@ services:
tests:
build: .
volumes:
- "/etc/group:/etc/group:ro"
- "/etc/passwd:/etc/passwd:ro"
- "/etc/shadow:/etc/shadow:ro"
- "/etc/sudoers.d:/etc/sudoers.d:ro"
- "/tmp/.X11-unix:/tmp/.X11-unix:rw"
- "$HOME/.Xauthority:/root/.Xauthority:rw"
- ".:/root/.vim/bundle/taskwiki:rw"
- ".:/root/.vim/bundle/taskwiki:ro"
network_mode: "host"
environment:
- DISPLAY
security_opt:
- label=type:container_runtime_t
tty: true
command: make xvfb-cover-pytest
environment:
PYTEST_FLAGS: "-o cache_dir=/tmp/pytest-cache ${PYTEST_FLAGS:-}"
TRAVIS:
TRAVIS_JOB_ID:
TRAVIS_BRANCH:
TRAVIS_PULL_REQUEST:
2 changes: 1 addition & 1 deletion ftplugin/vimwiki/taskwiki.vim
Expand Up @@ -26,7 +26,7 @@ let s:plugin_path = escape(expand('<sfile>:p:h:h:h'), '\')

" Run the measure parts first, if desired
if exists("g:taskwiki_measure_coverage")
execute 'py3file ' . s:plugin_path . '/knowledge/testcoverage.py'
execute 'py3file ' . s:plugin_path . '/taskwiki/testcoverage.py'
endif

" Execute the main body of taskwiki source
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1 +1 @@
git+git://github.com/robgolding63/tasklib@develop
tasklib>=1.3,<2.0
138 changes: 70 additions & 68 deletions taskwiki/regexp.py
Expand Up @@ -44,97 +44,99 @@
VIEWPORT = {
'default':
re.compile(
'^' # Starts at the begging of the line
'[=]+' # Heading begging
'(?P<name>[^=\|\[\{]*)' # Name of the viewport, all before the | sign
# Cannot include '[', '=', '|, and '{'
'\|' # Colon
'(?P<filter>[^=\|]+?)' # Filter
'(' # Optional defaults
'\|' # Colon
'(?P<defaults>[^=\|]+?)' # Default attrs
')?'
'\s*' # Any whitespace
'(#(?P<source>[A-Z]))?' # Optional source indicator
'\s*' # Any whitespace
'(\$(?P<sort>[A-Z]))?' # Optional sort indicator
'\s*' # Any whitespace
'[=]+' # Header ending
r'^' # Starts at the begging of the line
r'[=]+' # Heading begging
r'(?P<name>[^=\|\[\{]*)' # Name of the viewport, all before the | sign
# Cannot include '[', '=', '|', and '{'
r'\|' # Bar
r'(?!\|)' # (But not two, that would be a preset)
r'(?P<filter>[^=\|]*?)' # Filter
r'(' # Optional defaults
r'\|' # Bar
r'(?P<defaults>[^=\|]+?)' # Default attrs
r')?'
r'\s*' # Any whitespace
r'(#(?P<source>[A-Z]))?' # Optional source indicator
r'\s*' # Any whitespace
r'(\$(?P<sort>[A-Z]))?' # Optional sort indicator
r'\s*' # Any whitespace
r'[=]+' # Header ending
),
'markdown':
re.compile(
'^' # Starts at the begging of the line
'[#]+' # Heading begging
'(?P<name>[^#\|\[\{]*)' # Name of the viewport, all before the | sign
# Cannot include '[', '=', '|, and '{'
'\|' # Colon
'(?P<filter>[^#\|]+?)' # Filter
'(' # Optional defaults
'\|' # Colon
'(?P<defaults>[^#\|]+?)'# Default attrs
')?'
'\s*' # Any whitespace
'(#(?P<source>[A-Z]))?' # Optional source indicator
'\s*' # Any whitespace
'(\$(?P<sort>[A-Z]))?' # Optional sort indicator
'\s*' # Any whitespace
'$' # End of line
r'^' # Starts at the begging of the line
r'[#]+' # Heading begging
r'(?P<name>[^#\|\[\{]*)' # Name of the viewport, all before the | sign
# Cannot include '[', '#', '|', and '{'
r'\|' # Bar
r'(?!\|)' # (But not two, that would be a preset)
r'(?P<filter>[^#\|]*?)' # Filter
r'(' # Optional defaults
r'\|' # Bar
r'(?P<defaults>[^#\|]+?)' # Default attrs
r')?'
r'\s*' # Any whitespace
r'(#(?P<source>[A-Z]))?' # Optional source indicator
r'\s*' # Any whitespace
r'(\$(?P<sort>[A-Z]))?' # Optional sort indicator
r'\s*' # Any whitespace
r'$' # End of line
)
}

HEADER = {
'default':
re.compile(
'^' # Starts at the beginning of the line
'(?P<header_start>[=]+)' # With a positive number of =
'[^=]+' # Character other than =
'[=]+' # Positive number of =, closing the header
'\s*' # Allow trailing whitespace
r'^' # Starts at the beginning of the line
r'(?P<header_start>[=]+)' # With a positive number of =
r'[^=]+' # Character other than =
r'[=]+' # Positive number of =, closing the header
r'\s*' # Allow trailing whitespace
),
'markdown':
re.compile(
'^' # Starts at the beginning of the line
'(?P<header_start>[#]+)' # With a positive number of #
'[^#]+' # Character other than #
r'^' # Starts at the beginning of the line
r'(?P<header_start>[#]+)' # With a positive number of #
r'[^#]+' # Character other than #
)
}

PRESET = {
'default':
re.compile(
'^' # Starts at the beginning of the line
'(?P<header_start>[=]+)' # With a positive number of =
'([^=\|\[\{]*)' # Heading caption, everything up to ||
# Cannot include '[', '=', '|, and '{'
'\|\|' # Delimiter
'(?P<filter>[^=\|]+?)' # Filter preset
'(' # Optional defaults
'\|\|' # Delimiter
'(?P<defaults>[^=\|]+?)' # Default attrs preset
')?'
'\s*' # Any whitespace
'[=]+' # Header ending
r'^' # Starts at the beginning of the line
r'(?P<header_start>[=]+)' # With a positive number of =
r'([^=\|\[\{]*)' # Heading caption, everything up to ||
# Cannot include '[', '=', '|, and '{'
r'\|\|' # Delimiter
r'(?P<filter>[^=\|]+?)' # Filter preset
r'(' # Optional defaults
r'\|\|' # Delimiter
r'(?P<defaults>[^=\|]+?)' # Default attrs preset
r')?'
r'\s*' # Any whitespace
r'[=]+' # Header ending
),
'markdown':
re.compile(
'^' # Starts at the beginning of the line
'(?P<header_start>[#]+)' # With a positive number of #
'([^#\|\[\{]*)' # Heading caption, everything up to ||
# Cannot include '[', '#', '|, and '{'
'\|\|' # Delimiter
'(?P<filter>[^#\|]+?)' # Filter preset
'(' # Optional defaults
'\|\|' # Delimiter
'(?P<defaults>[^#\|]+?)' # Default attrs preset
')?'
'\s*' # Any whitespace
'$' # End of line
r'^' # Starts at the beginning of the line
r'(?P<header_start>[#]+)' # With a positive number of #
r'([^#\|\[\{]*)' # Heading caption, everything up to ||
# Cannot include '[', '#', '|, and '{'
r'\|\|' # Delimiter
r'(?P<filter>[^#\|]+?)' # Filter preset
r'(' # Optional defaults
r'\|\|' # Delimiter
r'(?P<defaults>[^#\|]+?)' # Default attrs preset
r')?'
r'\s*' # Any whitespace
r'$' # End of line
)
}

ANSI_ESCAPE_SEQ = re.compile(
'\x1b' # literal ESC
'\[' # literal [
'[;\d]*' # zero or more digits or semicolons
'[A-Za-z]' # a letter
r'\x1b' # literal ESC
r'\[' # literal [
r'[;\d]*' # zero or more digits or semicolons
r'[A-Za-z]' # a letter
)

0 comments on commit 679faa7

Please sign in to comment.