Esempio n. 1
0
 def pantsd(self):
     return PantsDaemon(self._build_root,
                        self._pants_workdir,
                        self._log_level,
                        self._native,
                        self._log_dir,
                        reset_func=clean_global_runtime_state)
Esempio n. 2
0
def test_close_stdio(mock_close):
    mock_options = unittest.mock.Mock()
    mock_options_values = unittest.mock.Mock()
    mock_options.for_global_scope.return_value = mock_options_values
    mock_options_values.pants_subprocessdir = "non_existent_dir"
    mock_server = unittest.mock.Mock()

    def create_services(bootstrap_options, legacy_graph_scheduler):
        return PantsServices()

    pantsd = PantsDaemon(
        native=Native(),
        work_dir="test_work_dir",
        log_level=logging.INFO,
        server=mock_server,
        core=PantsDaemonCore(create_services),
        metadata_base_dir="/tmp/pants_test_metadata_dir",
        bootstrap_options=mock_options,
    )

    with stdio_as(-1, -1, -1):
        handles = (sys.stdin, sys.stdout, sys.stderr)
        fds = [h.fileno() for h in handles]
        pantsd._close_stdio()
        mock_close.assert_has_calls(unittest.mock.call(x) for x in fds)
        for handle in handles:
            assert handle.closed is True
Esempio n. 3
0
 def pantsd(self):
   if not self._pantsd:
     self._pantsd = PantsDaemon(self._build_root,
                                self._pants_workdir,
                                self._log_level,
                                self._log_dir)
   return self._pantsd
Esempio n. 4
0
 def setUp(self):
     super(PantsDaemonTest, self).setUp()
     mock_options = mock.Mock()
     mock_options.pants_subprocessdir = 'non_existent_dir'
     self.pantsd = PantsDaemon(None, 'test_buildroot', 'test_work_dir',
                               logging.INFO, PantsServices(),
                               '/tmp/pants_test_metadata_dir', mock_options)
     self.mock_killswitch = mock.Mock()
     self.pantsd._kill_switch = self.mock_killswitch
     self.mock_service = mock.create_autospec(PantsService, spec_set=True)
Esempio n. 5
0
    def setUp(self):
        super(PantsDaemonTest, self).setUp()
        self.pantsd = PantsDaemon('test_buildroot',
                                  'test_work_dir',
                                  logging.INFO,
                                  log_dir='/non_existent')
        self.pantsd.set_services([])
        self.pantsd.set_socket_map({})

        self.mock_killswitch = mock.Mock()
        self.pantsd._kill_switch = self.mock_killswitch

        self.mock_service = mock.create_autospec(PantsService, spec_set=True)
 def setUp(self):
     super().setUp()
     mock_options = unittest.mock.Mock()
     mock_options.pants_subprocessdir = "non_existent_dir"
     self.pantsd = PantsDaemon(
         None,
         "test_buildroot",
         "test_work_dir",
         logging.INFO,
         PantsServices(),
         "/tmp/pants_test_metadata_dir",
         mock_options,
     )
     self.mock_killswitch = unittest.mock.Mock()
     self.pantsd._kill_switch = self.mock_killswitch
     self.mock_service = unittest.mock.create_autospec(PantsService,
                                                       spec_set=True)
Esempio n. 7
0
  def setUp(self):
    super(PantsDaemonTest, self).setUp()
    lock = threading.RLock()
    self.pantsd = PantsDaemon('test_buildroot',
                              'test_work_dir',
                              logging.INFO,
                              None,
                              log_dir='/non_existent',
                              metadata_base_dir=self.subprocess_dir)
    self.pantsd.set_services([])
    self.pantsd.set_socket_map({})
    self.pantsd.set_lock(lock)

    self.mock_killswitch = mock.Mock()
    self.pantsd._kill_switch = self.mock_killswitch

    self.mock_service = mock.create_autospec(PantsService, spec_set=True)
Esempio n. 8
0
    def setUp(self):
        super().setUp()
        mock_options = unittest.mock.Mock()
        mock_options_values = unittest.mock.Mock()
        mock_options.for_global_scope.return_value = mock_options_values
        mock_options_values.pants_subprocessdir = "non_existent_dir"
        mock_server = unittest.mock.Mock()

        def create_services(bootstrap_options, legacy_graph_scheduler):
            return PantsServices()

        self.pantsd = PantsDaemon(
            native=Native(),
            work_dir="test_work_dir",
            log_level=logging.INFO,
            server=mock_server,
            core=PantsDaemonCore(create_services),
            metadata_base_dir="/tmp/pants_test_metadata_dir",
            bootstrap_options=mock_options,
        )
Esempio n. 9
0
 def pantsd(self):
     return PantsDaemon(self._build_root, self._pants_workdir,
                        self._log_level, self._log_dir)