1- import { cp , realpath , symlink } from 'node:fs/promises' ;
2- import { isWindowsTestMode , windowsTmpDir } from '../utils/wsl' ;
1+ import { cp , mkdir , realpath } from 'node:fs/promises' ;
32import path from 'node:path' ;
3+ import { getGlobalVariable } from '../utils/env' ;
4+ import { interopWslPathForOutsideIfNecessary , isWindowsTestMode } from '../utils/wsl' ;
45
56/**
67 * Configure Windows WSL test setup, if needed.
@@ -11,15 +12,42 @@ export default async function () {
1112 return ;
1213 }
1314
14- // Unwrap the symlink of Windows. Windows will otherwise not be able to execute the binary.
15+ // Expose Git binary in path. Node is already exposes via the NPM directory.
16+ // These global tools are used by e2e tests.
17+ process . env [ 'PATH' ] = [ process . env . PATH , windowsMode . gitBinaryDirForWindows ] . join ( path . delimiter ) ;
18+
19+ // Unwrap the symlinks by Bazel. Windows will otherwise not be able to execute the binary.
1520 // Trick: We use the promises-variant as that one is not patched by Aspect and can resolve outside sandbox/runfiles.
16- const downloadedNodeBinary = await realpath ( windowsMode . nodeBinaryForWindowsInsideWslPath ) ;
21+ const downloadedNodeBinary = await realpath ( windowsMode . wslRootBinariesNeedingCopy . nodePath ) ;
22+ const downloadedChromium = await realpath ( windowsMode . wslRootBinariesNeedingCopy . chromiumPath ) ;
23+ const downloadedChromedriver = await realpath (
24+ windowsMode . wslRootBinariesNeedingCopy . chromedriverPath ,
25+ ) ;
1726
1827 // We will copy the Node version outside of WSL, as otherwise junctions to inside WSL,
1928 // or the UNC path system messes up npm.
20- await cp ( downloadedNodeBinary , windowsMode . nodeBinaryForWindowsPath ) ;
29+ await cp ( downloadedNodeBinary , windowsMode . copiedWindowsBinaries . nodePath ) ;
2130
22- // Expose Git binary in path. Node is already exposes via the NPM directory.
23- // These global tools are used by e2e tests.
24- process . env [ 'PATH' ] = [ process . env . PATH , windowsMode . gitBinaryDirForWindows ] . join ( path . delimiter ) ;
31+ const tmpRoot = getGlobalVariable ( 'tmp-root' ) ;
32+ const chromeTestingTmpDir = path . join ( tmpRoot , 'chrome-testing-tools' ) ;
33+ const chromiumDestDir = path . join ( tmpRoot , 'chromium' ) ;
34+ const chromedriverDestDir = path . join ( tmpRoot , 'chromedriver' ) ;
35+
36+ await mkdir ( chromeTestingTmpDir ) ;
37+ await cp ( path . dirname ( downloadedChromium ) , chromiumDestDir , { recursive : true } ) ;
38+ await cp ( path . dirname ( downloadedChromedriver ) , chromedriverDestDir , { recursive : true } ) ;
39+
40+ const chromiumBinDestPath = path . join ( chromiumDestDir , path . basename ( downloadedChromium ) ) ;
41+ const chromedriverBinDestPath = path . join (
42+ chromedriverDestDir ,
43+ path . basename ( downloadedChromedriver ) ,
44+ ) ;
45+
46+ process . env . CHROME_BIN = interopWslPathForOutsideIfNecessary ( chromiumBinDestPath ) ;
47+ process . env . CHROME_PATH = interopWslPathForOutsideIfNecessary ( chromiumBinDestPath ) ;
48+ process . env . CHROMEDRIVER_BIN = interopWslPathForOutsideIfNecessary ( chromedriverBinDestPath ) ;
49+
50+ // Update `TEMP` to the Windows tmp root that we configure in 001-create-tmp-dir.
51+ // Otherwise we'd spawn Node processes outside WSL with a temp dir in the WSL VM.
52+ process . env . TEMP = tmpRoot ;
2553}
0 commit comments