Reverts the "installed tests" feature. (#6695)

* Reverts the "installed tests" feature.

* It was never fully utilized and has enough issues to call for a rethink.
* Reverts commits (with some manual fixups):
  * 9427ed633e3dd24095eb4c85423a41eae91b669e.
  * 2b235dc85f27e99103cd35911264ce38ac2d5767.
* Run lit tests in the current binary dir, like C++ tests.
diff --git a/build_tools/cmake/iree_cc_test.cmake b/build_tools/cmake/iree_cc_test.cmake
index 4651837..dfc8bc6 100644
--- a/build_tools/cmake/iree_cc_test.cmake
+++ b/build_tools/cmake/iree_cc_test.cmake
@@ -5,7 +5,6 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 include(CMakeParseArguments)
-include(iree_installed_test)
 
 # iree_cc_test()
 #
@@ -126,8 +125,6 @@
   string(REPLACE "::" "/" _PACKAGE_PATH ${_PACKAGE_NS})
   set(_TEST_NAME "${_PACKAGE_PATH}/${_RULE_NAME}")
 
-  list(APPEND _RULE_LABELS "${_PACKAGE_PATH}")
-
   # Case for cross-compiling towards Android.
   if(ANDROID)
     set(_ANDROID_REL_DIR "${_PACKAGE_PATH}/${_RULE_NAME}")
@@ -152,24 +149,22 @@
         TEST_TMPDIR=${_ANDROID_ABS_DIR}/test_tmpdir
     )
     set_property(TEST ${_TEST_NAME} PROPERTY ENVIRONMENT ${_ENVIRONMENT_VARS})
-    set_property(TEST ${_TEST_NAME} PROPERTY LABELS "${_RULE_LABELS}")
   else(ANDROID)
-    iree_add_installed_test(
-      TEST_NAME "${_TEST_NAME}"
-      LABELS "${_RULE_LABELS}"
+    add_test(
+      NAME
+        ${_TEST_NAME}
       COMMAND
         # We run all our tests through a custom test runner to allow temp
         # directory cleanup upon test completion.
         "${CMAKE_SOURCE_DIR}/build_tools/cmake/run_test.${IREE_HOST_SCRIPT_EXT}"
         "$<TARGET_FILE:${_NAME}>"
-      INSTALLED_COMMAND
-        # Must match install destination below.
-        "${_PACKAGE_PATH}/$<TARGET_FILE_NAME:${_NAME}>"
-    )
+      WORKING_DIRECTORY
+        "${CMAKE_BINARY_DIR}"
+      )
+    set_property(TEST ${_TEST_NAME} PROPERTY ENVIRONMENT "TEST_TMPDIR=${CMAKE_BINARY_DIR}/${_NAME}_test_tmpdir")
+    iree_add_test_environment_properties(${_TEST_NAME})
   endif(ANDROID)
 
-  install(TARGETS ${_NAME}
-    DESTINATION "tests/${_PACKAGE_PATH}"
-    COMPONENT Tests
-  )
+  list(APPEND _RULE_LABELS "${_PACKAGE_PATH}")
+  set_property(TEST ${_TEST_NAME} PROPERTY LABELS "${_RULE_LABELS}")
 endfunction()
