From 967119653b8425a985165ee3829b61e9d26d9b0c Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Tue, 19 Nov 2019 17:37:13 -0700 Subject: [PATCH 1/4] Rename some test files from test_foo.py to foo_test.py --- .../subsystems/{test_pex_build_util.py => pex_build_util_test.py} | 0 src/python/pants/base/{test_specs.py => specs_test.py} | 0 src/python/pants/fs/{test_fs.py => fs_test.py} | 0 ...t_list_goals_integration.py => list_goals_test_integration.py} | 0 src/python/pants/rules/core/{test_cloc.py => cloc_test.py} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename src/python/pants/backend/python/subsystems/{test_pex_build_util.py => pex_build_util_test.py} (100%) rename src/python/pants/base/{test_specs.py => specs_test.py} (100%) rename src/python/pants/fs/{test_fs.py => fs_test.py} (100%) rename src/python/pants/help/{test_list_goals_integration.py => list_goals_test_integration.py} (100%) rename src/python/pants/rules/core/{test_cloc.py => cloc_test.py} (100%) diff --git a/src/python/pants/backend/python/subsystems/test_pex_build_util.py b/src/python/pants/backend/python/subsystems/pex_build_util_test.py similarity index 100% rename from src/python/pants/backend/python/subsystems/test_pex_build_util.py rename to src/python/pants/backend/python/subsystems/pex_build_util_test.py diff --git a/src/python/pants/base/test_specs.py b/src/python/pants/base/specs_test.py similarity index 100% rename from src/python/pants/base/test_specs.py rename to src/python/pants/base/specs_test.py diff --git a/src/python/pants/fs/test_fs.py b/src/python/pants/fs/fs_test.py similarity index 100% rename from src/python/pants/fs/test_fs.py rename to src/python/pants/fs/fs_test.py diff --git a/src/python/pants/help/test_list_goals_integration.py b/src/python/pants/help/list_goals_test_integration.py similarity index 100% rename from src/python/pants/help/test_list_goals_integration.py rename to src/python/pants/help/list_goals_test_integration.py diff --git a/src/python/pants/rules/core/test_cloc.py b/src/python/pants/rules/core/cloc_test.py similarity index 100% rename from src/python/pants/rules/core/test_cloc.py rename to src/python/pants/rules/core/cloc_test.py From 3212ae1cf966ebfd645d9a8b3d0cc84128ae643d Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Tue, 19 Nov 2019 20:07:42 -0700 Subject: [PATCH 2/4] Fix type hints --- src/python/pants/testutil/pants_run_integration_test.py | 8 +++++--- src/python/pants/util/process_handler.py | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/python/pants/testutil/pants_run_integration_test.py b/src/python/pants/testutil/pants_run_integration_test.py index bc68840f51f..b385c19642d 100644 --- a/src/python/pants/testutil/pants_run_integration_test.py +++ b/src/python/pants/testutil/pants_run_integration_test.py @@ -57,7 +57,7 @@ def join( communicate_fn = self.process.communicate if tee_output: - communicate_fn = SubprocessProcessHandler(self.process).communicate_teeing_stdout_and_stderr + communicate_fn = SubprocessProcessHandler(self.process).communicate_teeing_stdout_and_stderr # type: ignore if stdin_data is not None: stdin_data = ensure_binary(stdin_data) (stdout_data, stderr_data) = communicate_fn(stdin_data) @@ -293,7 +293,7 @@ def get_cache_subdir(self, cache_dir, subdir_glob='*/', other_dirs=()): def run_pants_with_workdir_without_waiting(self, command, workdir, config=None, extra_env=None, build_root=None, print_exception_stacktrace=True, - **kwargs): + **kwargs) -> PantsJoinHandle: args = [ '--no-pantsrc', f'--pants-workdir={workdir}', @@ -350,7 +350,9 @@ def run_pants_with_workdir_without_waiting(self, command, workdir, config=None, hermetic_env = os.getenv('HERMETIC_ENV') if hermetic_env: for h in hermetic_env.strip(',').split(','): - env[h] = os.getenv(h) + val = os.getenv(h) + if val is not None: + env[h] = val else: env = os.environ.copy() if extra_env: diff --git a/src/python/pants/util/process_handler.py b/src/python/pants/util/process_handler.py index cd507287241..e8d5fc6a4f0 100644 --- a/src/python/pants/util/process_handler.py +++ b/src/python/pants/util/process_handler.py @@ -5,6 +5,7 @@ import multiprocessing import sys from abc import ABC, abstractmethod +from typing import Optional, Tuple class ProcessHandler(ABC): @@ -55,7 +56,9 @@ def terminate(self): def poll(self): return self._process.poll() - def communicate_teeing_stdout_and_stderr(self, stdin=None): + def communicate_teeing_stdout_and_stderr( + self, stdin: Optional[bytes] = None + ) -> Tuple[bytes, bytes]: """ Just like subprocess.communicate, but tees stdout and stderr to both sys.std{out,err} and a buffer. Only operates on stdout/stderr if the Popen call send them to subprocess.PIPE. From 81ef470bf348e872374247381d5c9eddf1a7c438 Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Tue, 19 Nov 2019 20:13:18 -0700 Subject: [PATCH 3/4] Revert "Fix type hints" This reverts commit 3212ae1cf966ebfd645d9a8b3d0cc84128ae643d. --- src/python/pants/testutil/pants_run_integration_test.py | 8 +++----- src/python/pants/util/process_handler.py | 5 +---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/python/pants/testutil/pants_run_integration_test.py b/src/python/pants/testutil/pants_run_integration_test.py index b385c19642d..bc68840f51f 100644 --- a/src/python/pants/testutil/pants_run_integration_test.py +++ b/src/python/pants/testutil/pants_run_integration_test.py @@ -57,7 +57,7 @@ def join( communicate_fn = self.process.communicate if tee_output: - communicate_fn = SubprocessProcessHandler(self.process).communicate_teeing_stdout_and_stderr # type: ignore + communicate_fn = SubprocessProcessHandler(self.process).communicate_teeing_stdout_and_stderr if stdin_data is not None: stdin_data = ensure_binary(stdin_data) (stdout_data, stderr_data) = communicate_fn(stdin_data) @@ -293,7 +293,7 @@ def get_cache_subdir(self, cache_dir, subdir_glob='*/', other_dirs=()): def run_pants_with_workdir_without_waiting(self, command, workdir, config=None, extra_env=None, build_root=None, print_exception_stacktrace=True, - **kwargs) -> PantsJoinHandle: + **kwargs): args = [ '--no-pantsrc', f'--pants-workdir={workdir}', @@ -350,9 +350,7 @@ def run_pants_with_workdir_without_waiting(self, command, workdir, config=None, hermetic_env = os.getenv('HERMETIC_ENV') if hermetic_env: for h in hermetic_env.strip(',').split(','): - val = os.getenv(h) - if val is not None: - env[h] = val + env[h] = os.getenv(h) else: env = os.environ.copy() if extra_env: diff --git a/src/python/pants/util/process_handler.py b/src/python/pants/util/process_handler.py index e8d5fc6a4f0..cd507287241 100644 --- a/src/python/pants/util/process_handler.py +++ b/src/python/pants/util/process_handler.py @@ -5,7 +5,6 @@ import multiprocessing import sys from abc import ABC, abstractmethod -from typing import Optional, Tuple class ProcessHandler(ABC): @@ -56,9 +55,7 @@ def terminate(self): def poll(self): return self._process.poll() - def communicate_teeing_stdout_and_stderr( - self, stdin: Optional[bytes] = None - ) -> Tuple[bytes, bytes]: + def communicate_teeing_stdout_and_stderr(self, stdin=None): """ Just like subprocess.communicate, but tees stdout and stderr to both sys.std{out,err} and a buffer. Only operates on stdout/stderr if the Popen call send them to subprocess.PIPE. From 2bb2b119b037a65bf83f0412cd96eb4baab2a4c1 Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Tue, 19 Nov 2019 20:15:23 -0700 Subject: [PATCH 4/4] Must use naming scheme foo_integration_test, not foo_test_integration --- ...t_goals_test_integration.py => list_goals_integration_test.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/python/pants/help/{list_goals_test_integration.py => list_goals_integration_test.py} (100%) diff --git a/src/python/pants/help/list_goals_test_integration.py b/src/python/pants/help/list_goals_integration_test.py similarity index 100% rename from src/python/pants/help/list_goals_test_integration.py rename to src/python/pants/help/list_goals_integration_test.py