From 30228bdde2a11a75b2f36c1d5fcc69eb15609355 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Wed, 13 Mar 2019 20:19:24 -0700 Subject: [PATCH] filter-repo: add tests triggering callback sanity checks Signed-off-by: Elijah Newren --- t/t9391-filter-repo-lib-usage.sh | 10 ++++++++++ t/t9391/erroneous.py | 16 ++++++++++++++++ t/t9392-python-callback.sh | 11 +++++++++++ 3 files changed, 37 insertions(+) create mode 100755 t/t9391/erroneous.py diff --git a/t/t9391-filter-repo-lib-usage.sh b/t/t9391-filter-repo-lib-usage.sh index 1224773..6d670e9 100755 --- a/t/t9391-filter-repo-lib-usage.sh +++ b/t/t9391-filter-repo-lib-usage.sh @@ -141,4 +141,14 @@ test_expect_success 'unusual.py' ' ) ' +test_expect_success 'erroneous.py' ' + setup erroneous && + ( + cd erroneous && + test_must_fail $TEST_DIRECTORY/t9391/erroneous.py 2>../err && + + test_i18ngrep "Error: Cannot pass a tag_callback to RepoFilter AND pass --tag-callback" ../err + ) +' + test_done diff --git a/t/t9391/erroneous.py b/t/t9391/erroneous.py new file mode 100755 index 0000000..a5c05d2 --- /dev/null +++ b/t/t9391/erroneous.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +""" +Please see the + ***** API BACKWARD COMPATIBILITY CAVEAT ***** +near the top of git-filter-repo +""" + +import git_filter_repo as fr + +def handle_tag(tag): + print("Decipher this: "+''.join(reversed(progress.message))) + +args = fr.FilteringOptions.parse_args(['--force', '--tag-callback', 'pass']) +filter = fr.RepoFilter(args, tag_callback = handle_tag) +filter.run() diff --git a/t/t9392-python-callback.sh b/t/t9392-python-callback.sh index 243228f..983879e 100755 --- a/t/t9392-python-callback.sh +++ b/t/t9392-python-callback.sh @@ -170,4 +170,15 @@ test_expect_success '--reset-callback' ' ) ' +test_expect_success 'callback has return statement sanity check' ' + setup callback_return_sanity && + ( + cd callback_return_sanity && + + test_must_fail git filter-repo --filename-callback "filename + \".txt\"" 2>../err&& + test_i18ngrep "Error: --filename-callback should have a return statement" ../err && + rm ../err + ) +' + test_done