diff --git a/build_tools/cmake/iree_installed_test.cmake b/build_tools/cmake/iree_installed_test.cmake
deleted file mode 100644
index 1f99997..0000000
--- a/build_tools/cmake/iree_installed_test.cmake
+++ /dev/null
@@ -1,92 +0,0 @@
-# Copyright 2020 The IREE Authors
-#
-# Licensed under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-# iree_add_installed_test()
-#
-# Creates a build-time and exported install-time test. All tests are installed
-# into the tests/ tree. Calling code must arrange to install dependencies of the
-# test into that tree.
-#
-# Parameters:
-# TEST_NAME: Name of the test (as in "some/path/to/test").
-# COMMAND: Passed to add_test() as is.
-# ENVIRONMENT: Set as the ENVIRONMENT property of the build-time test.
-# INSTALLED_COMMAND: Corrollary to the 'COMMAND' argument but added to the
-#   install time definition.
-# WORKING_DIRECTORY: Passed to add_test() as is. Note that in the install tree
-# all tests run in the tests/ directory.
-# LABELS: Labels to pass to add_test() and installed tests.
-function(iree_add_installed_test)
-  cmake_parse_arguments(
-    _RULE
-    ""
-    "TEST_NAME"
-    "COMMAND;ENVIRONMENT;INSTALLED_COMMAND;WORKING_DIRECTORY;LABELS"
-    ${ARGN}
-  )
-
-
-  add_test(
-    NAME
-      ${_RULE_TEST_NAME}
-    COMMAND
-      ${_RULE_COMMAND}
-  )
-  if (DEFINED _RULE_WORKING_DIRECTORY)
-    set_property(
-      TEST
-        ${_RULE_TEST_NAME}
-      PROPERTY WORKING_DIRECTORY
-        "${_RULE_WORKING_DIRECTORY}"
-    )
-  endif()
-  set_property(
-    TEST
-      ${_RULE_TEST_NAME}
-    PROPERTY LABELS
-      "${_RULE_LABELS}"
-  )
-  set_property(
-    TEST
-      ${_RULE_TEST_NAME}
-    PROPERTY ENVIRONMENT
-      "TEST_TMPDIR=${CMAKE_BINARY_DIR}/${_RULE_TEST_NAME}_test_tmpdir"
-      ${_RULE_ENVIRONMENT}
-  )
-  iree_add_test_environment_properties(${_RULE_TEST_NAME})
-
-  # Write the to the installed ctest file template.
-  set(_installed_ctest_input_file
-        "${CMAKE_BINARY_DIR}/iree_installed_tests.cmake.in")
-  get_property(_has_tests GLOBAL PROPERTY IREE_HAS_INSTALLED_TESTS)
-  if(NOT _has_tests)
-    # First time.
-    file(WRITE "${_installed_ctest_input_file}")  # Truncate.
-    set_property(GLOBAL PROPERTY IREE_HAS_INSTALLED_TESTS ON)
-  endif()
-
-  # Now write directives to the installed tests cmake file.
-  file(APPEND "${_installed_ctest_input_file}"
-    "add_test(${_RULE_TEST_NAME} ${_RULE_INSTALLED_COMMAND})\n"
-    "set_tests_properties(${_RULE_TEST_NAME} PROPERTIES LABELS \"${_RULE_LABELS}\")\n"
-  )
-
-  # First time generation and setup to install. Note that since this all runs
-  # at the generate phase, it doesn't matter that we trigger it before all
-  # tests accumulate.
-  if(NOT _has_tests)
-    set(_installed_ctest_output_file "${CMAKE_BINARY_DIR}/iree_installed_tests.cmake")
-    file(GENERATE
-      OUTPUT "${_installed_ctest_output_file}"
-      INPUT "${_installed_ctest_input_file}"
-    )
-    install(FILES "${_installed_ctest_output_file}"
-      DESTINATION tests
-      RENAME "CTestTestfile.cmake"
-      COMPONENT Tests
-    )
-  endif()
-endfunction()
diff --git a/build_tools/cmake/iree_lit_test.cmake b/build_tools/cmake/iree_lit_test.cmake
index 9f54ec9..e898800 100644
--- a/build_tools/cmake/iree_lit_test.cmake
+++ b/build_tools/cmake/iree_lit_test.cmake
@@ -5,7 +5,6 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 include(CMakeParseArguments)
-include(iree_installed_test)
 
 # iree_lit_test()
 #
@@ -61,11 +60,9 @@
   iree_package_ns(_PACKAGE_NS)
   string(REPLACE "::" "/" _PACKAGE_PATH ${_PACKAGE_NS})
   set(_NAME_PATH "${_PACKAGE_PATH}/${_RULE_NAME}")
