Repository: incubator-impala Updated Branches: refs/heads/master 532b1fe11 -> 0983da92b
IMPALA-3992: bad shell error message when running nonexistent file Fix the error handling code and add a test. Change-Id: Iebcf1dc8a1a08b400a2c769a9cff38ea02c8e525 Reviewed-on: http://gerrit.cloudera.org:8080/4022 Reviewed-by: Henry Robinson <[email protected]> Tested-by: Internal Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/50e21247 Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/50e21247 Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/50e21247 Branch: refs/heads/master Commit: 50e21247d60b9d33cb2601126a1af9231fc7e43b Parents: 532b1fe Author: Tim Armstrong <[email protected]> Authored: Wed Aug 17 14:28:45 2016 -0700 Committer: Internal Jenkins <[email protected]> Committed: Thu Aug 18 03:37:48 2016 +0000 ---------------------------------------------------------------------- shell/impala_shell.py | 3 ++- tests/shell/test_shell_commandline.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/50e21247/shell/impala_shell.py ---------------------------------------------------------------------- diff --git a/shell/impala_shell.py b/shell/impala_shell.py index ff35412..b9dc60a 100755 --- a/shell/impala_shell.py +++ b/shell/impala_shell.py @@ -1232,7 +1232,8 @@ def execute_queries_non_interactive_mode(options): else: query_file_handle = open(options.query_file, 'r') except Exception, e: - print_to_stderr("Could not open file '%s': %s", options.query_file, e) + print_to_stderr("Could not open file '%s': %s" % (options.query_file, e)) + sys.exit(1) query_text = query_file_handle.read() elif options.query: http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/50e21247/tests/shell/test_shell_commandline.py ---------------------------------------------------------------------- diff --git a/tests/shell/test_shell_commandline.py b/tests/shell/test_shell_commandline.py index 9963730..29c5040 100644 --- a/tests/shell/test_shell_commandline.py +++ b/tests/shell/test_shell_commandline.py @@ -429,3 +429,6 @@ class TestImpalaShell(ImpalaTestSuite): assert "(Coordinator: " in results.stderr assert "Query progress can be monitored at: " in results.stderr + def test_missing_query_file(self): + result = run_impala_shell_cmd('-f nonexistent.sql', expect_success=False) + assert "Could not open file 'nonexistent.sql'" in result.stderr
