Skip to content

Commit

Permalink
Merge pull request #1740 from patricklx/patch-4
Browse files Browse the repository at this point in the history
enable vite windows tests
  • Loading branch information
NullVoxPopuli authored Dec 21, 2023
2 parents 2edb355 + 08543bd commit 241f631
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
1 change: 0 additions & 1 deletion test-packages/support/suite-setup-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ async function githubMatrix() {
})),
...suites
.filter(s => s.name !== 'jest-suites') // TODO: jest tests do not work under windows yet
.filter(s => !s.name.includes('vite-app')) // TODO: vite-app tests do not work under windows yet
.filter(s => !s.name.includes('watch-mode')) // TODO: watch tests are far too slow on windows right now
.map(s => ({
name: `${s.name} windows`,
Expand Down
32 changes: 32 additions & 0 deletions tests/scenarios/vite-app-test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import { viteAppScenarios } from './scenarios';
import type { PreparedApp } from 'scenario-tester';
import QUnit from 'qunit';
import { exec } from 'child_process';
import { readdirSync } from 'fs-extra';
import { join } from 'path';

const { module: Qmodule, test } = QUnit;

// cannot use util.promisify
// because then qunit will exit early with
// an error about an async hold
function execPromise(command: string): Promise<string> {
return new Promise(function (resolve, reject) {
exec(command, (error, stdout) => {
if (error) {
reject(error);
return;
}
resolve(stdout.trim());
});
});
}

viteAppScenarios
.map('vite-app-basics', _project => {})
.forEachScenario(scenario => {
Expand All @@ -16,6 +32,22 @@ viteAppScenarios
app = await scenario.prepare();
});

if (process.platform === 'win32') {
test(`correct windows path`, async function (assert) {
// windows sometimes generates short path alias 8.3
// which leads to resolving errors later
// e.g. cannot find owning engine for C:\Users\runneradmin\AppData\Local\Temp\tmp-2256UvRXnGotcjxi\node_modules\.embroider\rewritten-app
// the value in engines are: C:\Users\RUNNER~1\AppData\Local\Temp\tmp-2256UvRXnGotcjxi\node_modules\.embroider\rewritten-app
// it looks like there is no way to fix this in JS with
// e.g fs.realpath, resolve, normalize
// Powershell command can be used, python could also resolve it...
const command = `powershell.exe -command "(Get-Item -LiteralPath '${app.dir}').FullName"`;
const dir = await execPromise(command);
app.dir = dir;
assert.ok(!dir.includes('~'));
});
}

test(`pnpm build:ember`, async function (assert) {
let result = await app.execute('pnpm build:ember');
assert.equal(result.exitCode, 0, result.output);
Expand Down

0 comments on commit 241f631

Please sign in to comment.