Skip to content

Commit

Permalink
chore(tests): enhance e2e test logs and delay for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Sep 15, 2024
1 parent 70b8525 commit 963411a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions core/tests/app-updater/tests/fixtures/tauri-v1/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand All @@ -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}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) => {
Expand Down
8 changes: 5 additions & 3 deletions core/tests/app-updater/tests/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 963411a

Please sign in to comment.