[lit] Fix internal env calling other internal commands
authorJoel E. Denny <jdenny.ornl@gmail.com>
Wed, 30 Oct 2019 18:22:16 +0000 (14:22 -0400)
committerJoel E. Denny <jdenny.ornl@gmail.com>
Thu, 31 Oct 2019 18:37:51 +0000 (14:37 -0400)
commit0d4e6519c5dd81034935d4da9c519c17e41b1202
tree757e67ad8bf3eae10c948b0fe3305344a997c680
parent8e406204418895f7b09d1a9a3f8037e741a43968
[lit] Fix internal env calling other internal commands

Without this patch, when using lit's internal shell, if `env` on a lit
RUN line calls `cd`, `mkdir`, or any of the other in-process shell
builtins that lit implements, lit accidentally searches for the latter
as an external executable.

This patch puts such builtins in a map so that boilerplate for them
need be implemented only once.  This patch moves that handling after
processing of `env` so that `env` calling such a builtin can be
detected.  Finally, because such calls appear to be useless, this
patch takes the safe approach of diagnosing them rather than
supporting them.

Reviewed By: probinson, mgorny, rnk

Differential Revision: https://reviews.llvm.org/D66506
llvm/utils/lit/lit/TestRunner.py
llvm/utils/lit/tests/Inputs/shtest-env/env-calls-cd.txt [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/shtest-env/env-calls-colon.txt [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/shtest-env/env-calls-echo.txt [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/shtest-env/env-calls-export.txt [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/shtest-env/env-calls-mkdir.txt [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/shtest-env/env-calls-rm.txt [new file with mode: 0644]
llvm/utils/lit/tests/shtest-env.py