From 598ecaa5a12b02e29663541d81b2334d5cf01fa0 Mon Sep 17 00:00:00 2001 From: karajan1001 Date: Fri, 7 Aug 2020 14:44:41 +0800 Subject: [PATCH 1/4] Error message when no match found. 1. remove error message when no match found. --- dvc/main.py | 4 +++- tests/func/test_check_ignore.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dvc/main.py b/dvc/main.py index fc1450e536..08214a9fcc 100644 --- a/dvc/main.py +++ b/dvc/main.py @@ -84,7 +84,9 @@ def main(argv=None): # noqa: C901 ret = 255 try: - if ret != 0: + if ret != 0 and ( + ret != 1 and getattr(args, "cmd", "") != "check-ignore" + ): logger.info(FOOTER) if analytics.is_enabled(): diff --git a/tests/func/test_check_ignore.py b/tests/func/test_check_ignore.py index eba86bc98f..d2e8be5b25 100644 --- a/tests/func/test_check_ignore.py +++ b/tests/func/test_check_ignore.py @@ -14,6 +14,8 @@ def test_check_ignore(tmp_dir, dvc, file, ret, output, caplog): assert main(["check-ignore", file]) == ret assert (file in caplog.text) is output + if not output: + assert caplog.text == "" @pytest.mark.parametrize( From e9edca54c886fe56a27d09f0949b7262f07ca61e Mon Sep 17 00:00:00 2001 From: karajan1001 Date: Fri, 7 Aug 2020 15:32:36 +0800 Subject: [PATCH 2/4] Test update. 1.Test update cover return 0 and 1 --- tests/func/test_check_ignore.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/func/test_check_ignore.py b/tests/func/test_check_ignore.py index d2e8be5b25..52f9fadda7 100644 --- a/tests/func/test_check_ignore.py +++ b/tests/func/test_check_ignore.py @@ -14,8 +14,7 @@ def test_check_ignore(tmp_dir, dvc, file, ret, output, caplog): assert main(["check-ignore", file]) == ret assert (file in caplog.text) is output - if not output: - assert caplog.text == "" + assert "Having any troubles?" not in caplog.text @pytest.mark.parametrize( @@ -62,7 +61,7 @@ def test_check_ignore_non_matching(tmp_dir, dvc, non_matching, caplog): [], ], ) -def test_check_ignore_error_args_cases(tmp_dir, dvc, args): +def test_check_ignore_error_args_cases(tmp_dir, dvc, args, caplog): assert main(["check-ignore"] + args) == 255 From e6e43a8e9baf7f1215ee19b91bd3cbe70d8a215c Mon Sep 17 00:00:00 2001 From: karajan1001 Date: Fri, 7 Aug 2020 15:37:01 +0800 Subject: [PATCH 3/4] Remove unused arguments --- tests/func/test_check_ignore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/func/test_check_ignore.py b/tests/func/test_check_ignore.py index 52f9fadda7..927456e481 100644 --- a/tests/func/test_check_ignore.py +++ b/tests/func/test_check_ignore.py @@ -61,7 +61,7 @@ def test_check_ignore_non_matching(tmp_dir, dvc, non_matching, caplog): [], ], ) -def test_check_ignore_error_args_cases(tmp_dir, dvc, args, caplog): +def test_check_ignore_error_args_cases(tmp_dir, dvc, args): assert main(["check-ignore"] + args) == 255 From c97ad5792cbe367c655fb5e4fa07a0e2164f8d88 Mon Sep 17 00:00:00 2001 From: karajan1001 Date: Fri, 7 Aug 2020 16:16:53 +0800 Subject: [PATCH 4/4] Error message show in dvc check-ignore --- dvc/main.py | 2 +- tests/func/test_check_ignore.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dvc/main.py b/dvc/main.py index 08214a9fcc..07e0812537 100644 --- a/dvc/main.py +++ b/dvc/main.py @@ -85,7 +85,7 @@ def main(argv=None): # noqa: C901 try: if ret != 0 and ( - ret != 1 and getattr(args, "cmd", "") != "check-ignore" + ret != 1 or getattr(args, "cmd", "") != "check-ignore" ): logger.info(FOOTER) diff --git a/tests/func/test_check_ignore.py b/tests/func/test_check_ignore.py index 927456e481..905b6245d2 100644 --- a/tests/func/test_check_ignore.py +++ b/tests/func/test_check_ignore.py @@ -61,8 +61,9 @@ def test_check_ignore_non_matching(tmp_dir, dvc, non_matching, caplog): [], ], ) -def test_check_ignore_error_args_cases(tmp_dir, dvc, args): +def test_check_ignore_error_args_cases(tmp_dir, dvc, args, caplog): assert main(["check-ignore"] + args) == 255 + assert ("Having any troubles?" in caplog.text) == ("-q" not in args) @pytest.mark.parametrize("path,ret", [({"dir": {}}, 0), ({"dir": "files"}, 1)])