-  list(APPEND _RULE_LABELS "${_PACKAGE_PATH}")
-
-  iree_add_installed_test(
-    TEST_NAME "${_NAME_PATH}"
-    LABELS "${_RULE_LABELS}"
+  add_test(
+    NAME
+      ${_NAME_PATH}
     COMMAND
       # We run all our tests through a custom test runner to allow setup
       # and teardown.
@@ -73,18 +70,16 @@
       "${CMAKE_SOURCE_DIR}/iree/tools/run_lit.${IREE_HOST_SCRIPT_EXT}"
       ${_TEST_FILE_PATH}
       ${_DATA_DEP_PATHS}
-    INSTALLED_COMMAND
-      # TODO: Make the lit runner be not a shell script and more cross-platform.
-      # Note that the data deps are not bundled: must be externally on the path.
-      bin/run_lit.${IREE_HOST_SCRIPT_EXT}
-      ${_TEST_FILE_PATH}
+    WORKING_DIRECTORY
+      "${CMAKE_CURRENT_BINARY_DIR}"
   )
-  set_property(TEST ${_NAME_PATH} PROPERTY REQUIRED_FILES "${_TEST_FILE_PATH}")
 
-  install(FILES ${_TEST_FILE_PATH}
-    DESTINATION "tests/${_PACKAGE_PATH}"
-    COMPONENT Tests
-  )
+  list(APPEND _RULE_LABELS "${_PACKAGE_PATH}")
+  set_property(TEST ${_NAME_PATH} PROPERTY LABELS "${_RULE_LABELS}")
+  set_property(TEST ${_NAME_PATH} PROPERTY REQUIRED_FILES "${_TEST_FILE_PATH}")
+  set_property(TEST ${_NAME_PATH} PROPERTY ENVIRONMENT "TEST_TMPDIR=${_NAME}_test_tmpdir")
+  iree_add_test_environment_properties(${_NAME_PATH})
+
   # TODO(gcmn): Figure out how to indicate a dependency on _RULE_DATA being built
 endfunction()
 
diff --git a/build_tools/cmake/iree_python.cmake b/build_tools/cmake/iree_python.cmake
index 6adcb34..f86f4e9 100644
--- a/build_tools/cmake/iree_python.cmake
+++ b/build_tools/cmake/iree_python.cmake
@@ -5,7 +5,6 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 include(CMakeParseArguments)
-include(iree_installed_test)
 
 ###############################################################################
 # Main user rules
@@ -257,6 +256,7 @@
 # NAME: name of test
 # SRCS: Test source file
 # ARGS: Command line arguments to the Python source file.
+# DEPS: List of deps the test requires
 # LABELS: Additional labels to apply to the test. The package path is added
 #     automatically.
 # GENERATED_IN_BINARY_DIR: If present, indicates that the srcs have been
@@ -269,8 +269,8 @@
   cmake_parse_arguments(
     _RULE
     "GENERATED_IN_BINARY_DIR"
-    "NAME;SRCS"
-    "ARGS;LABELS"
+    "NAME"
+    "ARGS;DEPS;LABELS;SRCS"
     ${ARGN}
   )
 
@@ -288,26 +288,17 @@
   set(_NAME_PATH "${_PACKAGE_PATH}/${_RULE_NAME}")
   list(APPEND _RULE_LABELS "${_PACKAGE_PATH}")
 
-  iree_add_installed_test(
-    TEST_NAME "${_NAME_PATH}"
-    LABELS "${_RULE_LABELS}"
-    ENVIRONMENT
-      "PYTHONPATH=${CMAKE_BINARY_DIR}/bindings/python:$ENV{PYTHONPATH}"
+  add_test(
+    NAME ${_NAME}
     COMMAND
       "${CMAKE_SOURCE_DIR}/build_tools/cmake/run_test.${IREE_HOST_SCRIPT_EXT}"
       "${Python3_EXECUTABLE}"
-      "${_SRC_DIR}/${_RULE_SRCS}"
-      ${_RULE_ARGS}
-    INSTALLED_COMMAND
-      python
-      "${_PACKAGE_PATH}/${_RULE_SRCS}"
+      "${CMAKE_CURRENT_SOURCE_DIR}/${_RULE_SRCS}"
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
   )
 
-  install(FILES ${_RULE_SRCS}
-    DESTINATION "tests/${_PACKAGE_PATH}"
-    COMPONENT Tests
-  )
-
+  set_property(TEST ${_NAME} PROPERTY LABELS "${_RULE_LABELS}")
+  set_property(TEST ${_NAME} PROPERTY ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/bindings/python:$ENV{PYTHONPATH};TEST_TMPDIR=${_NAME}_${V}_test_tmpdir")
   # TODO(marbre): Find out how to add deps to tests.
   #               Similar to _RULE_DATA in iree_lit_test().
 endfunction()