def test_pantsd_invalidation_stale_sources(self): test_path = 'tests/python/pants_test/daemon_correctness_test_0001' test_build_file = os.path.join(test_path, 'BUILD') test_src_file = os.path.join(test_path, 'some_file.py') has_source_root_regex = r'"source_root": ".*/{}"'.format(test_path) export_cmd = ['export', test_path] try: with self.pantsd_successful_run_context() as (pantsd_run, checker, workdir, _): safe_mkdir(test_path, clean=True) pantsd_run(['help']) checker.assert_started() safe_file_dump( test_build_file, "python_library(sources=globs('some_non_existent_file.py'))" ) result = pantsd_run(export_cmd) checker.assert_running() assertNotRegex(self, result.stdout_data, has_source_root_regex) safe_file_dump(test_build_file, "python_library(sources=globs('*.py'))") result = pantsd_run(export_cmd) checker.assert_running() assertNotRegex(self, result.stdout_data, has_source_root_regex) safe_file_dump(test_src_file, 'import this\n') result = pantsd_run(export_cmd) checker.assert_running() assertRegex(self, result.stdout_data, has_source_root_regex) finally: rm_rf(test_path)
def test_pantsd_run(self): extra_config = { 'GLOBAL': { # Muddies the logs with warnings: once all of the warnings in the repository # are fixed, this can be removed. 'glob_expansion_failure': 'ignore', } } with self.pantsd_successful_run_context( 'debug', extra_config=extra_config) as (pantsd_run, checker, workdir, _): pantsd_run(['list', '3rdparty:']) checker.assert_started() pantsd_run(['list', ':']) checker.assert_running() pantsd_run(['list', '::']) checker.assert_running() # And again using the cached BuildGraph. pantsd_run(['list', '::']) checker.assert_running() # Assert there were no warnings or errors thrown in the pantsd log. for line in read_pantsd_log(workdir): # Ignore deprecation warning emissions. if 'DeprecationWarning' in line: continue # Check if the line begins with W or E to check if it is a warning or error line. assertNotRegex(self, line, r'^[WE].*')
def test_native_logging(self): expected_msg = "\[DEBUG\] engine::scheduler: Launching \d+ root" pants_run = self.run_pants(["-linfo", "list", "src/scala::"]) assertNotRegex(self, pants_run.stderr_data, expected_msg) pants_run = self.run_pants(["-ldebug", "list", "src/scala::"]) assertRegex(self, pants_run.stderr_data, expected_msg)
def test_pantsd_run(self): extra_config = { 'GLOBAL': { # Muddies the logs with warnings: once all of the warnings in the repository # are fixed, this can be removed. 'glob_expansion_failure': 'ignore', } } with self.pantsd_successful_run_context( 'debug', extra_config=extra_config ) as (pantsd_run, checker, workdir, _): pantsd_run(['list', '3rdparty:']) checker.assert_started() pantsd_run(['list', ':']) checker.assert_running() pantsd_run(['list', '::']) checker.assert_running() # And again using the cached BuildGraph. pantsd_run(['list', '::']) checker.assert_running() # Assert there were no warnings or errors thrown in the pantsd log. full_log = '\n'.join(read_pantsd_log(workdir)) for line in read_pantsd_log(workdir): # Ignore deprecation warning emissions. if 'DeprecationWarning' in line: continue # Check if the line begins with W or E to check if it is a warning or error line. assertNotRegex(self, line, r'^[WE].*', 'error message detected in log:\n{}'.format(full_log))
def test_pantsd_invalidation_stale_sources(self): test_path = 'tests/python/pants_test/daemon_correctness_test_0001' test_build_file = os.path.join(test_path, 'BUILD') test_src_file = os.path.join(test_path, 'some_file.py') has_source_root_regex = r'"source_root": ".*/{}"'.format(test_path) export_cmd = ['export', test_path] try: with self.pantsd_successful_run_context() as (pantsd_run, checker, workdir, _): safe_mkdir(test_path, clean=True) pantsd_run(['help']) checker.assert_started() safe_file_dump(test_build_file, "python_library(sources=globs('some_non_existent_file.py'))") result = pantsd_run(export_cmd) checker.assert_running() assertNotRegex(self, result.stdout_data, has_source_root_regex) safe_file_dump(test_build_file, "python_library(sources=globs('*.py'))") result = pantsd_run(export_cmd) checker.assert_running() assertNotRegex(self, result.stdout_data, has_source_root_regex) safe_file_dump(test_src_file, 'import this\n') result = pantsd_run(export_cmd) checker.assert_running() assertRegex(self, result.stdout_data, has_source_root_regex) finally: rm_rf(test_path)
def test_engine_list(self): pants_run = self.run_pants(['-ldebug', 'list', '3rdparty::']) self.assert_success(pants_run) assertRegex(self, pants_run.stderr_data, 'build_graph is: .*LegacyBuildGraph') assertRegex(self, pants_run.stderr_data, 'computed \d+ nodes in') assertNotRegex(self, pants_run.stderr_data, 'pantsd is running at pid \d+')
def test_native_logging(self): expected_msg = "\[DEBUG\] engine::scheduler: Launching \d+ root" pants_run = self.run_pants([ "-linfo", "list", "src/scala::" ]) assertNotRegex(self, pants_run.stderr_data, expected_msg) pants_run = self.run_pants([ "-ldebug", "list", "src/scala::" ]) assertRegex(self, pants_run.stderr_data, expected_msg)