Skip to content

Commit 2ae57be

Browse files
authored
feat: Standardization of test execution methods in Windows (#76)
1 parent cb55122 commit 2ae57be

19 files changed

Lines changed: 1320 additions & 759 deletions

File tree

.github/workflows/ci-smoke.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
# Make this a reusable workflow, no value needed
66
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
77
inputs:
8+
os:
9+
description: 'OS for run'
10+
type: string
11+
default: "['ubuntu-latest', 'windows-latest', 'macos-latest']"
812
scenario:
913
description: 'Smoke scenario'
1014
type: string
@@ -19,7 +23,7 @@ jobs:
1923
fail-fast: false
2024
matrix:
2125
node-version: ['20']
22-
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
26+
os: ${{ fromJSON(inputs.os) }}
2327
runs-on: ${{ matrix.os }}
2428
steps:
2529
- name: 👷 Checkout

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,11 @@ jobs:
7474
uses: ./.github/workflows/ci-smoke.yml
7575
with:
7676
scenario: 'env'
77+
78+
smoke-retro-wdio:
79+
name: Smoke - Run test with temporary configuration file when lower version of WDIO
80+
needs: [lint, build, e2e]
81+
uses: ./.github/workflows/ci-smoke.yml
82+
with:
83+
os: "['windows-latest']"
84+
scenario: 'retro-wdio-win'

e2e/package.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,27 @@
1919
"test:smoke": "run-s test:smoke:*",
2020
"test:smoke:config": "cross-env VSCODE_WDIO_E2E_SCENARIO=config xvfb-maybe wdio run ./wdioSmoke.conf.ts",
2121
"test:smoke:timeout": "cross-env VSCODE_WDIO_E2E_SCENARIO=timeout xvfb-maybe wdio run ./wdioSmoke.conf.ts",
22+
"test:smoke:retro-wdio-win": "run-s test:smoke:retro-wdio-win:*",
23+
"test:smoke:retro-wdio-win:run-latest": "cross-env VSCODE_WDIO_E2E_SCENARIO=mocha VSCODE_WDIO_SMOKE_RETRO_WIN=no xvfb-maybe pnpm run wdio",
24+
"test:smoke:retro-wdio-win:prepare": "tsx ./scripts/retro-wdio-win.ts",
25+
"test:smoke:retro-wdio-win:run": "cross-env VSCODE_WDIO_E2E_SCENARIO=mocha VSCODE_WDIO_SMOKE_RETRO_WIN=yes xvfb-maybe pnpm run wdio",
26+
"test:smoke:retro-wdio-win:cleanup": "git checkout ../samples/e2e/mocha/package.json ../pnpm-lock.yaml && pnpm --filter @vscode-wdio/e2e-mocha install",
2227
"test:smoke:env": "cross-env VSCODE_WDIO_E2E_SCENARIO=env xvfb-maybe wdio run ./wdioSmoke.conf.ts",
2328
"wdio": "wdio run ./wdio.conf.ts"
2429
},
2530
"devDependencies": {
2631
"@types/semver": "^7.7.0",
27-
"@wdio/cli": "^9.13.0",
28-
"@wdio/globals": "^9.12.6",
29-
"@wdio/local-runner": "^9.13.0",
30-
"@wdio/mocha-framework": "^9.13.0",
31-
"@wdio/spec-reporter": "^9.13.0",
32-
"@wdio/types": "^9.15.0",
32+
"@wdio/cli": "^9.16.2",
33+
"@wdio/globals": "^9.16.2",
34+
"@wdio/local-runner": "^9.16.2",
35+
"@wdio/mocha-framework": "^9.16.2",
36+
"@wdio/spec-reporter": "^9.16.2",
37+
"@wdio/types": "^9.16.2",
3338
"chai": "^5.2.0",
3439
"expect": "^30.0.0",
3540
"semver": "^7.7.2",
3641
"wdio-vscode-service": "^6.1.3",
37-
"webdriver": "^9.13.0",
38-
"webdriverio": "^9.13.0"
42+
"webdriver": "^9.16.2",
43+
"webdriverio": "^9.16.2"
3944
}
4045
}

e2e/scripts/retro-wdio-win.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import shell from 'shelljs'
2+
3+
import pkg from '../../samples/e2e/mocha/package.json' with { type: 'json' }
4+
5+
const targetPkg = '@vscode-wdio/e2e-mocha'
6+
const targetWdioVersion = '9.15.0'
7+
8+
const wdioPkgs = Object.keys(pkg.devDependencies).filter((pkg) => pkg.startsWith('@wdio/'))
9+
10+
const targetWdioPkgs = wdioPkgs.map((pkg) => `${pkg}@${targetWdioVersion}`)
11+
12+
const cmd = `pnpm --filter ${targetPkg} install -D ${targetWdioPkgs.join(' ')}`
13+
14+
console.log(`\n>${cmd}\n`)
15+
16+
const result = shell.exec(cmd)
17+
process.exit(result.code)

e2e/tests/basic.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,21 @@ describe(`VS Code Extension Testing with ${targetFramework}`, function () {
8585

8686
await expect(items).toMatchTreeStructure(expected.runPartially)
8787
})
88+
89+
// eslint-disable-next-line mocha/no-setup-in-describe
90+
if (process.env.VSCODE_WDIO_SMOKE_RETRO_WIN === 'yes') {
91+
92+
it('should use temporally configuration file', async function () {
93+
await expect(workbench).hasExpectedLog(
94+
'Use temporary configuration files to run WDIO: @wdio/utils@9.15.0 < 9.16.0'
95+
)
96+
})
97+
98+
// eslint-disable-next-line mocha/no-setup-in-describe
99+
} else if (process.env.VSCODE_WDIO_SMOKE_RETRO_WIN === 'no') {
100+
101+
it('should not use temporally configuration file', async function () {
102+
await expect(workbench).hasExpectedLog(/Use cli argument to run WDIO: @wdio\/utils/)
103+
})
104+
}
88105
})

