diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd487b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.bundle +test-repo diff --git a/.tito/tito.props b/.tito/tito.props index 1120d24..71808ff 100644 --- a/.tito/tito.props +++ b/.tito/tito.props @@ -3,3 +3,4 @@ builder = tito.builder.Builder tagger = tito.tagger.VersionTagger changelog_do_not_remove_cherrypick = 0 changelog_format = %s +fetch_sources = True diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 0000000..7f96386 --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,28 @@ +#! /bin/bash -ex + +srcdir=$(dirname "$(readlink -f "$0")") +cd "$srcdir" +filename=$(basename "$(spectool -S vcs-diff-lint.spec | sed -n 's/Source1: \(.*\)/\1/p')") +echo "$filename" +rm -rf test-repo +git clone "$filename" test-repo +export PATH=$srcdir:$PATH +cd test-repo + +for test_dir in "$srcdir"/test_data/*; do + test -d "$test_dir" || continue + test_name=$(basename "$test_dir") + + echo "=== Test $test_name ===" + new=$(echo "$test_name" | cut -d_ -f2) + old=$(echo "$test_name" | cut -d_ -f3) + testdir=$srcdir/test_data/$test_name + git checkout "$new" + vcs-diff-lint --compare-against "$old" > errors || : + + found_match=false + for added in "$testdir"/added-*.err; do + diff -ruN errors "$added" && found_match=: && break + done + $found_match +done diff --git a/test_data/001_51806b39_1059de39_basic/added-01.err b/test_data/001_51806b39_1059de39_basic/added-01.err new file mode 100644 index 0000000..61d007f --- /dev/null +++ b/test_data/001_51806b39_1059de39_basic/added-01.err @@ -0,0 +1,5 @@ +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 diff --git a/vcs-diff-lint.spec b/vcs-diff-lint.spec index fadb85d..e42bace 100644 --- a/vcs-diff-lint.spec +++ b/vcs-diff-lint.spec @@ -4,6 +4,8 @@ Release: 1%{?dist} Summary: VCS Differential Code Analysis Tool BuildArch: noarch +%bcond_without check + License: GPL-2.0-or-later URL: https://github.com/fedora-copr/vcs-diff-lint # Source is created by: @@ -11,6 +13,8 @@ URL: https://github.com/fedora-copr/vcs-diff-lint # tito build --tgz --tag %%name-%%version-%%release Source0: %name-%version.tar.gz +Source1: https://github.com/praiskup/vcs-diff-lint-testdata/releases/download/v1.0.0/vcs-diff-lint-testdata-1.0.0.bundle + Requires: csdiff Requires: git Recommends: pylint @@ -18,6 +22,14 @@ Recommends: python3-mypy Recommends: python3-types-requests Recommends: ruff +%if %{with check} +BuildRequires: csdiff +BuildRequires: git +BuildRequires: pylint +BuildRequires: rpmdevtools +%endif + + %description Analyze code, and print only reports related to a particular change. @@ -31,6 +43,9 @@ added (or even fixed, as opt-in) analyzers' warnings. %prep %autosetup +%if %{with check} +cp %{SOURCE1} ./ +%endif %build @@ -44,6 +59,11 @@ install -p vcs-diff-lint-csdiff-pylint %buildroot%_bindir install -p vcs-diff-lint-csdiff-mypy %buildroot%_bindir install -p vcs-diff-lint-csdiff-ruff %buildroot%_bindir +%if %{with check} +%check +./run-tests.sh +%endif + %files %license LICENSE