chore(tests): enhance e2e test logs and delay for CI

This commit is contained in:
Lucas Nogueira
2024-09-15 11:34:52 -03:00
parent 70b852595a
commit 963411a86a
3 changed files with 10 additions and 3 deletions

View File

@@ -7,6 +7,7 @@
use std::time::Duration;
fn main() {
eprintln!("running tauri v1 app...");
let mut context = tauri::generate_context!();
if std::env::var("TARGET").unwrap_or_default() == "nsis" {
// /D sets the default installation directory ($INSTDIR),
@@ -25,6 +26,7 @@ fn main() {
}
tauri::Builder::default()
.setup(|app| {
println!("current version: {}", app.package_info().version);
let handle = app.handle();
tauri::async_runtime::spawn(async move {
match handle
@@ -34,6 +36,7 @@ fn main() {
.await
{
Ok(update) => {
println!("got update {}", update.latest_version());
if update.is_update_available() {
if let Err(e) = update.download_and_install().await {
println!("{e}");

View File

@@ -7,11 +7,13 @@
use tauri_plugin_updater::UpdaterExt;
fn main() {
eprintln!("running tauri v2 app...");
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.setup(|app| {
let handle = app.handle().clone();
println!("current version: {}", app.package_info().version);
tauri::async_runtime::spawn(async move {
match handle.updater().unwrap().check().await {
Ok(Some(update)) => {

View File

@@ -490,6 +490,8 @@ fn update_app_flow<F: FnOnce(Options<'_>) -> (PathBuf, TauriVersion)>(build_app_
vec![UPDATED_EXIT_CODE, UP_TO_DATE_EXIT_CODE]
};
let ci = std::env::var("CI").map(|v| v == "true").unwrap_or_default();
for expected_exit_code in status_checks {
let mut binary_cmd = if cfg!(windows) {
Command::new(tauri_v1_fixture_dir.join("target/debug/app-updater.exe"))
@@ -501,7 +503,7 @@ fn update_app_flow<F: FnOnce(Options<'_>) -> (PathBuf, TauriVersion)>(build_app_
.1
.join("Contents/MacOS/app-updater"),
)
} else if std::env::var("CI").map(|v| v == "true").unwrap_or_default() {
} else if ci {
let mut c = Command::new("xvfb-run");
c.arg("--auto-servernum").arg(
&bundle_paths(&tauri_v1_fixture_dir, "0.1.0")
@@ -542,12 +544,12 @@ fn update_app_flow<F: FnOnce(Options<'_>) -> (PathBuf, TauriVersion)>(build_app_
let code = status.code().unwrap_or(-1);
if code != expected_exit_code {
panic!("failed to update app\nexpected {expected_exit_code} got {code}",);
panic!("failed to update app\nexpected {expected_exit_code} got {code}");
}
// wait for the update to be applied on Windows
#[cfg(windows)]
std::thread::sleep(std::time::Duration::from_secs(3));
std::thread::sleep(std::time::Duration::from_secs(if ci { 6 } else { 3 }));
}
// force Rust to rebuild the binary so it doesn't conflict with other test runs