From 5ad3919016365e891be75e0587cc7aa366be7af3 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 7 Nov 2022 01:20:21 -0800 Subject: [PATCH 1/4] Add test to get active interpreter --- src/test/common.ts | 3 ++- src/test/proposedApi.test.ts | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/test/proposedApi.test.ts diff --git a/src/test/common.ts b/src/test/common.ts index e58830b7f236..0a76c495830a 100644 --- a/src/test/common.ts +++ b/src/test/common.ts @@ -14,6 +14,7 @@ import type { IExtensionApi } from '../client/apiTypes'; import { IProcessService } from '../client/common/process/types'; import { IDisposable } from '../client/common/types'; import { IServiceContainer, IServiceManager } from '../client/ioc/types'; +import { ProposedExtensionAPI } from '../client/proposedApiTypes'; import { EXTENSION_ROOT_DIR_FOR_TESTS, IS_MULTI_ROOT_TEST, IS_PERF_TEST, IS_SMOKE_TEST } from './constants'; import { noop, sleep } from './core'; @@ -437,7 +438,7 @@ export async function isPythonVersion(...versions: string[]): Promise { } } -export interface IExtensionTestApi extends IExtensionApi { +export interface IExtensionTestApi extends IExtensionApi, ProposedExtensionAPI { serviceContainer: IServiceContainer; serviceManager: IServiceManager; } diff --git a/src/test/proposedApi.test.ts b/src/test/proposedApi.test.ts new file mode 100644 index 000000000000..fb473566c93b --- /dev/null +++ b/src/test/proposedApi.test.ts @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { expect } from 'chai'; +import { IExtensionApi } from '../client/apiTypes'; +import { ProposedExtensionAPI } from '../client/proposedApiTypes'; +import { initialize } from './initialize'; + +suite('Python API tests', () => { + let api: IExtensionApi & ProposedExtensionAPI; + suiteSetup(async () => { + api = await initialize(); + }); + test('Active environment is defined', async () => { + const environmentPath = api.environments.getActiveEnvironmentPath(); + const environment = await api.environments.resolveEnvironment(environmentPath); + console.log('Log active environment', JSON.stringify(environment)); + expect(environment).to.not.equal(undefined, 'Active environment is not defined'); + }); +}); From 4edc1a7c1e1ec6af3e16bad4140c8581f741d3f8 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 7 Nov 2022 01:49:05 -0800 Subject: [PATCH 2/4] Only run desired test --- .github/workflows/pr-check.yml | 7 ++++--- src/test/{proposedApi.test.ts => api.test.ts} | 0 2 files changed, 4 insertions(+), 3 deletions(-) rename src/test/{proposedApi.test.ts => api.test.ts} (100%) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index e654cdc36f97..7b0d1a83bc41 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -15,6 +15,7 @@ env: VSIX_NAME: ms-python-insiders.vsix TEST_RESULTS_DIRECTORY: . DISABLE_TRANSLATIONS: true + VSC_PYTHON_CI_TEST_GREP: 'Python API tests' # Force a path with spaces and to test extension works in these scenarios # Unicode characters are causing 2.7 failures so skip that for now. special-working-directory: './path with spaces' @@ -93,10 +94,10 @@ jobs: matrix: # We're not running CI on macOS for now because it's one less matrix entry to lower the number of runners used, # macOS runners are expensive, and we assume that Ubuntu is enough to cover the Unix case. - os: [ubuntu-latest, windows-latest] + os: [windows-latest] # Run the tests on the oldest and most recent versions of Python. - python: ['3.x'] - test-suite: [ts-unit, python-unit, venv, single-workspace, debugger, functional] + python: ['3.10'] + test-suite: [single-workspace] steps: - name: Checkout diff --git a/src/test/proposedApi.test.ts b/src/test/api.test.ts similarity index 100% rename from src/test/proposedApi.test.ts rename to src/test/api.test.ts From 9f7adb5fb25602a31d6a650dd7b0a237265e75cb Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 7 Nov 2022 02:04:41 -0800 Subject: [PATCH 3/4] Log approrp --- src/test/api.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/api.test.ts b/src/test/api.test.ts index fb473566c93b..24eb78c11bf0 100644 --- a/src/test/api.test.ts +++ b/src/test/api.test.ts @@ -14,7 +14,11 @@ suite('Python API tests', () => { test('Active environment is defined', async () => { const environmentPath = api.environments.getActiveEnvironmentPath(); const environment = await api.environments.resolveEnvironment(environmentPath); - console.log('Log active environment', JSON.stringify(environment)); - expect(environment).to.not.equal(undefined, 'Active environment is not defined'); + expect(environment).to.not.equal( + undefined, + `Active environment is not defined, envPath: ${JSON.stringify(environmentPath)}, env: ${JSON.stringify( + environment, + )}`, + ); }); }); From 5ee210c5273598211db965beafe9e29a773d0f24 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 7 Nov 2022 02:06:30 -0800 Subject: [PATCH 4/4] Run all tests --- .github/workflows/pr-check.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 7b0d1a83bc41..e654cdc36f97 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -15,7 +15,6 @@ env: VSIX_NAME: ms-python-insiders.vsix TEST_RESULTS_DIRECTORY: . DISABLE_TRANSLATIONS: true - VSC_PYTHON_CI_TEST_GREP: 'Python API tests' # Force a path with spaces and to test extension works in these scenarios # Unicode characters are causing 2.7 failures so skip that for now. special-working-directory: './path with spaces' @@ -94,10 +93,10 @@ jobs: matrix: # We're not running CI on macOS for now because it's one less matrix entry to lower the number of runners used, # macOS runners are expensive, and we assume that Ubuntu is enough to cover the Unix case. - os: [windows-latest] + os: [ubuntu-latest, windows-latest] # Run the tests on the oldest and most recent versions of Python. - python: ['3.10'] - test-suite: [single-workspace] + python: ['3.x'] + test-suite: [ts-unit, python-unit, venv, single-workspace, debugger, functional] steps: - name: Checkout