Skip to content

chore: add unit tests on ci for Windows #7539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,13 @@ jobs:
test-unit:
name: Unit Tests
if: always() && needs.changes.outputs.build-unit == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
settings:
- host: ubuntu-latest
- host: windows-latest

runs-on: ${{ matrix.settings.host }}
needs:
- changes
- build-other-packages
Expand Down
17 changes: 12 additions & 5 deletions packages/qwik/src/cli/add/update-files.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'node:fs';
import { extname, join } from 'node:path';
import { extname, join, normalize } from 'node:path';
import type { FsUpdates, UpdateAppOptions } from '../types';
import { getPackageManager } from '../utils/utils';

Expand All @@ -22,12 +22,18 @@ export async function mergeIntegrationDir(
const s = await fs.promises.stat(srcChildPath);

if (s.isDirectory()) {
await mergeIntegrationDir(fileUpdates, opts, srcChildPath, destRootPath, alwaysInRoot);
await mergeIntegrationDir(
fileUpdates,
opts,
srcChildPath,
normalize(destRootPath).replace(/\\/g, '/'),
alwaysInRoot
);
} else if (s.isFile()) {
const finalDestPath = getFinalDestPath(opts, destRootPath, destDir, destName, alwaysInRoot);

if (destName === 'package.json') {
await mergePackageJsons(fileUpdates, srcChildPath, destRootPath);
await mergePackageJsons(fileUpdates, srcChildPath, destRootPath.replace(/\\/g, '/'));
} else if (destName === 'settings.json') {
await mergeJsons(fileUpdates, srcChildPath, finalDestPath);
} else if (destName === 'README.md') {
Expand All @@ -37,7 +43,7 @@ export async function mergeIntegrationDir(
destName === '.prettierignore' ||
destName === '.eslintignore'
) {
await mergeIgnoresFile(fileUpdates, srcChildPath, destRootPath);
await mergeIgnoresFile(fileUpdates, srcChildPath, destRootPath.replace(/\\/g, '/'));
} else if (ext === '.css') {
await mergeCss(fileUpdates, srcChildPath, finalDestPath, opts);
} else if (fs.existsSync(finalDestPath)) {
Expand Down Expand Up @@ -79,7 +85,8 @@ function getFinalDestPath(
? destRootPath
: destChildPath;

return finalDestPath;
// Normalize path separators to forward slashes for cross-platform compatibility
return normalize(finalDestPath).replace(/\\/g, '/');
}

async function mergePackageJsons(fileUpdates: FsUpdates, srcPath: string, destPath: string) {
Expand Down
21 changes: 13 additions & 8 deletions packages/qwik/src/optimizer/src/plugins/plugin.unit.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import path, { resolve } from 'node:path';
import { assert, describe, expect, test } from 'vitest';
import { normalizePath } from '../../../testing/util';
import type { QwikManifest } from '../types';
import { ExperimentalFeatures, createQwikPlugin } from './plugin';
import { normalizePath } from '../../../testing/util';
import { qwikVite } from './vite';
import type { ResolvedId } from 'rollup';

const cwd = process.cwd();

Expand Down Expand Up @@ -244,18 +245,22 @@ describe('resolveId', () => {
).toHaveProperty('id', '/root/src/routes/layout.tsx_s_7xk04rim0vu.js');
expect(await plugin.resolveId(null!, './foo', '/root/src/routes/layout.tsx')).toBeFalsy();
expect(
await plugin.resolveId(
ctx,
'./layout.tsx_layout_component_usetask_1_7xk04rim0vu.js',
'/root/src/routes/layout.tsx'
)
).toHaveProperty('id', '/root/src/routes/layout.tsx_layout_component_usetask_1_7xk04rim0vu.js');
(
(await plugin.resolveId(
ctx,
'./layout.tsx_layout_component_usetask_1_7xk04rim0vu.js',
'/root/src/routes/layout.tsx'
)) as ResolvedId
).id
).toContain('/root/src/routes/layout.tsx_layout_component_usetask_1_7xk04rim0vu.js');
// this uses the already populated id we created above
expect(
await plugin.resolveId(
{
resolve: (id: string, importer: string) => {
expect(id).toBe('/root/src/routes/foo');
expect(id).toContain(
process.platform === 'win32' ? '\\root\\src\\routes\\foo' : '/root/src/routes/foo'
);
expect(importer).toBe('Yey');
return { id: 'hi' };
},
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/optimizer/src/plugins/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export function normalizeRollupOutputOptionsObject(
const sanitized = relativePath
.replace(/^(\.\.\/)+/, '')
.replace(/^\/+/, '')
.replace(/\//g, '-');
.replace(/[\\/]/g, '-');
return `build/${sanitized}.js`;
};
}
Expand Down
Loading