-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
102 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
__pycache__ | ||
.coverage | ||
*.bundle | ||
test-repo |
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,10 @@ | ||
#! /bin/bash -e | ||
cov=--cov | ||
args=() | ||
for arg; do | ||
case $arg in | ||
--no-cov) cov= ;; | ||
*) args+=( "$arg" ) | ||
esac | ||
done | ||
exec python3 -m pytest -vv $cov "${args[@]}" |
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,28 @@ | ||
""" | ||
vcs-diff-lint tests | ||
""" | ||
|
||
import os | ||
import shutil | ||
from subprocess import Popen, PIPE, check_call | ||
|
||
SRCDIR = os.path.normpath(os.path.join(os.path.dirname(__file__), "..")) | ||
GITROOTDIR = os.path.join(SRCDIR, 'test-repo') | ||
|
||
bundle = None | ||
with Popen(['spectool', '-S', 'vcs-diff-lint.spec'], | ||
stdout=PIPE, cwd=SRCDIR) as spectool: | ||
with Popen(['sed', '-n', 's/^Source1: \\(.*\\)/\\1/p'], | ||
stdin=spectool.stdout, stdout=PIPE, | ||
encoding="utf-8") as sed: | ||
bundle, _ = sed.communicate() | ||
bundle = os.path.basename(bundle.strip()) | ||
|
||
try: | ||
shutil.rmtree(GITROOTDIR) | ||
except FileNotFoundError: | ||
pass | ||
check_call(['git', 'clone', bundle, GITROOTDIR], cwd=SRCDIR) | ||
|
||
os.environ["PATH"] = SRCDIR+":"+os.environ["PATH"] | ||
check_call(["bash", "-c", "env"]) |
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,31 @@ | ||
""" | ||
Run vcs-diff-lint tests against the bundled git repo. | ||
""" | ||
|
||
import subprocess | ||
from tests import GITROOTDIR | ||
|
||
|
||
def run_vcs_diff_lint(old, new, expected_output): | ||
""" Run vcs-diff-lint in the datadir """ | ||
subprocess.check_call(["git", "checkout", new], cwd=GITROOTDIR) | ||
out = subprocess.run(["vcs-diff-lint", "--compare-against", | ||
old], cwd=GITROOTDIR, stdout=subprocess.PIPE, | ||
check=False, encoding="utf-8") | ||
assert out.stdout == expected_output | ||
|
||
|
||
def test_basic(): | ||
""" | ||
Test added issues. | ||
""" | ||
old = '1059de39' | ||
new = '51806b39' | ||
data="""\ | ||
Error: PYLINT_WARNING: | ||
python/hello-world-python:1: C0114[missing-module-docstring]: Missing module docstring | ||
Error: PYLINT_WARNING: | ||
python/hello-world-python:4: C0116[missing-function-docstring]: api_method: Missing function or method docstring | ||
""" | ||
run_vcs_diff_lint(old, new, data) |
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