Exemplo n.º 1
0
    def test_managed_webpack_compiler_in_watch_mode_raises_when_not_built(self):
        # NOTE: The 'Built at: ' message is never printed.
        self.exit_stack.enter_context(self.swap_popen(outputs=[b'abc', b'def']))
        str_io = python_utils.string_io()
        self.exit_stack.enter_context(python_utils.redirect_stdout(str_io))

        self.assertRaisesRegexp(
            IOError, 'First build never completed',
            lambda: self.exit_stack.enter_context(
                servers.managed_webpack_compiler(watch_mode=True)))
        self.assert_matches_regexps(str_io.getvalue().strip().split('\n'), [
            'Starting new Webpack Compiler',
            'abc',
            'def',
            'Stopping Webpack Compiler',
        ])
Exemplo n.º 2
0
    def test_managed_webpack_compiler_in_watch_mode_when_build_succeeds(self):
        popen_calls = self.exit_stack.enter_context(self.swap_popen(
            outputs=[b'abc', b'Built at: 123', b'def']))
        str_io = python_utils.string_io()
        self.exit_stack.enter_context(python_utils.redirect_stdout(str_io))
        logs = self.exit_stack.enter_context(self.capture_logging())

        proc = self.exit_stack.enter_context(servers.managed_webpack_compiler(
            watch_mode=True))
        self.exit_stack.close()

        self.assert_proc_was_managed_as_expected(logs, proc.pid)
        self.assertEqual(len(popen_calls), 1)
        self.assertIn('--color', popen_calls[0].program_args)
        self.assertIn('--watch', popen_calls[0].program_args)
        self.assertIn('--progress', popen_calls[0].program_args)
        self.assert_matches_regexps(str_io.getvalue().strip().split('\n'), [
            'Starting new Webpack Compiler',
            'abc',
            'Built at: 123',
            'def',
            'Stopping Webpack Compiler',
        ])