Skip to content

Commit edc5ff8

Browse files
committed
refactor: remove env passing, ensure isolation of window specs
1 parent a46d884 commit edc5ff8

File tree

3 files changed

+11
-52
lines changed

3 files changed

+11
-52
lines changed

e2e/wdio.tauri.conf.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,15 @@ switch (envContext.testType) {
122122
case 'standalone':
123123
specs = ['./test/tauri/standalone/*.spec.ts'];
124124
break;
125+
case 'window':
126+
// Window tests - only window-specific functionality
127+
specs = ['./test/tauri/window.spec.ts'];
128+
break;
125129
default:
126130
// Standard tests - core functionality without specialized test modes
127131
specs = ['./test/tauri/*.spec.ts'];
128-
// Exclude mocking tests for now
129-
exclude = ['./test/tauri/mocking.spec.ts'];
132+
// Exclude mocking tests and window tests (window tests require splash)
133+
exclude = ['./test/tauri/mocking.spec.ts', './test/tauri/window.spec.ts'];
130134
break;
131135
}
132136

@@ -181,8 +185,6 @@ if (envContext.isMultiremote) {
181185
'wdio:tauriServiceOptions': {
182186
appBinaryPath: appBinaryPath,
183187
appArgs: ['--browser=A'],
184-
// Pass environment variables to tauri-driver
185-
env: baseEnv,
186188
// Enable log capture for logging tests
187189
captureBackendLogs: true,
188190
captureFrontendLogs: true,
@@ -203,8 +205,6 @@ if (envContext.isMultiremote) {
203205
'wdio:tauriServiceOptions': {
204206
appBinaryPath: appBinaryPath,
205207
appArgs: ['--browser=B'],
206-
// Pass environment variables to tauri-driver
207-
env: baseEnv,
208208
// Enable log capture for logging tests
209209
captureBackendLogs: true,
210210
captureFrontendLogs: true,
@@ -217,12 +217,6 @@ if (envContext.isMultiremote) {
217217
},
218218
};
219219
} else {
220-
// Tauri standard configuration - create base env for tauri-driver
221-
const baseEnv: Record<string, string> = {};
222-
if (envContext.isSplashEnabled) {
223-
baseEnv.ENABLE_SPLASH_WINDOW = 'true';
224-
}
225-
226220
capabilities = [
227221
{
228222
browserName: 'tauri',
@@ -233,8 +227,6 @@ if (envContext.isMultiremote) {
233227
'wdio:tauriServiceOptions': {
234228
appBinaryPath: appBinaryPath,
235229
appArgs: ['foo', 'bar=baz'],
236-
// Pass environment variables to tauri-driver
237-
env: baseEnv,
238230
// Enable log capture for logging tests
239231
captureBackendLogs: true,
240232
captureFrontendLogs: true,

packages/tauri-service/src/launcher.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,10 @@ export default class TauriLaunchService {
483483

484484
// Set up environment variables for data directory isolation
485485
const envVarName = process.platform === 'linux' ? 'XDG_DATA_HOME' : 'TAURI_DATA_DIR';
486-
const env = { ...process.env, ...workerOptions.env, [envVarName]: dataDir };
486+
process.env[envVarName] = dataDir;
487487

488488
// Spawn tauri-driver for this worker
489-
await this.startTauriDriverForWorker(cid, port, nativePort, env, workerOptions);
489+
await this.startTauriDriverForWorker(cid, port, nativePort, workerOptions);
490490

491491
// Update capabilities with allocated port so WDIO connects to correct port
492492
// This is critical - the worker needs to know which port to connect to
@@ -668,7 +668,6 @@ export default class TauriLaunchService {
668668
workerId: string,
669669
port: number,
670670
nativePort: number,
671-
env: NodeJS.ProcessEnv,
672671
options?: TauriServiceOptions,
673672
): Promise<void> {
674673
console.log(`[CONSOLE-DEBUG] startTauriDriverForWorker called for worker-${workerId}`);
@@ -697,23 +696,13 @@ export default class TauriLaunchService {
697696
log.debug(`[worker-${workerId}] Using native driver: ${nativeDriverPath}`);
698697
}
699698

700-
// Extract data directory from env for storage and merge with worker options
701-
const customEnv = workerOptions.env || {};
702-
const spawnEnv = { ...process.env, ...env, ...customEnv };
703-
const dataDir = spawnEnv.XDG_DATA_HOME || spawnEnv.TAURI_DATA_DIR || '';
704-
705-
// DEBUG: Log key environment variables being passed
706-
log.debug(`[worker-${workerId}] Environment debug:`);
707-
log.debug(`[worker-${workerId}] ENABLE_SPLASH_WINDOW: ${spawnEnv.ENABLE_SPLASH_WINDOW || 'not set'}`);
708-
log.debug(`[worker-${workerId}] XDG_DATA_HOME: ${spawnEnv.XDG_DATA_HOME || 'not set'}`);
709-
log.debug(`[worker-${workerId}] TAURI_DATA_DIR: ${spawnEnv.TAURI_DATA_DIR || 'not set'}`);
710-
log.debug(`[worker-${workerId}] DISPLAY: ${spawnEnv.DISPLAY || 'not set'}`);
699+
// Extract data directory from env for storage
700+
const dataDir = process.env.XDG_DATA_HOME || process.env.TAURI_DATA_DIR || '';
711701

712702
await new Promise<void>((resolve, reject) => {
713703
const proc = spawn(tauriDriverPath, args, {
714704
stdio: ['ignore', 'pipe', 'pipe'],
715705
detached: false,
716-
env: spawnEnv,
717706
});
718707

719708
log.info(`[worker-${workerId}] Spawned process with PID: ${proc.pid ?? 'unknown'}`);
@@ -871,25 +860,13 @@ export default class TauriLaunchService {
871860
}
872861

873862
return new Promise((resolve, reject) => {
874-
// Use process.env as base and merge with any custom env from options
875-
const customEnv = options.env || {};
876-
const spawnEnv = { ...process.env, ...customEnv };
877-
878-
// DEBUG: Log key environment variables being passed
879-
log.debug(`Environment debug (single driver):`);
880-
log.debug(` ENABLE_SPLASH_WINDOW: ${spawnEnv.ENABLE_SPLASH_WINDOW || 'not set'}`);
881-
log.debug(` XDG_DATA_HOME: ${spawnEnv.XDG_DATA_HOME || 'not set'}`);
882-
log.debug(` TAURI_DATA_DIR: ${spawnEnv.TAURI_DATA_DIR || 'not set'}`);
883-
log.debug(` DISPLAY: ${spawnEnv.DISPLAY || 'not set'}`);
884-
885863
if (process.platform === 'linux') {
886-
log.info(`Starting tauri-driver (DISPLAY from environment: ${spawnEnv.DISPLAY || 'not set'})`);
864+
log.info(`Starting tauri-driver (DISPLAY from environment: ${process.env.DISPLAY || 'not set'})`);
887865
}
888866

889867
this.tauriDriverProcess = spawn(tauriDriverPath, args, {
890868
stdio: ['ignore', 'pipe', 'pipe'],
891869
detached: false,
892-
env: spawnEnv,
893870
});
894871

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

packages/tauri-service/src/types.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ 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-
* Use this to set environment-specific configurations like ENABLE_SPLASH_WINDOW
20-
* @default undefined
21-
*/
22-
env?: Record<string, string>;
2317
/**
2418
* Automatically install tauri-driver if not found
2519
* Requires Rust toolchain (cargo) to be installed
@@ -48,10 +42,6 @@ export interface TauriServiceOptions extends BaseTauriServiceOptions {
4842
export interface TauriServiceGlobalOptions extends BaseTauriServiceGlobalOptions {
4943
/**
5044
* Environment variables to pass to the spawned tauri-driver process
51-
* Use this to set environment-specific configurations like ENABLE_SPLASH_WINDOW
52-
* @default undefined
53-
*/
54-
env?: Record<string, string>;
5545
/**
5646
* Automatically install tauri-driver if not found
5747
* @default false

0 commit comments

Comments
 (0)