e2e/wdio.conf.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const version = isCompatibilityMode ? minimumVersion : 'stable'
2020
const outputDir = path.join(__dirname, 'logs', [isCompatibilityMode ? 'compatibility' : 'e2e', target].join('-'))
2121
process.env.VSCODE_WDIO_TRACE_LOG_PATH = outputDir
2222

23+
const loglevel = process.env.VSCODE_WDIO_SMOKE_RETRO_WIN ? 'debug' : 'trace'
24+
2325
function defineSpecs(target: TestTargets) {
2426
switch (target) {
2527
case 'cucumber':
@@ -38,7 +40,7 @@ export function createBaseConfig(workspacePath: string, userSettings = {}): Webd
3840
const resolvedUserSettings = Object.assign(
3941
{},
4042
{
41-
'webdriverio.logLevel': 'trace',
43+
'webdriverio.logLevel': loglevel,
4244
},
4345
userSettings
4446
)

packages/vscode-wdio-reporter/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
},
1717
"dependencies": {
1818
"@vscode-wdio/constants": "workspace:*",
19-
"@wdio/reporter": "^9.12.3"
19+
"@wdio/reporter": "^9.16.2"
2020
},
2121
"devDependencies": {
2222
"@vscode-wdio/types": "workspace:*",
23-
"@wdio/types": "^9.13.0"
23+
"@wdio/types": "^9.16.2"
2424
}
2525
}

packages/vscode-wdio-types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
"devDependencies": {
4949
"@vscode-wdio/constants": "workspace:*",
50-
"@wdio/types": "^9.13.0"
50+
"@wdio/types": "^9.16.2"
5151
},
5252
"dependencies": {
5353
"@types/ws": "^8.18.1"

packages/vscode-wdio-worker/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
"@vscode-wdio/utils": "workspace:*",
3232
"birpc": "^2.3.0",
3333
"dotenv": "^16.5.0",
34+
"import-meta-resolve": "^4.1.0",
3435
"recast": "^0.23.11",
3536
"ws": "^8.18.1"
3637
},
3738
"devDependencies": {
3839
"@types/ws": "^8.18.1",
3940
"@vscode-wdio/types": "workspace:*",
40-
"@wdio/cli": "^9.12.4"
41+
"@wdio/cli": "^9.16.2"
4142
}
4243
}

packages/vscode-wdio-worker/src/test.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as os from 'node:os'
33
import { dirname, isAbsolute, join, resolve } from 'node:path'
44

55
import { getLauncherInstance } from './cli.js'
6-
import { getTempConfigCreator, isWindows } from './utils.js'
6+
import { getTempConfigCreator, isFixedWdio, isWindows } from './utils.js'
77
import type { ResultSet } from '@vscode-wdio/types/reporter'
88
import type { RunTestOptions, TestResultData } from '@vscode-wdio/types/server'
99
import type { ILogger } from '@vscode-wdio/types/utils'
@@ -15,6 +15,13 @@ const VSCODE_REPORTER_PATH = resolve(__dirname, 'reporter.cjs')
1515
export async function runTest(this: WorkerMetaContext, options: RunTestOptions): Promise<TestResultData> {
1616
const outputDir = await getOutputDir.call(this)
1717
let configFile: string | undefined = undefined
18+
19+
// To avoid this issue, We use temporary configuration files
20+
// only on Windows platforms and for versions of @wdio/utils prior to 9.15.0.
21+
// https://github.com/webdriverio/webdriverio/issues/14532
22+
// This issue was fixed by this PR.
23+
// https://github.com/webdriverio/webdriverio/pull/14565
24+
const useTempConfigFile = isWindows() && !(await isFixedWdio.call(this, options.configPath))
1825
try {
1926
// Prepare launcher options
2027
const wdioArgs: RunCommandArguments = {
@@ -42,16 +49,14 @@ export async function runTest(this: WorkerMetaContext, options: RunTestOptions):
4249
await fs.mkdir(logDir, { recursive: true })
4350
}
4451

45-
if (isWindows()) {
52+
if (useTempConfigFile) {
4653
const creator = await getTempConfigCreator(this)
4754
configFile = await creator(options.configPath, outputDir.json!)
4855
options.configPath = configFile
4956
wdioArgs.configPath = configFile
50-
}
51-
52-
// The `stdout` must be true because the name of the logger is
53-
// the name of the file and the initialization of Write Stream will fail.
54-
if (!isWindows()) {
57+
} else {
58+
// The `stdout` must be true because the name of the logger is
59+
// the name of the file and the initialization of Write Stream will fail.
5560
wdioArgs.reporters = [[VSCODE_REPORTER_PATH, { stdout: true, outputDir: outputDir.json }]]
5661
}
5762

@@ -122,7 +127,7 @@ export async function runTest(this: WorkerMetaContext, options: RunTestOptions):
122127
if (outputDir.json) {
123128
await removeResultDir(this.log, outputDir.json)
124129
}
125-
if (isWindows() && configFile) {
130+
if (useTempConfigFile && configFile) {
126131
try {
127132
this.log.debug(`Remove temp config file...: ${configFile}`)
128133
await fs.rm(configFile, { recursive: true, force: true })

0 commit comments

Comments
 (0)