From 5f9c33b50a468bb10ed2041c3c98bfb450f6ad3c Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Mon, 17 Feb 2020 11:38:21 +0100 Subject: [PATCH] Don't time --no-execute This made some output for non-execution. See #977. --- src/exec.cpp | 2 +- src/parse_execution.cpp | 3 ++- tests/checks/no-execute.fish | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index e5e74cad7..b57ec02d8 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -957,7 +957,7 @@ bool exec_job(parser_t &parser, const shared_ptr &j, const job_lineage_t // A false return tells the caller to remove the job from the list. return false; } - cleanup_t timer = push_timer(j->flags().has_time_prefix); + cleanup_t timer = push_timer(j->flags().has_time_prefix && !no_exec()); // Get the deferred process, if any. We will have to remember its pipes. autoclose_pipes_t deferred_pipes; diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index e524af8c6..10688e84d 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -1214,7 +1214,8 @@ end_execution_reason_t parse_execution_context_t::run_1_job(tnode_t job_ // is significantly faster. if (job_is_simple_block(job_node)) { tnode_t optional_time = job_node.child<0>(); - cleanup_t timer = push_timer(optional_time.tag() == parse_optional_time_time); + // If no-exec has been given, there is nothing to time. + cleanup_t timer = push_timer(optional_time.tag() == parse_optional_time_time && !no_exec()); tnode_t variable_assignments = job_node.child<1>(); const block_t *block = nullptr; end_execution_reason_t result = diff --git a/tests/checks/no-execute.fish b/tests/checks/no-execute.fish index 1ea4f8aba..5bb4d11eb 100644 --- a/tests/checks/no-execute.fish +++ b/tests/checks/no-execute.fish @@ -5,6 +5,11 @@ echo "type foo" | $fish -n echo $status #CHECK: 0 +# Test that it doesn't time non-execution. +echo "time echo foo" | $fish -n +echo $status +#CHECK: 0 + # Test that it doesn't check globs. echo "echo /asfjidhfiusnlkxcnvklxcvlkmcxlv*" | $fish -n echo $status