Skip to content

Commit bdaf6d6

Browse files
authored
chore(vscode): separate out building of settings for test (#4919)
1 parent 170a1d0 commit bdaf6d6

16 files changed

+111
-52
lines changed

vscode/extension/tests/broken_project.spec.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import fs from 'fs-extra'
33
import os from 'os'
44
import path from 'path'
55
import { openLineageView, saveFile, SUSHI_SOURCE_PATH } from './utils'
6-
import { startCodeServer, stopCodeServer } from './utils_code_server'
6+
import {
7+
createPythonInterpreterSettingsSpecifier,
8+
startCodeServer,
9+
stopCodeServer,
10+
} from './utils_code_server'
711

812
test('bad project, double model', async ({ page }) => {
913
const tempDir = await fs.mkdtemp(
@@ -25,8 +29,8 @@ test('bad project, double model', async ({ page }) => {
2529

2630
const context = await startCodeServer({
2731
tempDir,
28-
placeFileWithPythonInterpreter: true,
2932
})
33+
await createPythonInterpreterSettingsSpecifier(tempDir)
3034
try {
3135
await page.goto(`http://127.0.0.1:${context.codeServerPort}`)
3236

@@ -60,8 +64,8 @@ test('working project, then broken through adding double model, then refixed', a
6064

6165
const context = await startCodeServer({
6266
tempDir,
63-
placeFileWithPythonInterpreter: true,
6467
})
68+
await createPythonInterpreterSettingsSpecifier(tempDir)
6569
try {
6670
await page.goto(`http://127.0.0.1:${context.codeServerPort}`)
6771
await page.waitForLoadState('networkidle')
@@ -173,8 +177,8 @@ test('bad project, double model, then fixed', async ({ page }) => {
173177

174178
const context = await startCodeServer({
175179
tempDir,
176-
placeFileWithPythonInterpreter: true,
177180
})
181+
await createPythonInterpreterSettingsSpecifier(tempDir)
178182
try {
179183
await page.goto(`http://127.0.0.1:${context.codeServerPort}`)
180184

@@ -246,8 +250,8 @@ test('bad project, double model, check lineage', async ({ page }) => {
246250

247251
const context = await startCodeServer({
248252
tempDir,
249-
placeFileWithPythonInterpreter: true,
250253
})
254+
await createPythonInterpreterSettingsSpecifier(tempDir)
251255
try {
252256
await page.goto(`http://127.0.0.1:${context.codeServerPort}`)
253257
await page.waitForLoadState('networkidle')

vscode/extension/tests/completions.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ import path from 'path'
33
import fs from 'fs-extra'
44
import os from 'os'
55
import { SUSHI_SOURCE_PATH } from './utils'
6-
import { startCodeServer, stopCodeServer } from './utils_code_server'
6+
import {
7+
createPythonInterpreterSettingsSpecifier,
8+
startCodeServer,
9+
stopCodeServer,
10+
} from './utils_code_server'
711

812
test('Autocomplete for model names', async ({ page }) => {
913
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'vscode-test-sushi-'))
1014
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
1115

1216
const context = await startCodeServer({
1317
tempDir,
14-
placeFileWithPythonInterpreter: true,
1518
})
19+
await createPythonInterpreterSettingsSpecifier(tempDir)
1620

1721
try {
1822
await page.goto(`http://127.0.0.1:${context.codeServerPort}`)
@@ -74,8 +78,8 @@ test.describe('Macro Completions', () => {
7478

7579
const context = await startCodeServer({
7680
tempDir,
77-
placeFileWithPythonInterpreter: true,
7881
})
82+
await createPythonInterpreterSettingsSpecifier(tempDir)
7983

8084
try {
8185
await page.goto(`http://127.0.0.1:${context.codeServerPort}`)
@@ -132,8 +136,8 @@ test.describe('Macro Completions', () => {
132136

133137
const context = await startCodeServer({
134138
tempDir,
135-
placeFileWithPythonInterpreter: true,
136139
})
140+
await createPythonInterpreterSettingsSpecifier(tempDir)
137141

138142
try {
139143
await page.goto(`http://127.0.0.1:${context.codeServerPort}`)

vscode/extension/tests/diagnostics.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import path from 'path'
33
import fs from 'fs-extra'
44
import os from 'os'
55
import { runCommand, SUSHI_SOURCE_PATH } from './utils'
6-
import { startCodeServer, stopCodeServer } from './utils_code_server'
6+
import {
7+
createPythonInterpreterSettingsSpecifier,
8+
startCodeServer,
9+
stopCodeServer,
10+
} from './utils_code_server'
711

812
test('Workspace diagnostics show up in the diagnostics panel', async ({
913
page,
@@ -13,8 +17,8 @@ test('Workspace diagnostics show up in the diagnostics panel', async ({
1317

1418
const context = await startCodeServer({
1519
tempDir,
16-
placeFileWithPythonInterpreter: true,
1720
})
21+
await createPythonInterpreterSettingsSpecifier(tempDir)
1822

1923
const configPath = path.join(tempDir, 'config.py')
2024
const configContent = await fs.readFile(configPath, 'utf8')

vscode/extension/tests/find_references.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
startCodeServer,
88
stopCodeServer,
99
CodeServerContext,
10+
createPythonInterpreterSettingsSpecifier,
1011
} from './utils_code_server'
1112

1213
// Helper function to set up a test environment for model references
@@ -15,8 +16,8 @@ async function setupModelTestEnvironment(): Promise<CodeServerContext> {
1516
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
1617
const context = await startCodeServer({
1718
tempDir,
18-
placeFileWithPythonInterpreter: true,
1919
})
20+
await createPythonInterpreterSettingsSpecifier(tempDir)
2021
return context
2122
}
2223

vscode/extension/tests/format.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ import path from 'path'
33
import fs from 'fs-extra'
44
import os from 'os'
55
import { runCommand, SUSHI_SOURCE_PATH } from './utils'
6-
import { startCodeServer, stopCodeServer } from './utils_code_server'
6+
import {
7+
createPythonInterpreterSettingsSpecifier,
8+
startCodeServer,
9+
stopCodeServer,
10+
} from './utils_code_server'
711

812
test('Format project works correctly', async ({ page }) => {
913
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'vscode-test-sushi-'))
1014
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
1115

1216
const context = await startCodeServer({
1317
tempDir,
14-
placeFileWithPythonInterpreter: true,
1518
})
19+
await createPythonInterpreterSettingsSpecifier(tempDir)
1620

1721
try {
1822
await page.goto(`http://127.0.0.1:${context.codeServerPort}`)

vscode/extension/tests/go_to_definition.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ import path from 'path'
33
import fs from 'fs-extra'
44
import os from 'os'
55
import { goToDefinition, SUSHI_SOURCE_PATH } from './utils'
6-
import { startCodeServer, stopCodeServer } from './utils_code_server'
6+
import {
7+
createPythonInterpreterSettingsSpecifier,
8+
startCodeServer,
9+
stopCodeServer,
10+
} from './utils_code_server'
711

812
test('Stop server works', async ({ page }) => {
913
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'vscode-test-sushi-'))
1014
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
1115

1216
const context = await startCodeServer({
1317
tempDir,
14-
placeFileWithPythonInterpreter: true,
1518
})
19+
await createPythonInterpreterSettingsSpecifier(tempDir)
1620

1721
try {
1822
// Navigate to code-server instance
@@ -53,8 +57,8 @@ test('Go to definition for model', async ({ page }) => {
5357

5458
const context = await startCodeServer({
5559
tempDir,
56-
placeFileWithPythonInterpreter: true,
5760
})
61+
await createPythonInterpreterSettingsSpecifier(tempDir)
5862

5963
try {
6064
// Navigate to code-server instance

vscode/extension/tests/hints.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ import path from 'path'
33
import fs from 'fs-extra'
44
import os from 'os'
55
import { SUSHI_SOURCE_PATH } from './utils'
6-
import { startCodeServer, stopCodeServer } from './utils_code_server'
6+
import {
7+
createPythonInterpreterSettingsSpecifier,
8+
startCodeServer,
9+
stopCodeServer,
10+
} from './utils_code_server'
711

812
test('Model type hinting', async ({ page }) => {
913
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'vscode-test-sushi-'))
1014
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
1115

1216
const context = await startCodeServer({
1317
tempDir,
14-
placeFileWithPythonInterpreter: true,
1518
})
19+
await createPythonInterpreterSettingsSpecifier(tempDir)
1620

1721
try {
1822
// Navigate to code-server instance

vscode/extension/tests/lineage.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import fs from 'fs-extra'
44
import os from 'os'
55
import { openLineageView, SUSHI_SOURCE_PATH } from './utils'
66
import { writeFileSync } from 'fs'
7-
import { startCodeServer, stopCodeServer } from './utils_code_server'
7+
import {
8+
createPythonInterpreterSettingsSpecifier,
9+
startCodeServer,
10+
stopCodeServer,
11+
} from './utils_code_server'
812

913
/**
1014
* Helper function to launch VS Code and test lineage with given project path config
@@ -24,8 +28,8 @@ test('Lineage panel renders correctly - no project path config (default)', async
2428

2529
const context = await startCodeServer({
2630
tempDir,
27-
placeFileWithPythonInterpreter: true,
2831
})
32+
await createPythonInterpreterSettingsSpecifier(tempDir)
2933

3034
try {
3135
await page.goto(`http://127.0.0.1:${context.codeServerPort}`)
@@ -146,8 +150,8 @@ test('Lineage panel renders correctly - absolute path project outside of workspa
146150
await fs.ensureDir(workspaceDir)
147151
const context = await startCodeServer({
148152
tempDir: workspaceDir,
149-
placeFileWithPythonInterpreter: false,
150153
})
154+
await createPythonInterpreterSettingsSpecifier(workspaceDir)
151155

152156
const settings = {
153157
'sqlmesh.projectPath': projectDir,
@@ -203,8 +207,8 @@ test.skip('Lineage panel renders correctly - multiworkspace setup', async ({
203207

204208
const context = await startCodeServer({
205209
tempDir: workspaceDir,
206-
placeFileWithPythonInterpreter: true,
207210
})
211+
await createPythonInterpreterSettingsSpecifier(workspaceDir)
208212

209213
const settings = {
210214
'python.defaultInterpreterPath': context.defaultPythonInterpreter,

vscode/extension/tests/lineage_settings.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ import path from 'path'
33
import fs from 'fs-extra'
44
import os from 'os'
55
import { openLineageView, SUSHI_SOURCE_PATH } from './utils'
6-
import { startCodeServer, stopCodeServer } from './utils_code_server'
6+
import {
7+
createPythonInterpreterSettingsSpecifier,
8+
startCodeServer,
9+
stopCodeServer,
10+
} from './utils_code_server'
711

812
test('Settings button is visible in the lineage view', async ({ page }) => {
913
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'vscode-test-sushi-'))
1014
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
1115

1216
const context = await startCodeServer({
1317
tempDir,
14-
placeFileWithPythonInterpreter: true,
1518
})
19+
await createPythonInterpreterSettingsSpecifier(tempDir)
1620

1721
try {
1822
await page.goto(`http://127.0.0.1:${context.codeServerPort}`)

vscode/extension/tests/python_env.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ if test_var is None or test_var == "":
3535

3636
async function runTest(page: Page, context: CodeServerContext): Promise<void> {
3737
await page.goto(`http://127.0.0.1:${context.codeServerPort}`)
38+
await page.waitForSelector('text=models')
3839
await openLineageView(page)
3940
}
4041

0 commit comments

Comments
 (0)