Skip to content

Commit f09c955

Browse files
committed
chore: reinstate env passing, defer main window creation
1 parent 8e74198 commit f09c955

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

e2e/wdio.tauri.conf.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ type TauriCapability = {
145145
'wdio:tauriServiceOptions': {
146146
appBinaryPath: string;
147147
appArgs: string[];
148+
env?: Record<string, string>;
148149
captureBackendLogs?: boolean;
149150
captureFrontendLogs?: boolean;
150151
backendLogLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error';
@@ -187,6 +188,7 @@ if (envContext.isMultiremote) {
187188
'wdio:tauriServiceOptions': {
188189
appBinaryPath: appBinaryPath,
189190
appArgs: ['--browser=A'],
191+
env: baseEnv,
190192
// Enable log capture for logging tests
191193
captureBackendLogs: true,
192194
captureFrontendLogs: true,
@@ -208,6 +210,7 @@ if (envContext.isMultiremote) {
208210
'wdio:tauriServiceOptions': {
209211
appBinaryPath: appBinaryPath,
210212
appArgs: ['--browser=B'],
213+
env: baseEnv,
211214
// Enable log capture for logging tests
212215
captureBackendLogs: true,
213216
captureFrontendLogs: true,
@@ -220,6 +223,11 @@ if (envContext.isMultiremote) {
220223
},
221224
};
222225
} else {
226+
const baseEnv: Record<string, string> = {};
227+
if (envContext.isSplashEnabled) {
228+
baseEnv.ENABLE_SPLASH_WINDOW = 'true';
229+
}
230+
223231
capabilities = [
224232
{
225233
browserName: 'tauri',
@@ -231,6 +239,7 @@ if (envContext.isMultiremote) {
231239
'wdio:tauriServiceOptions': {
232240
appBinaryPath: appBinaryPath,
233241
appArgs: ['foo', 'bar=baz'],
242+
env: baseEnv,
234243
// Enable log capture for logging tests
235244
captureBackendLogs: true,
236245
captureFrontendLogs: true,

fixtures/e2e-apps/tauri/src-tauri/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ fn main() {
242242
.transparent(true)
243243
.build()
244244
.expect("Failed to create splash window");
245+
} else {
246+
create_main_window(app.handle());
245247
}
246248
Ok::<(), Box<dyn std::error::Error>>(())
247249
})

fixtures/e2e-apps/tauri/src-tauri/tauri.conf.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,7 @@
2020
"capabilities": ["default"]
2121
},
2222
"withGlobalTauri": true,
23-
"windows": [
24-
{
25-
"label": "main",
26-
"title": "Tauri E2E App",
27-
"width": 800,
28-
"height": 600,
29-
"resizable": true,
30-
"fullscreen": false
31-
}
32-
]
23+
"windows": []
3324
},
3425
"plugins": {
3526
"tauri-driver": {

packages/tauri-service/src/launcher.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,12 @@ export default class TauriLaunchService {
700700
const dataDir = process.env.XDG_DATA_HOME || process.env.TAURI_DATA_DIR || '';
701701

702702
await new Promise<void>((resolve, reject) => {
703+
const spawnEnv = workerOptions.env ? { ...process.env, ...workerOptions.env } : undefined;
704+
703705
const proc = spawn(tauriDriverPath, args, {
704706
stdio: ['ignore', 'pipe', 'pipe'],
705707
detached: false,
708+
...(spawnEnv ? { env: spawnEnv } : {}),
706709
});
707710

708711
log.info(`[worker-${workerId}] Spawned process with PID: ${proc.pid ?? 'unknown'}`);
@@ -864,9 +867,12 @@ export default class TauriLaunchService {
864867
log.info(`Starting tauri-driver (DISPLAY from environment: ${process.env.DISPLAY || 'not set'})`);
865868
}
866869

870+
const spawnEnv = options.env ? { ...process.env, ...options.env } : undefined;
871+
867872
this.tauriDriverProcess = spawn(tauriDriverPath, args, {
868873
stdio: ['ignore', 'pipe', 'pipe'],
869874
detached: false,
875+
...(spawnEnv ? { env: spawnEnv } : {}),
870876
});
871877

872878
// Use readline for line-buffered log handling (fixes Windows chunking issues)

packages/tauri-service/src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export type TauriResult<T = unknown> = BaseTauriResult<T>;
1414
* - logDir: Custom log directory for standalone mode
1515
*/
1616
export interface TauriServiceOptions extends BaseTauriServiceOptions {
17+
/**
18+
* Environment variables to pass to the spawned tauri-driver process
19+
* These are merged with process.env when spawning the driver
20+
*/
21+
env?: Record<string, string>;
1722
/**
1823
* Automatically install tauri-driver if not found
1924
* Requires Rust toolchain (cargo) to be installed

0 commit comments

Comments
 (0)