[tests] improving remote dev launcher test diagnostics

GitOrigin-RevId: 437c45b2711c683578dbab03171760f271b9f3f2
This commit is contained in:
Roman Shevchenko
2024-09-11 09:55:12 +02:00
committed by intellij-monorepo-bot
parent c792d53f08
commit 08244e6c15
2 changed files with 18 additions and 20 deletions

View File

@@ -29,10 +29,10 @@ mod tests {
#[test]
fn remote_dev_known_command_without_project_path_test() {
let remote_dev_command = &["dumpLaunchParameters"];
let output = run_launcher(LauncherRunSpec::remote_dev().with_args(remote_dev_command)).stdout;
let run_result = run_launcher(LauncherRunSpec::remote_dev().with_args(remote_dev_command));
assert!(output.contains("dump-launch-parameters"), "output:\n{}", output);
assert!(!output.contains("Usage: ./remote-dev-server [ij_command_name] [/path/to/project] [arguments...]"), "output:\n{}", output);
check_output(&run_result, |output| output.contains("dump-launch-parameters"));
check_output(&run_result, |output| !output.contains("Usage: ./remote-dev-server [ij_command_name] [/path/to/project] [arguments...]"));
}
#[test]
@@ -46,12 +46,12 @@ mod tests {
fn remote_dev_known_command_with_project_path_test() {
let test = prepare_test_env(LauncherLocation::RemoteDev);
let remote_dev_command = &["run", &test.project_dir.display().to_string()];
let output = run_launcher_ext(&test, LauncherRunSpec::remote_dev().with_args(remote_dev_command)).stdout;
let run_result = run_launcher_ext(&test, LauncherRunSpec::remote_dev().with_args(remote_dev_command));
let project_dir = format!("{:?}", &test.project_dir);
assert!(output.contains("remoteDevHost"), "'remoteDevHost' not in output:\n{}", output);
assert!(output.contains(project_dir.as_str()), "'{project_dir}' not in output:\n{}", output);
assert!(!output.contains("Usage: ./remote-dev-server [ij_command_name] [/path/to/project] [arguments...]"), "output:\n{}", output);
check_output(&run_result, |output| output.contains("remoteDevHost"));
check_output(&run_result, |output| output.contains(project_dir.as_str()));
check_output(&run_result, |output| !output.contains("Usage: ./remote-dev-server [ij_command_name] [/path/to/project] [arguments...]"));
}
#[test]
@@ -67,12 +67,12 @@ mod tests {
let project_dir = &test.project_dir.to_string_lossy().to_string();
let remote_dev_command = &["warmup", project_dir];
let output = run_launcher_ext(&test, LauncherRunSpec::remote_dev().with_args(remote_dev_command)).stdout;
let run_result = run_launcher_ext(&test, LauncherRunSpec::remote_dev().with_args(remote_dev_command));
let project_dir_arg = &format!("--project-dir={}", project_dir.replace('\\', "\\\\"));
assert!(output.contains("warmup"), "output:\n{}", output);
assert!(output.contains(project_dir_arg), "'{}' is not in the output:\n{}", project_dir_arg, output);
assert!(!output.contains("Usage: ./remote-dev-server [ij_command_name] [/path/to/project] [arguments...]"), "output:\n{}", output);
check_output(&run_result, |output| output.contains("warmup"));
check_output(&run_result, |output| output.contains(project_dir_arg));
check_output(&run_result, |output| !output.contains("Usage: ./remote-dev-server [ij_command_name] [/path/to/project] [arguments...]"));
}
#[test]
@@ -81,12 +81,10 @@ mod tests {
let remote_dev_command = &["serverMode", "print-cwd"];
let launch_result = run_launcher_ext(&test, LauncherRunSpec::standard().with_args(remote_dev_command));
let output = launch_result.stdout;
assert!(output.contains("Started in server mode"), "'serverMode' was not included in arguments:\n{}", output);
assert!(output.contains("Mode: remote-dev"), "Launched in non-remote mode:\n{}", output);
assert!(output.contains("CWD="), "Working directory was not printed:\n{}", output);
check_output(&launch_result, |output| output.contains("Started in server mode"));
check_output(&launch_result, |output| output.contains("Mode: remote-dev"));
check_output(&launch_result, |output| output.contains("CWD="));
}
#[test]
@@ -153,7 +151,7 @@ mod tests {
check_output(&launch_result, |output| output.contains(&expected_output));
}
fn check_output<Check>(run_result: &LauncherRunResult, check: Check) where Check: FnOnce(&String) -> bool{
assert!(check(&run_result.stdout), "stdout:\n{}\nstderr:\n{}", run_result.stdout, run_result.stderr)
fn check_output<Check>(run_result: &LauncherRunResult, check: Check) where Check: FnOnce(&String) -> bool {
assert!(check(&run_result.stdout), "Output check failed; run result: {:?}", run_result);
}
}

View File

@@ -484,8 +484,8 @@ impl LauncherRunResult {
impl Debug for LauncherRunResult {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!(
"\n** exit code: {:?} ({:?})\n** stderr: <<<{}>>>\n** stdout: <<<{}>>>",
self.exit_status.code(), self.exit_status, self.stderr, self.stdout))
"\n** exit status: {} (code: {:?})\n** stderr: <<<{}>>>\n** stdout: <<<{}>>>",
self.exit_status, self.exit_status.code(), self.stderr, self.stdout))
}
}