Skip to content

Commit 384d422

Browse files
author
Kartik Raj
committed
Fix venv tests
1 parent ece6a1c commit 384d422

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ jobs:
282282
shell: pwsh
283283
if: matrix.test-suite == 'venv'
284284
run: |
285-
# 1. For `terminalActivation.testvirtualenvs.test.ts`
285+
# 1. For `*.testvirtualenvs.test.ts`
286286
if ('${{ matrix.os }}' -match 'windows-latest') {
287287
$condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python.exe
288288
$condaExecPath = Join-Path -Path $Env:CONDA -ChildPath Scripts | Join-Path -ChildPath conda

.github/workflows/pr-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ jobs:
255255
shell: pwsh
256256
if: matrix.test-suite == 'venv'
257257
run: |
258-
# 1. For `terminalActivation.testvirtualenvs.test.ts`
258+
# 1. For `*.testvirtualenvs.test.ts`
259259
if ('${{ matrix.os }}' -match 'windows-latest') {
260260
$condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python.exe
261261
$condaExecPath = Join-Path -Path $Env:CONDA -ChildPath Scripts | Join-Path -ChildPath conda
@@ -451,7 +451,7 @@ jobs:
451451
PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json'
452452
shell: pwsh
453453
run: |
454-
# 1. For `terminalActivation.testvirtualenvs.test.ts`
454+
# 1. For `*.testvirtualenvs.test.ts`
455455
if ('${{ matrix.os }}' -match 'windows-latest') {
456456
$condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python.exe
457457
$condaExecPath = Join-Path -Path $Env:CONDA -ChildPath Scripts | Join-Path -ChildPath conda

src/client/common/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ export namespace ThemeIcons {
9494

9595
export const DEFAULT_INTERPRETER_SETTING = 'python';
9696

97-
export const isCI = process.env.TRAVIS === 'true' || process.env.TF_BUILD !== undefined;
97+
export const isCI =
98+
process.env.TRAVIS === 'true' || process.env.TF_BUILD !== undefined || process.env.GITHUB_ACTIONS === 'true';
9899

99100
export function isTestExecution(): boolean {
100101
return process.env.VSC_PYTHON_CI_TEST === '1' || isUnitTestExecution();

src/test/pythonEnvironments/base/locators/lowLevel/condaLocator.testvirtualenvs.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
// Copyright (c) Microsoft Corporation. All rights reserved.
23
// Licensed under the MIT License.
34

@@ -10,11 +11,14 @@ import { CondaEnvironmentLocator } from '../../../../../client/pythonEnvironment
1011
import { sleep } from '../../../../core';
1112
import { createDeferred, Deferred } from '../../../../../client/common/utils/async';
1213
import { PythonEnvsChangedEvent } from '../../../../../client/pythonEnvironments/base/watcher';
13-
import { TEST_TIMEOUT } from '../../../../constants';
14+
import { EXTENSION_ROOT_DIR_FOR_TESTS, TEST_TIMEOUT } from '../../../../constants';
1415
import { traceWarn } from '../../../../../client/logging';
1516
import { TEST_LAYOUT_ROOT } from '../../../common/commonTestConstants';
1617
import { getEnvs } from '../../common';
1718
import { assertBasicEnvsEqual } from '../envTestUtils';
19+
import { PYTHON_VIRTUAL_ENVS_LOCATION } from '../../../../ciConstants';
20+
import { isCI } from '../../../../../client/common/constants';
21+
import * as externalDependencies from '../../../../../client/pythonEnvironments/common/externalDependencies';
1822

1923
class CondaEnvs {
2024
private readonly condaEnvironmentsTxt;
@@ -55,6 +59,10 @@ class CondaEnvs {
5559
suite('Conda Env Locator', async () => {
5660
let locator: CondaEnvironmentLocator;
5761
let condaEnvsTxt: CondaEnvs;
62+
const envsLocation =
63+
PYTHON_VIRTUAL_ENVS_LOCATION !== undefined
64+
? path.join(EXTENSION_ROOT_DIR_FOR_TESTS, PYTHON_VIRTUAL_ENVS_LOCATION)
65+
: path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json');
5866

5967
async function waitForChangeToBeDetected(deferred: Deferred<void>) {
6068
const timeout = setTimeout(() => {
@@ -63,11 +71,23 @@ suite('Conda Env Locator', async () => {
6371
}, TEST_TIMEOUT);
6472
await deferred.promise;
6573
}
74+
let envPaths: any;
75+
76+
suiteSetup(async () => {
77+
if (isCI) {
78+
envPaths = await fs.readJson(envsLocation);
79+
}
80+
});
6681

6782
setup(async () => {
6883
sinon.stub(platformUtils, 'getUserHomeDir').returns(TEST_LAYOUT_ROOT);
6984
condaEnvsTxt = new CondaEnvs();
7085
await condaEnvsTxt.cleanUp();
86+
if (isCI) {
87+
console.log('I am in CI');
88+
console.log(JSON.stringify(envPaths));
89+
sinon.stub(externalDependencies, 'getPythonSetting').returns(envPaths.condaExecPath);
90+
}
7191
});
7292

7393
async function setupLocator(onChanged: (e: PythonEnvsChangedEvent) => Promise<void>) {

0 commit comments

Comments
 (0)