def test_select_argv(self): """Test invoking binary_util.py as a standalone script.""" with temporary_dir() as tmp_dir: config_file_loc = os.path.join(tmp_dir, 'pants.ini') safe_file_dump(config_file_loc, payload="""\ [GLOBAL] allow_external_binary_tool_downloads: True pants_bootstrapdir: {} """.format(tmp_dir)) expected_output_glob = os.path.join( tmp_dir, 'bin', 'cmake', '*', '*', '3.9.5', 'cmake') with environment_as(PANTS_CONFIG_FILES='[{!r}]'.format(config_file_loc)): # Ignore the first argument, as per sys.argv. output_file = select(['_', 'cmake', '3.9.5', 'cmake.tar.gz']) self.assertTrue(is_readable_dir(output_file)) realized_glob = assert_single_element(glob.glob(expected_output_glob)) self.assertEqual(os.path.realpath(output_file), os.path.realpath(realized_glob))
def test_select_argv(self): """Test invoking binary_util.py as a standalone script.""" with temporary_dir() as tmp_dir: config_file_loc = os.path.join(tmp_dir, "pants.toml") safe_file_dump( config_file_loc, payload=f"""\ [GLOBAL] allow_external_binary_tool_downloads = true pants_bootstrapdir = "{tmp_dir}" """, ) expected_output_glob = os.path.join(tmp_dir, "bin", "cmake", "*", "*", "3.9.5", "cmake") with environment_as(PANTS_CONFIG_FILES=f"[{config_file_loc!r}]"): # Ignore the first argument, as per sys.argv. output_file = select(["_", "cmake", "3.9.5", "cmake.tar.gz"]) self.assertTrue(is_readable_dir(output_file)) realized_glob = assert_single_element( glob.glob(expected_output_glob)) self.assertEqual(os.path.realpath(output_file), os.path.realpath(realized_glob))