Skip to content

Commit cbf2235

Browse files
committed
chore: reinstate env passing, defer main window creation
1 parent 1e2c10e commit cbf2235

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
@@ -144,6 +144,7 @@ type TauriCapability = {
144144
'wdio:tauriServiceOptions': {
145145
appBinaryPath: string;
146146
appArgs: string[];
147+
env?: Record<string, string>;
147148
captureBackendLogs?: boolean;
148149
captureFrontendLogs?: boolean;
149150
backendLogLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error';
@@ -185,6 +186,7 @@ if (envContext.isMultiremote) {
185186
'wdio:tauriServiceOptions': {
186187
appBinaryPath: appBinaryPath,
187188
appArgs: ['--browser=A'],
189+
env: baseEnv,
188190
// Enable log capture for logging tests
189191
captureBackendLogs: true,
190192
captureFrontendLogs: true,
@@ -205,6 +207,7 @@ if (envContext.isMultiremote) {
205207
'wdio:tauriServiceOptions': {
206208
appBinaryPath: appBinaryPath,
207209
appArgs: ['--browser=B'],
210+
env: baseEnv,
208211
// Enable log capture for logging tests
209212
captureBackendLogs: true,
210213
captureFrontendLogs: true,
@@ -217,6 +220,11 @@ if (envContext.isMultiremote) {
217220
},
218221
};
219222
} else {
223+
const baseEnv: Record<string, string> = {};
224+
if (envContext.isSplashEnabled) {
225+
baseEnv.ENABLE_SPLASH_WINDOW = 'true';
226+
}
227+
220228
capabilities = [
221229
{
222230
browserName: 'tauri',
@@ -227,6 +235,7 @@ if (envContext.isMultiremote) {
227235
'wdio:tauriServiceOptions': {
228236
appBinaryPath: appBinaryPath,
229237
appArgs: ['foo', 'bar=baz'],
238+
env: baseEnv,
230239
// Enable log capture for logging tests
231240
captureBackendLogs: true,
232241
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)