Report progress for silent dependency installs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import unittest
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
from unittest.mock import patch
|
||||
@@ -11,6 +12,33 @@ from deploy_tool.scanner import ProjectComponent, ScanResult
|
||||
|
||||
|
||||
class DeployerTests(unittest.TestCase):
|
||||
def test_silent_npm_process_reports_heartbeat(self):
|
||||
output = []
|
||||
|
||||
class SlowOutput:
|
||||
def __iter__(self):
|
||||
time.sleep(0.03)
|
||||
return iter(())
|
||||
|
||||
class FakeProcess:
|
||||
stdout = SlowOutput()
|
||||
|
||||
def poll(self):
|
||||
return None
|
||||
|
||||
def wait(self):
|
||||
return 0
|
||||
|
||||
exit_code = deployer_module._stream_process_output(
|
||||
FakeProcess(),
|
||||
["npm.cmd", "install"],
|
||||
output.append,
|
||||
heartbeat_seconds=0.01,
|
||||
)
|
||||
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertTrue(any("npm 可能正在解析依赖" in line for line in output))
|
||||
|
||||
def test_process_output_accepts_utf8_and_gbk_without_decode_failure(self):
|
||||
output = []
|
||||
popen_options = {}
|
||||
|
||||
Reference in New Issue
Block a user