Skip to content

Commit

Permalink
chery-pick(#17599): Revert "fix(pwt): compatibility in CWD with wrong…
Browse files Browse the repository at this point in the history
… casing (#16636)"
  • Loading branch information
pavelfeldman committed Sep 27, 2022
1 parent 6e8c2c5 commit 4b22c3f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 66 deletions.
22 changes: 0 additions & 22 deletions packages/playwright-test/src/loader.ts
Expand Up @@ -295,8 +295,6 @@ export class Loader {
}

private async _requireOrImport(file: string) {
if (process.platform === 'win32')
file = await fixWin32FilepathCapitalization(file);
const revertBabelRequire = installTransform();
const isModule = fileIsModule(file);
try {
Expand Down Expand Up @@ -688,23 +686,3 @@ export function folderIsModule(folder: string): boolean {
// Rely on `require` internal caching logic.
return require(packageJsonPath).type === 'module';
}

async function fixWin32FilepathCapitalization(file: string): Promise<string> {
/**
* On Windows with PowerShell <= 6 it is possible to have a CWD with different
* casing than what the actual directory on the filesystem is. This can cause
* that we require the file multiple times with different casing. To mitigate
* this we get the actual underlying filesystem path and use that.
* https://github.com/microsoft/playwright/issues/9193#issuecomment-1219362150
*/
const realFile = await new Promise<string>((resolve, reject) => fs.realpath.native(file, (error, realFile) => {
if (error)
return reject(error);
resolve(realFile);
}));
// We do not want to resolve them (e.g. 8.3 filenames), so we do a best effort
// approach by only using it if the actual lowercase characters are the same:
if (realFile.toLowerCase() === file.toLowerCase())
return realFile;
return file;
}
4 changes: 2 additions & 2 deletions tests/installation/npmTest.ts
Expand Up @@ -25,8 +25,8 @@ import debugLogger from 'debug';
import { Registry } from './registry';
import { spawnAsync } from './spawnAsync';

// os.tmpdir() on Windows returns a 8.3 filename, so we resolve it.
export const TMP_WORKSPACES = path.join(os.platform() === 'darwin' ? '/tmp' : fs.realpathSync.native(os.tmpdir()), 'pwt', 'workspaces');

export const TMP_WORKSPACES = path.join(os.platform() === 'darwin' ? '/tmp' : os.tmpdir(), 'pwt', 'workspaces');

const debug = debugLogger('itest');

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion tests/installation/playwright.config.ts
Expand Up @@ -27,7 +27,7 @@ const config: PlaywrightTestConfig = {
timeout: 5 * 60 * 1000,
retries: 0,
reporter: process.env.CI ? [
['list'],
['dot'],
['json', { outputFile: path.join(outputDir, 'report.json') }],
] : [['list'], ['html', { open: 'on-failure' }]],
forbidOnly: !!process.env.CI,
Expand Down

0 comments on commit 4b22c3f

Please sign in to comment.