@@ -2,48 +2,35 @@ import { expect, test } from '@playwright/test'
22import path from 'path'
33import fs from 'fs-extra'
44import os from 'os'
5- import { exec } from 'child_process'
6- import { promisify } from 'util'
7- import { REPO_ROOT , startVSCode , SUSHI_SOURCE_PATH } from './utils'
8-
9- const execAsync = promisify ( exec )
5+ import {
6+ createVirtualEnvironment ,
7+ pipInstall ,
8+ REPO_ROOT ,
9+ startVSCode ,
10+ SUSHI_SOURCE_PATH ,
11+ } from './utils'
1012
1113/**
1214 * Helper function to create and set up a Python virtual environment
1315 */
1416async function setupPythonEnvironment ( envDir : string ) : Promise < string > {
1517 // Create virtual environment
16- const pythonCmd = process . platform === 'win32' ? 'python' : 'python3'
17- const { stderr } = await execAsync ( `${ pythonCmd } -m venv "${ envDir } "` )
18- if ( stderr && ! stderr . includes ( 'WARNING' ) ) {
19- throw new Error ( `Failed to create venv: ${ stderr } ` )
20- }
21-
22- // Get paths
23- const isWindows = process . platform === 'win32'
24- const binDir = path . join ( envDir , isWindows ? 'Scripts' : 'bin' )
25- const pythonPath = path . join ( binDir , isWindows ? 'python.exe' : 'python' )
26- const pipPath = path . join ( binDir , isWindows ? 'pip.exe' : 'pip' )
18+ const pythonDetails = await createVirtualEnvironment ( envDir )
2719
2820 // Install the mock tcloud package
2921 const mockTcloudPath = path . join ( __dirname , 'tcloud' )
30- const { stderr : pipErr1 } = await execAsync (
31- `"${ pipPath } " install -e "${ mockTcloudPath } "` ,
32- )
33- if ( pipErr1 && ! pipErr1 . includes ( 'WARNING' ) && ! pipErr1 . includes ( 'notice' ) ) {
34- throw new Error ( `Failed to install mock tcloud: ${ pipErr1 } ` )
35- }
22+ await pipInstall ( pythonDetails , [ mockTcloudPath ] )
3623
3724 // Install sqlmesh from the local repository with LSP support
38- const sqlmeshRepoPath = path . join ( __dirname , '..' , '..' , '..' ) // Navigate to repo root from tests dir
39- const { stderr : pipErr2 } = await execAsync (
40- `"${ pipPath } " install -e "${ sqlmeshRepoPath } [lsp,bigquery]" "${ REPO_ROOT } /examples/custom_materializations"` ,
25+ const customMaterializations = path . join (
26+ REPO_ROOT ,
27+ 'examples' ,
28+ 'custom_materializations' ,
4129 )
42- if ( pipErr2 && ! pipErr2 . includes ( 'WARNING' ) && ! pipErr2 . includes ( 'notice' ) ) {
43- throw new Error ( `Failed to install sqlmesh: ${ pipErr2 } ` )
44- }
30+ const sqlmeshWithExtras = `${ REPO_ROOT } [lsp,bigquery]`
31+ await pipInstall ( pythonDetails , [ sqlmeshWithExtras , customMaterializations ] )
4532
46- return pythonPath
33+ return pythonDetails . pythonPath
4734}
4835
4936/**
0 commit comments