From c1ba5cb62e2d69edc0ccf06e2dd262f05c960e21 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 5 Dec 2018 13:39:08 -0800 Subject: [PATCH 01/33] Added template for virtual environment tests --- build/ci/templates/virtual_env_tests.yml | 152 ++++++++++++++++++++++ build/ci/vscode-python-pr-validation.yaml | 15 +++ 2 files changed, 167 insertions(+) create mode 100644 build/ci/templates/virtual_env_tests.yml diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml new file mode 100644 index 000000000000..8113843ee29c --- /dev/null +++ b/build/ci/templates/virtual_env_tests.yml @@ -0,0 +1,152 @@ +parameters: + name: 'Unit_Test_Run' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + PoolName: 'Hosted Ubuntu 1604' + MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' + MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' + MOCHA_REPORTER_JUNIT: true + RunHygiene: true + UploadBinary: false + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' + EnvironmentExecutableFolder: 'bin' + +jobs: +- job: ${{ parameters.name }} + pool: + name: ${{ parameters.PoolName }} + + variables: + # TODO: use {{ insert }}: {{ parameters.variables }}, it would not work at time I wrote this + nodeVersion: ${{ parameters.NodeVersion }} + npmVersion: ${{ parameters.NpmVersion }} + pythonVersion: ${{ parameters.PythonVersion }} + mochaReportFile: ${{ parameters.MOCHA_CI_REPORTFILE }} + MOCHA_CI_REPORTER_ID: ${{ parameters.MOCHA_CI_REPORTER_ID }} + MOCHA_CI_REPORTFILE: ${{ parameters.MOCHA_CI_REPORTFILE }} + MOCHA_REPORTER_JUNIT: ${{ parameters.MOCHA_REPORTER_JUNIT }} + runHygiene: ${{ parameters.RunHygiene }} + uploadBinary: ${{ parameters.UploadBinary }} + azureStorageAcctName: ${{ parameters.AzureStorageAccountName }} + azureStorageContainerName: ${{ parameters.AzureStorageContainerName }} + plaform: ${{ parameters.Platform }} + environmentExecutableFolder: ${{ parameters.EnvironmentExecutableFolder }} + + steps: + - bash: echo REQUESTED VARIABLE VALUES + + echo Node Version = $(nodeVersion) + + echo Python Version = $(pythonVersion) + + echo NPM Version = $(npmVersion) + + echo Mocha reportfile = '$(mochaReportFile)' + + echo MOCHA_CI_REPORTFILE = $MOCHA_CI_REPORTFILE + + echo MOCHA_CI_REPORTER_ID = $MOCHA_CI_REPORTER_ID + + echo MOCHA_REPORTER_JUNIT = $MOCHA_REPORTER_JUNIT + + echo COV_UUID = $COV_UUID + + echo Run Hygiene = $(runHygiene) + + displayName: 'Show build vars' + name: 'show_bld_vars' + + + - powershell: | + New-Item -ItemType directory -Path "$(System.ArtifactsDirectory)/bin-artifacts" + + $buildArtifactUri = "https://$(AzureStorageAccountName).blob.core.windows.net/$(AzureStorageContainerName)/$(Build.BuildNumber)/bin-artifacts.zip" + Write-Verbose "Downloading from $buildArtifactUri" + + $destination = "$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip" + Write-Verbose "Destination file: $destination" + + Invoke-WebRequest -Uri $buildArtifactUri -OutFile $destination -Verbose + + displayName: 'Download bin-artifacts from cloud-storage' + + + - task: ExtractFiles@1 + displayName: 'Splat bin-artifacts' + inputs: + archiveFilePatterns: '$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip' + + destinationFolder: '$(Build.SourcesDirectory)' + + cleanDestinationFolder: false + + + - bash: | + echo "#Adds the virtual environment's executable path to json file + + import json,sys + import os.path + key = sys.argv[1] + + if os.path.isfile('./envPaths.json'): + with open('envPaths.json', 'r') as read_file: + data = json.load(read_file) + else: + with open('envPaths.json', 'w+') as read_file: + data = {} + with open('envPaths.json', 'w') as outfile: + data[key] = sys.executable + json.dump(data, outfile, sort_keys=True, indent=4)" > addEnvPath.py + + displayName: 'Create Environment paths adder' + + + - bash: | + pip install pipenv + + pipenv run python addEnvPath.py pipenv + + cat envPaths.json + + displayName: 'Create pipenv environment' + + + - bash: | + python -m venv .venv + + .venv/$(environmentExecutableFolder)/python addEnvPath.py venv + + cat envPaths.json + + displayName: 'Create venv environment' + + + - bash: | + pip install virtualenv + + python -m virtualenv .virtualenv + + .virtualenv/$(environmentExecutableFolder)/python addEnvPath.py virtualenv + + cat envPaths.json + + displayName: 'Create virtualenv environment' + + + - task: CondaEnvironment@1 + displayName: 'Create conda environment ' + inputs: + packageSpecs: 'python=3.7' + + + - bash: | + python addEnvPath.py conda + + source deactivate + + cat envPaths.json + + displayName: 'Save conda environment executable' + diff --git a/build/ci/vscode-python-pr-validation.yaml b/build/ci/vscode-python-pr-validation.yaml index 0710ff576e37..f4769a0cf7c7 100644 --- a/build/ci/vscode-python-pr-validation.yaml +++ b/build/ci/vscode-python-pr-validation.yaml @@ -16,6 +16,21 @@ jobs: AzureStorageAccountName: 'vscodepythonci' AzureStorageContainerName: 'vscode-python-ci' + +- template: templates/virtual_env_tests.yml + parameters: + name: 'VirtualEnv_Tests_Windows_py37' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + PoolName: 'Hosted VS2017' + UploadBinary: true + Platform: 'Windows' + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' + VirtualExecutableFolder: 'Scripts' + + - job: 'System_Test_macOS' dependsOn: 'PR_Validate_Windows_py37' pool: From 329b90b5edf90dc6bb09ff27cac0a8ba0c6752ef Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 5 Dec 2018 15:24:51 -0800 Subject: [PATCH 02/33] Updated virtual_env_tests.yml --- build/ci/templates/virtual_env_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 8113843ee29c..22f0ba8c9409 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -62,7 +62,7 @@ jobs: - powershell: | New-Item -ItemType directory -Path "$(System.ArtifactsDirectory)/bin-artifacts" - $buildArtifactUri = "https://$(AzureStorageAccountName).blob.core.windows.net/$(AzureStorageContainerName)/$(Build.BuildNumber)/bin-artifacts.zip" + $buildArtifactUri = "https://$(azureStorageAcctName).blob.core.windows.net/$(azureStorageContainerName)/$(Build.BuildNumber)/bin-artifacts.zip" Write-Verbose "Downloading from $buildArtifactUri" $destination = "$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip" From c6706963ebf6e77312a3d897498946f5b72792b8 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 5 Dec 2018 17:13:50 -0800 Subject: [PATCH 03/33] Temporarily Removed downloading task --- build/ci/templates/virtual_env_tests.yml | 52 ++++++++++++++---------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 22f0ba8c9409..34bdfaf33d0a 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -12,6 +12,7 @@ parameters: AzureStorageAccountName: 'vscodepythonci' AzureStorageContainerName: 'vscode-python-ci' EnvironmentExecutableFolder: 'bin' + DIRECTORY_FOR_VIRTUAL_ENVS: './envPaths.json' jobs: - job: ${{ parameters.name }} @@ -33,6 +34,7 @@ jobs: azureStorageContainerName: ${{ parameters.AzureStorageContainerName }} plaform: ${{ parameters.Platform }} environmentExecutableFolder: ${{ parameters.EnvironmentExecutableFolder }} + DIRECTORY_FOR_VIRTUAL_ENVS: ${{ parameters.DIRECTORY_FOR_VIRTUAL_ENVS }} steps: - bash: echo REQUESTED VARIABLE VALUES @@ -59,28 +61,34 @@ jobs: name: 'show_bld_vars' - - powershell: | - New-Item -ItemType directory -Path "$(System.ArtifactsDirectory)/bin-artifacts" + # - powershell: | + # New-Item -ItemType directory -Path "$(System.ArtifactsDirectory)/bin-artifacts" - $buildArtifactUri = "https://$(azureStorageAcctName).blob.core.windows.net/$(azureStorageContainerName)/$(Build.BuildNumber)/bin-artifacts.zip" - Write-Verbose "Downloading from $buildArtifactUri" + # $buildArtifactUri = "https://$(azureStorageAcctName).blob.core.windows.net/$(azureStorageContainerName)/$(Build.BuildNumber)/bin-artifacts.zip" + # Write-Verbose "Downloading from $buildArtifactUri" - $destination = "$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip" - Write-Verbose "Destination file: $destination" + # $destination = "$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip" + # Write-Verbose "Destination file: $destination" - Invoke-WebRequest -Uri $buildArtifactUri -OutFile $destination -Verbose + # Invoke-WebRequest -Uri $buildArtifactUri -OutFile $destination -Verbose - displayName: 'Download bin-artifacts from cloud-storage' + # displayName: 'Download bin-artifacts from cloud-storage' - - task: ExtractFiles@1 - displayName: 'Splat bin-artifacts' - inputs: - archiveFilePatterns: '$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip' + # - task: ExtractFiles@1 + # displayName: 'Splat bin-artifacts' + # inputs: + # archiveFilePatterns: '$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip' + + # destinationFolder: '$(Build.SourcesDirectory)' - destinationFolder: '$(Build.SourcesDirectory)' + # cleanDestinationFolder: false - cleanDestinationFolder: false + + - task: UsePythonVersion@0 + displayName: 'Use Python 3.7' + inputs: + versionSpec: 3.7 - bash: | @@ -90,13 +98,13 @@ jobs: import os.path key = sys.argv[1] - if os.path.isfile('./envPaths.json'): - with open('envPaths.json', 'r') as read_file: + if os.path.isfile('$(DIRECTORY_FOR_VIRTUAL_ENVS)'): + with open('$(DIRECTORY_FOR_VIRTUAL_ENVS)', 'r') as read_file: data = json.load(read_file) else: - with open('envPaths.json', 'w+') as read_file: + with open('$(DIRECTORY_FOR_VIRTUAL_ENVS)', 'w+') as read_file: data = {} - with open('envPaths.json', 'w') as outfile: + with open('$(DIRECTORY_FOR_VIRTUAL_ENVS)', 'w') as outfile: data[key] = sys.executable json.dump(data, outfile, sort_keys=True, indent=4)" > addEnvPath.py @@ -108,7 +116,7 @@ jobs: pipenv run python addEnvPath.py pipenv - cat envPaths.json + cat $(DIRECTORY_FOR_VIRTUAL_ENVS) displayName: 'Create pipenv environment' @@ -118,7 +126,7 @@ jobs: .venv/$(environmentExecutableFolder)/python addEnvPath.py venv - cat envPaths.json + cat $(DIRECTORY_FOR_VIRTUAL_ENVS) displayName: 'Create venv environment' @@ -130,7 +138,7 @@ jobs: .virtualenv/$(environmentExecutableFolder)/python addEnvPath.py virtualenv - cat envPaths.json + cat $(DIRECTORY_FOR_VIRTUAL_ENVS) displayName: 'Create virtualenv environment' @@ -146,7 +154,7 @@ jobs: source deactivate - cat envPaths.json + cat $(DIRECTORY_FOR_VIRTUAL_ENVS) displayName: 'Save conda environment executable' From e4d17c8b26d22e64fb078fc3eec2bd0a92e25709 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 5 Dec 2018 17:27:09 -0800 Subject: [PATCH 04/33] Correct Executable Folder --- build/ci/templates/virtual_env_tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 34bdfaf33d0a..4e32599040fa 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -1,9 +1,9 @@ parameters: - name: 'Unit_Test_Run' + name: 'VirtualEnv_Tests_Windows_py37' PythonVersion: '3.7' NodeVersion: '8.11.2' NpmVersion: 'latest' - PoolName: 'Hosted Ubuntu 1604' + PoolName: 'Hosted VS2017' MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' MOCHA_REPORTER_JUNIT: true @@ -11,7 +11,7 @@ parameters: UploadBinary: false AzureStorageAccountName: 'vscodepythonci' AzureStorageContainerName: 'vscode-python-ci' - EnvironmentExecutableFolder: 'bin' + EnvironmentExecutableFolder: 'Scripts' DIRECTORY_FOR_VIRTUAL_ENVS: './envPaths.json' jobs: From 1aa6c54b8f3896d363bce5fed890f80f83ba0b46 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 6 Dec 2018 10:44:46 -0800 Subject: [PATCH 05/33] Added dependencies --- build/ci/templates/virtual_env_tests.yml | 29 ++++++++++++----------- build/ci/vscode-python-pr-validation.yaml | 3 ++- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 4e32599040fa..22b4bc91ca79 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -16,6 +16,7 @@ parameters: jobs: - job: ${{ parameters.name }} + dependsOn: 'PR_Validate_Windows_py37' pool: name: ${{ parameters.PoolName }} @@ -61,28 +62,28 @@ jobs: name: 'show_bld_vars' - # - powershell: | - # New-Item -ItemType directory -Path "$(System.ArtifactsDirectory)/bin-artifacts" + - powershell: | + New-Item -ItemType directory -Path "$(System.ArtifactsDirectory)/bin-artifacts" - # $buildArtifactUri = "https://$(azureStorageAcctName).blob.core.windows.net/$(azureStorageContainerName)/$(Build.BuildNumber)/bin-artifacts.zip" - # Write-Verbose "Downloading from $buildArtifactUri" + $buildArtifactUri = "https://$(azureStorageAcctName).blob.core.windows.net/$(azureStorageContainerName)/$(Build.BuildNumber)/bin-artifacts.zip" + Write-Verbose "Downloading from $buildArtifactUri" - # $destination = "$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip" - # Write-Verbose "Destination file: $destination" + $destination = "$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip" + Write-Verbose "Destination file: $destination" - # Invoke-WebRequest -Uri $buildArtifactUri -OutFile $destination -Verbose + Invoke-WebRequest -Uri $buildArtifactUri -OutFile $destination -Verbose - # displayName: 'Download bin-artifacts from cloud-storage' + displayName: 'Download bin-artifacts from cloud-storage' - # - task: ExtractFiles@1 - # displayName: 'Splat bin-artifacts' - # inputs: - # archiveFilePatterns: '$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip' + - task: ExtractFiles@1 + displayName: 'Splat bin-artifacts' + inputs: + archiveFilePatterns: '$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip' - # destinationFolder: '$(Build.SourcesDirectory)' + destinationFolder: '$(Build.SourcesDirectory)' - # cleanDestinationFolder: false + cleanDestinationFolder: false - task: UsePythonVersion@0 diff --git a/build/ci/vscode-python-pr-validation.yaml b/build/ci/vscode-python-pr-validation.yaml index f4769a0cf7c7..e8dfefb30aae 100644 --- a/build/ci/vscode-python-pr-validation.yaml +++ b/build/ci/vscode-python-pr-validation.yaml @@ -28,7 +28,8 @@ jobs: Platform: 'Windows' AzureStorageAccountName: 'vscodepythonci' AzureStorageContainerName: 'vscode-python-ci' - VirtualExecutableFolder: 'Scripts' + EnvironmentExecutableFolder: 'Scripts' + DIRECTORY_FOR_VIRTUAL_ENVS: './envPaths.json' - job: 'System_Test_macOS' From cef1777a118a789ab3f52da8205c51bafe9b1f01 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 7 Dec 2018 13:53:09 -0800 Subject: [PATCH 06/33] Added system tests to check activation for virtual environments --- build/ci/addEnvPath.py | 15 +++ build/ci/templates/virtual_env_tests.yml | 102 +++++++++--------- build/ci/vscode-python-pr-validation.yaml | 8 +- src/test/ciConstants.ts | 2 +- src/test/common.ts | 7 +- .../terminalActivation.testvirtualenvs.ts | 75 +++++++++++++ src/tmp/envPaths.json | 6 ++ 7 files changed, 159 insertions(+), 56 deletions(-) create mode 100644 build/ci/addEnvPath.py create mode 100644 src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts create mode 100644 src/tmp/envPaths.json diff --git a/build/ci/addEnvPath.py b/build/ci/addEnvPath.py new file mode 100644 index 000000000000..c6246b4b6d41 --- /dev/null +++ b/build/ci/addEnvPath.py @@ -0,0 +1,15 @@ +#Adds the virtual environment's executable path to json file + +import json,sys +import os.path +key = sys.argv[1] + +if os.path.isfile('$(ENV_PATHS_LOCATION)'): + with open('$(ENV_PATHS_LOCATION)', 'r') as read_file: + data = json.load(read_file) +else: + with open('$(ENV_PATHS_LOCATION)', 'w+') as read_file: + data = {} +with open('$(ENV_PATHS_LOCATION)', 'w') as outfile: + data[key] = sys.executable + json.dump(data, outfile, sort_keys=True, indent=4) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 22b4bc91ca79..09a2a82b2745 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -1,18 +1,14 @@ parameters: name: 'VirtualEnv_Tests_Windows_py37' - PythonVersion: '3.7' NodeVersion: '8.11.2' NpmVersion: 'latest' - PoolName: 'Hosted VS2017' - MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' - MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' - MOCHA_REPORTER_JUNIT: true - RunHygiene: true - UploadBinary: false AzureStorageAccountName: 'vscodepythonci' AzureStorageContainerName: 'vscode-python-ci' + PoolName: 'Hosted VS2017' EnvironmentExecutableFolder: 'Scripts' - DIRECTORY_FOR_VIRTUAL_ENVS: './envPaths.json' + ENV_PATHS_LOCATION: './src/tmp/envPaths.json' + TEST_FILES_SUFFIX: 'testvirtualenvs' + TestSuiteName: 'testSingleWorkspace' jobs: - job: ${{ parameters.name }} @@ -25,17 +21,12 @@ jobs: nodeVersion: ${{ parameters.NodeVersion }} npmVersion: ${{ parameters.NpmVersion }} pythonVersion: ${{ parameters.PythonVersion }} - mochaReportFile: ${{ parameters.MOCHA_CI_REPORTFILE }} - MOCHA_CI_REPORTER_ID: ${{ parameters.MOCHA_CI_REPORTER_ID }} - MOCHA_CI_REPORTFILE: ${{ parameters.MOCHA_CI_REPORTFILE }} - MOCHA_REPORTER_JUNIT: ${{ parameters.MOCHA_REPORTER_JUNIT }} - runHygiene: ${{ parameters.RunHygiene }} - uploadBinary: ${{ parameters.UploadBinary }} azureStorageAcctName: ${{ parameters.AzureStorageAccountName }} azureStorageContainerName: ${{ parameters.AzureStorageContainerName }} - plaform: ${{ parameters.Platform }} environmentExecutableFolder: ${{ parameters.EnvironmentExecutableFolder }} - DIRECTORY_FOR_VIRTUAL_ENVS: ${{ parameters.DIRECTORY_FOR_VIRTUAL_ENVS }} + ENV_PATHS_LOCATION: ${{ parameters.ENV_PATHS_LOCATION }} + TEST_FILES_SUFFIX: ${{ parameters.TEST_FILES_SUFFIX }} + TestSuiteName: ${{ parameters.TestSuiteName }} steps: - bash: echo REQUESTED VARIABLE VALUES @@ -92,32 +83,12 @@ jobs: versionSpec: 3.7 - - bash: | - echo "#Adds the virtual environment's executable path to json file - - import json,sys - import os.path - key = sys.argv[1] - - if os.path.isfile('$(DIRECTORY_FOR_VIRTUAL_ENVS)'): - with open('$(DIRECTORY_FOR_VIRTUAL_ENVS)', 'r') as read_file: - data = json.load(read_file) - else: - with open('$(DIRECTORY_FOR_VIRTUAL_ENVS)', 'w+') as read_file: - data = {} - with open('$(DIRECTORY_FOR_VIRTUAL_ENVS)', 'w') as outfile: - data[key] = sys.executable - json.dump(data, outfile, sort_keys=True, indent=4)" > addEnvPath.py - - displayName: 'Create Environment paths adder' - - - bash: | pip install pipenv - pipenv run python addEnvPath.py pipenv + pipenv run python ./build/ci/addEnvPath.py pipenvPath - cat $(DIRECTORY_FOR_VIRTUAL_ENVS) + cat $(ENV_PATHS_LOCATION) displayName: 'Create pipenv environment' @@ -125,9 +96,9 @@ jobs: - bash: | python -m venv .venv - .venv/$(environmentExecutableFolder)/python addEnvPath.py venv + .venv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py venvPath - cat $(DIRECTORY_FOR_VIRTUAL_ENVS) + cat $(ENV_PATHS_LOCATION) displayName: 'Create venv environment' @@ -137,25 +108,56 @@ jobs: python -m virtualenv .virtualenv - .virtualenv/$(environmentExecutableFolder)/python addEnvPath.py virtualenv + .virtualenv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py virtualEnvPath - cat $(DIRECTORY_FOR_VIRTUAL_ENVS) + cat $(ENV_PATHS_LOCATION) displayName: 'Create virtualenv environment' - - task: CondaEnvironment@1 - displayName: 'Create conda environment ' + # - task: CondaEnvironment@1 + # displayName: 'Create conda environment ' + # inputs: + # packageSpecs: 'python=3.7' + + + # - bash: | + # python ./build/ci/addEnvPath.py conda + + # source deactivate + + # cat $(ENV_PATHS_LOCATION) + + # displayName: 'Save conda environment executable' + + + - task: Npm@1 + displayName: 'update npm' inputs: - packageSpecs: 'python=3.7' + command: custom + verbose: true - - bash: | - python addEnvPath.py conda + customCommand: 'install -g npm@$(NpmVersion)' + + + - task: Npm@1 + displayName: 'npm ci' + inputs: + command: custom + + verbose: true + + customCommand: ci + + + - task: Npm@1 + displayName: 'run $(TestSuiteName)' + inputs: + command: custom - source deactivate + verbose: true - cat $(DIRECTORY_FOR_VIRTUAL_ENVS) + customCommand: 'run $(TestSuiteName)' - displayName: 'Save conda environment executable' diff --git a/build/ci/vscode-python-pr-validation.yaml b/build/ci/vscode-python-pr-validation.yaml index e8dfefb30aae..b9f85fb01f0c 100644 --- a/build/ci/vscode-python-pr-validation.yaml +++ b/build/ci/vscode-python-pr-validation.yaml @@ -23,13 +23,13 @@ jobs: PythonVersion: '3.7' NodeVersion: '8.11.2' NpmVersion: 'latest' - PoolName: 'Hosted VS2017' - UploadBinary: true - Platform: 'Windows' AzureStorageAccountName: 'vscodepythonci' AzureStorageContainerName: 'vscode-python-ci' + PoolName: 'Hosted VS2017' EnvironmentExecutableFolder: 'Scripts' - DIRECTORY_FOR_VIRTUAL_ENVS: './envPaths.json' + ENV_PATHS_LOCATION: './src/tmp/envPaths.json' + TEST_FILES_SUFFIX: 'testvirtualenvs.ts' + TestSuiteName: 'testSingleWorkspace' - job: 'System_Test_macOS' diff --git a/src/test/ciConstants.ts b/src/test/ciConstants.ts index e1fc989e5fd8..ee797bea79f5 100644 --- a/src/test/ciConstants.ts +++ b/src/test/ciConstants.ts @@ -6,7 +6,7 @@ // // Constants that pertain to CI processes/tests only. No dependencies on vscode! // - +export const ENV_PATHS_LOCATION = process.env.ENV_PATHS_LOCATION; export const IS_APPVEYOR = process.env.APPVEYOR === 'true'; export const IS_TRAVIS = process.env.TRAVIS === 'true'; export const IS_VSTS = process.env.TF_BUILD !== undefined; diff --git a/src/test/common.ts b/src/test/common.ts index e1e9e30150df..21f55cbc2f0f 100644 --- a/src/test/common.ts +++ b/src/test/common.ts @@ -35,7 +35,7 @@ export type PythonSettingKeys = 'workspaceSymbols.enabled' | 'pythonPath' | 'unitTest.nosetestArgs' | 'unitTest.pyTestArgs' | 'unitTest.unittestArgs' | 'formatting.provider' | 'sortImports.args' | 'unitTest.nosetestsEnabled' | 'unitTest.pyTestEnabled' | 'unitTest.unittestEnabled' | - 'envFile' | 'jediEnabled' | 'linting.ignorePatterns'; + 'envFile' | 'jediEnabled' | 'linting.ignorePatterns' | 'terminal.activateEnvironment'; async function disposePythonSettings() { if (!IS_SMOKE_TEST) { @@ -76,6 +76,11 @@ export async function setPythonPathInWorkspaceRoot(pythonPath: string) { return retryAsync(setPythonPathInWorkspace)(undefined, vscode.ConfigurationTarget.Workspace, pythonPath); } +export async function restorePythonPathInWorkspaceRoot() { + const vscode = require('vscode') as typeof import('vscode'); + return retryAsync(setPythonPathInWorkspace)(undefined, vscode.ConfigurationTarget.Workspace, PYTHON_PATH); +} + export const resetGlobalPythonPathSetting = async () => retryAsync(restoreGlobalPythonPathSetting)(); function getWorkspaceRoot() { diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts new file mode 100644 index 000000000000..bfaf16803399 --- /dev/null +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -0,0 +1,75 @@ +'use strict'; +// tslint:disable:max-func-body-length no-invalid-this no-any + +import { expect } from 'chai'; +import * as fs from 'fs-extra'; +import * as path from 'path'; +import * as vscode from 'vscode'; +import { ENV_PATHS_LOCATION } from '../../../ciConstants'; +import { PYTHON_PATH, restorePythonPathInWorkspaceRoot, setPythonPathInWorkspaceRoot, updateSetting, waitForCondition } from '../../../common'; +import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../../constants'; +import { sleep } from '../../../core'; +import { initialize, initializeTest } from '../../../initialize'; + +suite('Activation of Environments in Terminal', () => { + const file = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.py'); + const outputFile = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.log'); + const envPathsLocation = ENV_PATHS_LOCATION || path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); + const waitTimeForActivation = 5000; + type EnvPath = { + venvPath: string; + pipenvPath: string; + virtualEnvPath: string; + }; + let envPaths: EnvPath; + suiteSetup(async () => { + envPaths = await fs.readJson(envPathsLocation); + await initialize(); + }); + setup(async () => { + await initializeTest(); + await cleanUp(); + }); + teardown(cleanUp); + suiteTeardown(revertSettings); + async function revertSettings() { + await updateSetting('terminal.activateEnvironment', undefined , vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); + await restorePythonPathInWorkspaceRoot(); + } + async function cleanUp() { + if (await fs.pathExists(outputFile)) { + await fs.unlink(outputFile); + } + } + async function testActivation(envPath){ + await updateSetting('terminal.activateEnvironment', true, vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); + await setPythonPathInWorkspaceRoot(envPath); + const terminal = vscode.window.createTerminal(); + await sleep(waitTimeForActivation); + terminal.sendText(`python ${file}`, true); + await waitForCondition(() => fs.pathExists(outputFile), 5_000, '\'testExecInTerminal.log\' file not created'); + const content = await fs.readFile(outputFile, 'utf-8'); + + expect(content).to.equal(envPath); + } + async function testNonActivation(){ + await updateSetting('terminal.activateEnvironment', false, vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); + const terminal = vscode.window.createTerminal(); + terminal.sendText(`python ${file}`, true); + await waitForCondition(() => fs.pathExists(outputFile), 5_000, '\'testExecInTerminal.log\' file not created'); + const content = await fs.readFile(outputFile, 'utf-8'); + expect(content).to.not.equal(PYTHON_PATH); + } + test('Should not activate', async () => { + await testNonActivation(); + }); + test('Should activate with venv', async () => { + await testActivation(envPaths.venvPath); + }); + test('Should activate with pipenv', async () => { + await testActivation(envPaths.pipenvPath); + }); + test('Should activate with virtualenv', async () => { + await testActivation(envPaths.virtualEnvPath); + }); +}); diff --git a/src/tmp/envPaths.json b/src/tmp/envPaths.json new file mode 100644 index 000000000000..ca7f8c7d3ca7 --- /dev/null +++ b/src/tmp/envPaths.json @@ -0,0 +1,6 @@ +{ + "condaPath": "C:\\Users\\karraj\\AppData\\Local\\Continuum\\anaconda3\\envs\\.conda\\python.exe", + "pipenvPath": "C:\\Users\\karraj\\.virtualenvs\\test-mFICMEuQ\\Scripts\\python.exe", + "venvPath": "C:\\Users\\karraj\\Desktop\\vscode-python\\src\\test\\.venv\\Scripts\\python.exe", + "virtualEnvPath": "C:\\Users\\karraj\\Desktop\\.virtualenv\\Scripts\\python.exe" +} From ea86b3595b286056367c088fc90ce9f73444a9fd Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Sat, 8 Dec 2018 15:29:44 -0800 Subject: [PATCH 07/33] Corrected suffix --- build/ci/addEnvPath.py | 17 +++++++++++------ build/ci/templates/virtual_env_tests.yml | 8 ++++---- build/ci/vscode-python-pr-validation.yaml | 2 +- .../terminalActivation.testvirtualenvs.ts | 3 ++- src/tmp/envPaths.json | 6 ------ 5 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 src/tmp/envPaths.json diff --git a/build/ci/addEnvPath.py b/build/ci/addEnvPath.py index c6246b4b6d41..33054e9da89d 100644 --- a/build/ci/addEnvPath.py +++ b/build/ci/addEnvPath.py @@ -2,14 +2,19 @@ import json,sys import os.path -key = sys.argv[1] +jsonPath = sys.argv[1] +key = sys.argv[2] -if os.path.isfile('$(ENV_PATHS_LOCATION)'): - with open('$(ENV_PATHS_LOCATION)', 'r') as read_file: +if os.path.isfile(jsonPath): + with open(jsonPath, 'r') as read_file: data = json.load(read_file) else: - with open('$(ENV_PATHS_LOCATION)', 'w+') as read_file: - data = {} -with open('$(ENV_PATHS_LOCATION)', 'w') as outfile: + directory = os.path.dirname(jsonPath) + if not os.path.exists(directory): + os.makedirs(directory) + with open(jsonPath, 'w+') as read_file: + data = {} + data = {} +with open(jsonPath, 'w') as outfile: data[key] = sys.executable json.dump(data, outfile, sort_keys=True, indent=4) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 09a2a82b2745..93715a0fe6ca 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -86,7 +86,7 @@ jobs: - bash: | pip install pipenv - pipenv run python ./build/ci/addEnvPath.py pipenvPath + pipenv run python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) pipenvPath cat $(ENV_PATHS_LOCATION) @@ -96,7 +96,7 @@ jobs: - bash: | python -m venv .venv - .venv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py venvPath + .venv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) venvPath cat $(ENV_PATHS_LOCATION) @@ -108,7 +108,7 @@ jobs: python -m virtualenv .virtualenv - .virtualenv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py virtualEnvPath + .virtualenv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) virtualEnvPath cat $(ENV_PATHS_LOCATION) @@ -122,7 +122,7 @@ jobs: # - bash: | - # python ./build/ci/addEnvPath.py conda + # python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) condaPath # source deactivate diff --git a/build/ci/vscode-python-pr-validation.yaml b/build/ci/vscode-python-pr-validation.yaml index b9f85fb01f0c..f401502e8bf8 100644 --- a/build/ci/vscode-python-pr-validation.yaml +++ b/build/ci/vscode-python-pr-validation.yaml @@ -28,7 +28,7 @@ jobs: PoolName: 'Hosted VS2017' EnvironmentExecutableFolder: 'Scripts' ENV_PATHS_LOCATION: './src/tmp/envPaths.json' - TEST_FILES_SUFFIX: 'testvirtualenvs.ts' + TEST_FILES_SUFFIX: 'testvirtualenvs' TestSuiteName: 'testSingleWorkspace' diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index bfaf16803399..11670ff6d2a1 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -14,7 +14,8 @@ import { initialize, initializeTest } from '../../../initialize'; suite('Activation of Environments in Terminal', () => { const file = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.py'); const outputFile = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.log'); - const envPathsLocation = ENV_PATHS_LOCATION || path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); + const envPathsLocation = ENV_PATHS_LOCATION !== undefined ? + path.join(EXTENSION_ROOT_DIR_FOR_TESTS, ENV_PATHS_LOCATION) : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); const waitTimeForActivation = 5000; type EnvPath = { venvPath: string; diff --git a/src/tmp/envPaths.json b/src/tmp/envPaths.json deleted file mode 100644 index ca7f8c7d3ca7..000000000000 --- a/src/tmp/envPaths.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "condaPath": "C:\\Users\\karraj\\AppData\\Local\\Continuum\\anaconda3\\envs\\.conda\\python.exe", - "pipenvPath": "C:\\Users\\karraj\\.virtualenvs\\test-mFICMEuQ\\Scripts\\python.exe", - "venvPath": "C:\\Users\\karraj\\Desktop\\vscode-python\\src\\test\\.venv\\Scripts\\python.exe", - "virtualEnvPath": "C:\\Users\\karraj\\Desktop\\.virtualenv\\Scripts\\python.exe" -} From cd1587563bb35ce26d4e3662dac28f73454b6a02 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 10 Dec 2018 10:51:12 -0800 Subject: [PATCH 08/33] Added system test to check activation for CONDA --- build/ci/templates/virtual_env_tests.yml | 16 +++++++--------- .../terminalActivation.testvirtualenvs.ts | 4 ++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 93715a0fe6ca..57f57b6fbec2 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -115,20 +115,18 @@ jobs: displayName: 'Create virtualenv environment' - # - task: CondaEnvironment@1 - # displayName: 'Create conda environment ' - # inputs: - # packageSpecs: 'python=3.7' + - bash: | + echo $(CONDA) + activate $(CONDA) - # - bash: | - # python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) condaPath + python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) condaPath - # source deactivate + source deactivate - # cat $(ENV_PATHS_LOCATION) + cat $(ENV_PATHS_LOCATION) - # displayName: 'Save conda environment executable' + displayName: 'Save conda environment executable' - task: Npm@1 diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 11670ff6d2a1..efe2b7fa52fe 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -18,6 +18,7 @@ suite('Activation of Environments in Terminal', () => { path.join(EXTENSION_ROOT_DIR_FOR_TESTS, ENV_PATHS_LOCATION) : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); const waitTimeForActivation = 5000; type EnvPath = { + condaPath: string; venvPath: string; pipenvPath: string; virtualEnvPath: string; @@ -73,4 +74,7 @@ suite('Activation of Environments in Terminal', () => { test('Should activate with virtualenv', async () => { await testActivation(envPaths.virtualEnvPath); }); + test('Should activate with conda', async () => { + await testActivation(envPaths.condaPath); + }); }); From d4391935779ff247013e45142806c79da99de9f4 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 10 Dec 2018 12:36:56 -0800 Subject: [PATCH 09/33] Corrected conda activation --- build/ci/templates/virtual_env_tests.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 57f57b6fbec2..6aec430f0d3b 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -118,11 +118,7 @@ jobs: - bash: | echo $(CONDA) - activate $(CONDA) - - python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) condaPath - - source deactivate + C:/Miniconda/python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) condaPath cat $(ENV_PATHS_LOCATION) From a532b902ef80e2b03b85df6334f114f4df2ef26d Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 11 Dec 2018 11:05:13 -0800 Subject: [PATCH 10/33] Corrected terminal for conda activation --- .../terminalActivation.testvirtualenvs.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index efe2b7fa52fe..fb21a54ea49e 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -24,8 +24,12 @@ suite('Activation of Environments in Terminal', () => { virtualEnvPath: string; }; let envPaths: EnvPath; + let defaultShell; + let terminalSettings; suiteSetup(async () => { envPaths = await fs.readJson(envPathsLocation); + terminalSettings = vscode.workspace.getConfiguration('terminal', vscode.workspace.workspaceFolders[0].uri); + defaultShell = terminalSettings.inspect('integrated.shell.windows').globalValue; await initialize(); }); setup(async () => { @@ -36,6 +40,7 @@ suite('Activation of Environments in Terminal', () => { suiteTeardown(revertSettings); async function revertSettings() { await updateSetting('terminal.activateEnvironment', undefined , vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); + await terminalSettings.update('integrated.shell.windows', defaultShell, vscode.ConfigurationTarget.Global); await restorePythonPathInWorkspaceRoot(); } async function cleanUp() { @@ -75,6 +80,7 @@ suite('Activation of Environments in Terminal', () => { await testActivation(envPaths.virtualEnvPath); }); test('Should activate with conda', async () => { + await terminalSettings.update('integrated.shell.windows', 'C:\\Windows\\System32\\cmd.exe', vscode.ConfigurationTarget.Global); await testActivation(envPaths.condaPath); }); }); From 964206a728addd06909e2d8c7b899a690f884fec Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 11 Dec 2018 11:40:54 -0800 Subject: [PATCH 11/33] Changed conda bash script to powershell --- build/ci/templates/virtual_env_tests.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 6aec430f0d3b..dc91d68cbef4 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -114,13 +114,14 @@ jobs: displayName: 'Create virtualenv environment' + - powershell: | + Write-Host $Env:CONDA - - bash: | - echo $(CONDA) + $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python - C:/Miniconda/python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) condaPath + & $condaPythonPath ./build/ci/addEnvPath.py $Env:ENV_PATHS_LOCATION condaPath - cat $(ENV_PATHS_LOCATION) + Get-Content $Env:ENV_PATHS_LOCATION displayName: 'Save conda environment executable' From fe9746640205282088d6bd8091edf29d8a9efe93 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 11 Dec 2018 15:52:05 -0800 Subject: [PATCH 12/33] Added system test to ensure terminal gets activated with anaconda environment --- news/3 Code Health/1521.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/3 Code Health/1521.md diff --git a/news/3 Code Health/1521.md b/news/3 Code Health/1521.md new file mode 100644 index 000000000000..7a3f68b59fe7 --- /dev/null +++ b/news/3 Code Health/1521.md @@ -0,0 +1 @@ +Created system test to ensure terminal gets activated with anaconda environment \ No newline at end of file From 47708b2d4eeb7e7ccba9e4928fb95b616643a07b Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 11 Dec 2018 15:54:33 -0800 Subject: [PATCH 13/33] Added system tests to ensure terminal gets activated with virtualenv environment --- news/3 Code Health/1522.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/3 Code Health/1522.md diff --git a/news/3 Code Health/1522.md b/news/3 Code Health/1522.md new file mode 100644 index 000000000000..d0226766eef9 --- /dev/null +++ b/news/3 Code Health/1522.md @@ -0,0 +1 @@ +Added system tests to ensure terminal gets activated with virtualenv environment From b9cbb421b9d727bcdb98ee713c9f1631d36c3d9f Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 11 Dec 2018 15:55:35 -0800 Subject: [PATCH 14/33] Added system test to ensure terminal gets activated with pipenv --- news/3 Code Health/1523.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/3 Code Health/1523.md diff --git a/news/3 Code Health/1523.md b/news/3 Code Health/1523.md new file mode 100644 index 000000000000..ac9d6c029eba --- /dev/null +++ b/news/3 Code Health/1523.md @@ -0,0 +1 @@ +Added system test to ensure terminal gets activated with pipenv \ No newline at end of file From 358bb15483f118b1520d94b8c56f2fb5b52d2224 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 12 Dec 2018 13:18:08 -0800 Subject: [PATCH 15/33] Addressed PR reviews --- build/ci/addEnvPath.py | 3 + build/ci/templates/virtual_env_tests.yml | 64 +++++++++++++------ build/ci/vscode-python-pr-validation.yaml | 2 +- src/test/ciConstants.ts | 2 +- .../terminalActivation.testvirtualenvs.ts | 12 ++-- 5 files changed, 56 insertions(+), 27 deletions(-) diff --git a/build/ci/addEnvPath.py b/build/ci/addEnvPath.py index 33054e9da89d..b1e8eb052353 100644 --- a/build/ci/addEnvPath.py +++ b/build/ci/addEnvPath.py @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + #Adds the virtual environment's executable path to json file import json,sys diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index dc91d68cbef4..9c0003ea34a9 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -1,12 +1,13 @@ parameters: name: 'VirtualEnv_Tests_Windows_py37' + PythonVersion: '3.7' NodeVersion: '8.11.2' NpmVersion: 'latest' AzureStorageAccountName: 'vscodepythonci' AzureStorageContainerName: 'vscode-python-ci' PoolName: 'Hosted VS2017' EnvironmentExecutableFolder: 'Scripts' - ENV_PATHS_LOCATION: './src/tmp/envPaths.json' + PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' TEST_FILES_SUFFIX: 'testvirtualenvs' TestSuiteName: 'testSingleWorkspace' @@ -17,14 +18,13 @@ jobs: name: ${{ parameters.PoolName }} variables: - # TODO: use {{ insert }}: {{ parameters.variables }}, it would not work at time I wrote this nodeVersion: ${{ parameters.NodeVersion }} npmVersion: ${{ parameters.NpmVersion }} pythonVersion: ${{ parameters.PythonVersion }} azureStorageAcctName: ${{ parameters.AzureStorageAccountName }} azureStorageContainerName: ${{ parameters.AzureStorageContainerName }} environmentExecutableFolder: ${{ parameters.EnvironmentExecutableFolder }} - ENV_PATHS_LOCATION: ${{ parameters.ENV_PATHS_LOCATION }} + PYTHON_VIRTUAL_ENVS_LOCATION: ${{ parameters.PYTHON_VIRTUAL_ENVS_LOCATION }} TEST_FILES_SUFFIX: ${{ parameters.TEST_FILES_SUFFIX }} TestSuiteName: ${{ parameters.TestSuiteName }} @@ -77,51 +77,75 @@ jobs: cleanDestinationFolder: false - - task: UsePythonVersion@0 - displayName: 'Use Python 3.7' + - task: NodeTool@0 + displayName: 'Use Node $(nodeVersion)' inputs: - versionSpec: 3.7 + versionSpec: '$(nodeVersion)' - - bash: | - pip install pipenv + - task: UsePythonVersion@0 + displayName: 'Use Python $(pythonVersion)' + inputs: + versionSpec: '$(pythonVersion)' - pipenv run python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) pipenvPath - cat $(ENV_PATHS_LOCATION) + - task: CmdLine@1 + displayName: 'pip install pipenv' + inputs: + filename: python - displayName: 'Create pipenv environment' + arguments: '-m pip install pipenv' - bash: | - python -m venv .venv + pipenv run python ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) pipenvPath - .venv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) venvPath + displayName: 'Create and save pipenv environment' - cat $(ENV_PATHS_LOCATION) + - task: CmdLine@1 displayName: 'Create venv environment' + inputs: + filename: python + + arguments: '-m venv .venv' - bash: | - pip install virtualenv + .venv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) venvPath + + displayName: 'Save venv environment executable' - python -m virtualenv .virtualenv - .virtualenv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py $(ENV_PATHS_LOCATION) virtualEnvPath + - task: CmdLine@1 + displayName: 'pip install virtualenv' + inputs: + filename: python + + arguments: '-m pip install virtualenv' - cat $(ENV_PATHS_LOCATION) + - task: CmdLine@1 displayName: 'Create virtualenv environment' + inputs: + filename: python + + arguments: '-m virtualenv .virtualenv' + + + - bash: | + .virtualenv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) virtualEnvPath + + displayName: 'Save virtualenv environment executable' - powershell: | Write-Host $Env:CONDA $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python - & $condaPythonPath ./build/ci/addEnvPath.py $Env:ENV_PATHS_LOCATION condaPath + & $condaPythonPath ./build/ci/addEnvPath.py $Env:PYTHON_VIRTUAL_ENVS_LOCATION condaPath - Get-Content $Env:ENV_PATHS_LOCATION + Get-Content $Env:PYTHON_VIRTUAL_ENVS_LOCATION displayName: 'Save conda environment executable' diff --git a/build/ci/vscode-python-pr-validation.yaml b/build/ci/vscode-python-pr-validation.yaml index f401502e8bf8..a101ed9b64a5 100644 --- a/build/ci/vscode-python-pr-validation.yaml +++ b/build/ci/vscode-python-pr-validation.yaml @@ -27,7 +27,7 @@ jobs: AzureStorageContainerName: 'vscode-python-ci' PoolName: 'Hosted VS2017' EnvironmentExecutableFolder: 'Scripts' - ENV_PATHS_LOCATION: './src/tmp/envPaths.json' + PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' TEST_FILES_SUFFIX: 'testvirtualenvs' TestSuiteName: 'testSingleWorkspace' diff --git a/src/test/ciConstants.ts b/src/test/ciConstants.ts index ee797bea79f5..1be1ccf6a339 100644 --- a/src/test/ciConstants.ts +++ b/src/test/ciConstants.ts @@ -6,7 +6,7 @@ // // Constants that pertain to CI processes/tests only. No dependencies on vscode! // -export const ENV_PATHS_LOCATION = process.env.ENV_PATHS_LOCATION; +export const PYTHON_VIRTUAL_ENVS_LOCATION = process.env.PYTHON_VIRTUAL_ENVS_LOCATION; export const IS_APPVEYOR = process.env.APPVEYOR === 'true'; export const IS_TRAVIS = process.env.TRAVIS === 'true'; export const IS_VSTS = process.env.TF_BUILD !== undefined; diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index fb21a54ea49e..474084837cbb 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -1,11 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + 'use strict'; -// tslint:disable:max-func-body-length no-invalid-this no-any import { expect } from 'chai'; import * as fs from 'fs-extra'; import * as path from 'path'; import * as vscode from 'vscode'; -import { ENV_PATHS_LOCATION } from '../../../ciConstants'; +import { PYTHON_VIRTUAL_ENVS_LOCATION } from '../../../ciConstants'; import { PYTHON_PATH, restorePythonPathInWorkspaceRoot, setPythonPathInWorkspaceRoot, updateSetting, waitForCondition } from '../../../common'; import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../../constants'; import { sleep } from '../../../core'; @@ -14,8 +16,8 @@ import { initialize, initializeTest } from '../../../initialize'; suite('Activation of Environments in Terminal', () => { const file = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.py'); const outputFile = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.log'); - const envPathsLocation = ENV_PATHS_LOCATION !== undefined ? - path.join(EXTENSION_ROOT_DIR_FOR_TESTS, ENV_PATHS_LOCATION) : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); + const envsLocation = PYTHON_VIRTUAL_ENVS_LOCATION !== undefined ? + path.join(EXTENSION_ROOT_DIR_FOR_TESTS, PYTHON_VIRTUAL_ENVS_LOCATION) : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); const waitTimeForActivation = 5000; type EnvPath = { condaPath: string; @@ -27,7 +29,7 @@ suite('Activation of Environments in Terminal', () => { let defaultShell; let terminalSettings; suiteSetup(async () => { - envPaths = await fs.readJson(envPathsLocation); + envPaths = await fs.readJson(envsLocation); terminalSettings = vscode.workspace.getConfiguration('terminal', vscode.workspace.workspaceFolders[0].uri); defaultShell = terminalSettings.inspect('integrated.shell.windows').globalValue; await initialize(); From f218cfde0fb5e30b661ba0559d7d3f94d8df120d Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 12 Dec 2018 16:23:53 -0800 Subject: [PATCH 16/33] Added testing for linux --- build/ci/vscode-python-pr-validation.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build/ci/vscode-python-pr-validation.yaml b/build/ci/vscode-python-pr-validation.yaml index 4e997ed73ee8..b2ff2ca1d446 100644 --- a/build/ci/vscode-python-pr-validation.yaml +++ b/build/ci/vscode-python-pr-validation.yaml @@ -32,6 +32,21 @@ jobs: TestSuiteName: 'testSingleWorkspace' +- template: templates/virtual_env_tests.yml + parameters: + name: 'VirtualEnv_Tests_Linux_py37' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' + PoolName: 'Hosted Ubuntu 1604' + EnvironmentExecutableFolder: 'bin' + PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' + TEST_FILES_SUFFIX: 'testvirtualenvs' + TestSuiteName: 'testSingleWorkspace' + + - job: 'System_Test_macOS' dependsOn: 'PR_Validate_Windows_py37' pool: From 4f9fc477d755ccbea8f53f7470cf1a1e838b0865 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 12 Dec 2018 18:08:36 -0800 Subject: [PATCH 17/33] Corrected conda executable location for linux --- build/ci/templates/virtual_env_tests.yml | 9 ++++++++- build/ci/vscode-python-pr-validation.yaml | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 9c0003ea34a9..5838c7ea2650 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -5,6 +5,7 @@ parameters: NpmVersion: 'latest' AzureStorageAccountName: 'vscodepythonci' AzureStorageContainerName: 'vscode-python-ci' + Platform: 'Windows' PoolName: 'Hosted VS2017' EnvironmentExecutableFolder: 'Scripts' PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' @@ -21,6 +22,7 @@ jobs: nodeVersion: ${{ parameters.NodeVersion }} npmVersion: ${{ parameters.NpmVersion }} pythonVersion: ${{ parameters.PythonVersion }} + platform: ${{ parameters.Platform }} azureStorageAcctName: ${{ parameters.AzureStorageAccountName }} azureStorageContainerName: ${{ parameters.AzureStorageContainerName }} environmentExecutableFolder: ${{ parameters.EnvironmentExecutableFolder }} @@ -141,7 +143,12 @@ jobs: - powershell: | Write-Host $Env:CONDA - $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python + if( $Env:platform -eq 'Linux' ){ + $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $Env:environmentExecutableFolder | Join-Path -ChildPath python + + }else { + $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python + } & $condaPythonPath ./build/ci/addEnvPath.py $Env:PYTHON_VIRTUAL_ENVS_LOCATION condaPath diff --git a/build/ci/vscode-python-pr-validation.yaml b/build/ci/vscode-python-pr-validation.yaml index b2ff2ca1d446..b8d712200326 100644 --- a/build/ci/vscode-python-pr-validation.yaml +++ b/build/ci/vscode-python-pr-validation.yaml @@ -25,6 +25,7 @@ jobs: NpmVersion: 'latest' AzureStorageAccountName: 'vscodepythonci' AzureStorageContainerName: 'vscode-python-ci' + Platform: 'Windows' PoolName: 'Hosted VS2017' EnvironmentExecutableFolder: 'Scripts' PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' @@ -40,6 +41,7 @@ jobs: NpmVersion: 'latest' AzureStorageAccountName: 'vscodepythonci' AzureStorageContainerName: 'vscode-python-ci' + Platform: 'Linux' PoolName: 'Hosted Ubuntu 1604' EnvironmentExecutableFolder: 'bin' PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' From b074d54e1584716eb0360535af94ad1ebb741e76 Mon Sep 17 00:00:00 2001 From: Ritvik Raj Date: Thu, 13 Dec 2018 08:56:31 -0800 Subject: [PATCH 18/33] Corrected YAML --- build/ci/templates/virtual_env_tests.yml | 33 +++++++++++------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 5838c7ea2650..0a8ac9218935 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -1,17 +1,3 @@ -parameters: - name: 'VirtualEnv_Tests_Windows_py37' - PythonVersion: '3.7' - NodeVersion: '8.11.2' - NpmVersion: 'latest' - AzureStorageAccountName: 'vscodepythonci' - AzureStorageContainerName: 'vscode-python-ci' - Platform: 'Windows' - PoolName: 'Hosted VS2017' - EnvironmentExecutableFolder: 'Scripts' - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - TEST_FILES_SUFFIX: 'testvirtualenvs' - TestSuiteName: 'testSingleWorkspace' - jobs: - job: ${{ parameters.name }} dependsOn: 'PR_Validate_Windows_py37' @@ -142,16 +128,27 @@ jobs: - powershell: | Write-Host $Env:CONDA - - if( $Env:platform -eq 'Linux' ){ - $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $Env:environmentExecutableFolder | Join-Path -ChildPath python + Write-Host $(platform) + Write-Host $Env:environmentExecutableFolder + Write-Host $environmentExecutableFolder + Write-Host $Env:PYTHON_VIRTUAL_ENVS_LOCATION + Write-Host '$(environmentExecutableFolder)' + Write-Host $(PYTHON_VIRTUAL_ENVS_LOCATION) + if( '$(platform)' -eq 'Linux' ){ + $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath python }else { $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python } - & $condaPythonPath ./build/ci/addEnvPath.py $Env:PYTHON_VIRTUAL_ENVS_LOCATION condaPath + & $condaPythonPath ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) condaPath + Write-Host $Env:$(environmentExecutableFolder) + Write-Host $Env:Platform + Write-Host $Env:EnvironmentExecutableFolder + Write-Host $EnvironmentExecutableFolder + Write-Host $(PYTHON_VIRTUAL_ENVS_LOCATION) + Get-Content $(PYTHON_VIRTUAL_ENVS_LOCATION) Get-Content $Env:PYTHON_VIRTUAL_ENVS_LOCATION displayName: 'Save conda environment executable' From b75bc92d8b7774222a03e4f6d61e9e0f3d16b37e Mon Sep 17 00:00:00 2001 From: Ritvik Raj Date: Thu, 13 Dec 2018 11:28:55 -0800 Subject: [PATCH 19/33] Started xvfb task for venvs linux --- build/ci/templates/virtual_env_tests.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 0a8ac9218935..89574f2b170d 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -128,12 +128,9 @@ jobs: - powershell: | Write-Host $Env:CONDA - Write-Host $(platform) Write-Host $Env:environmentExecutableFolder - Write-Host $environmentExecutableFolder + Write-Host $Env:EnvironmentExecutableFolder Write-Host $Env:PYTHON_VIRTUAL_ENVS_LOCATION - Write-Host '$(environmentExecutableFolder)' - Write-Host $(PYTHON_VIRTUAL_ENVS_LOCATION) if( '$(platform)' -eq 'Linux' ){ $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath python @@ -143,12 +140,6 @@ jobs: & $condaPythonPath ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) condaPath - Write-Host $Env:$(environmentExecutableFolder) - Write-Host $Env:Platform - Write-Host $Env:EnvironmentExecutableFolder - Write-Host $EnvironmentExecutableFolder - Write-Host $(PYTHON_VIRTUAL_ENVS_LOCATION) - Get-Content $(PYTHON_VIRTUAL_ENVS_LOCATION) Get-Content $Env:PYTHON_VIRTUAL_ENVS_LOCATION displayName: 'Save conda environment executable' @@ -174,6 +165,14 @@ jobs: customCommand: ci + - script: | + set -e + /usr/bin/Xvfb :10 -ac >> /tmp/Xvfb.out 2>&1 & + disown -ar + displayName: 'Start xvfb' + condition: and(succeeded(), eq(variables['Platform'], 'Linux')) + + - task: Npm@1 displayName: 'run $(TestSuiteName)' inputs: From 10e9dcb929cb3eba7644774f910fdb0dd2f9838d Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 13 Dec 2018 12:47:38 -0800 Subject: [PATCH 20/33] Added DISPLAY env --- build/ci/templates/virtual_env_tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 89574f2b170d..9f699d26bb87 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -181,5 +181,7 @@ jobs: verbose: true customCommand: 'run $(TestSuiteName)' + env: + DISPLAY: :10 From e1b7b19bcc9f4ea27bf71e36c0f2f529acd738a4 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 13 Dec 2018 18:20:13 -0800 Subject: [PATCH 21/33] Printing variables to console --- .../terminalActivation.testvirtualenvs.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 474084837cbb..dd7ba68adda7 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -53,6 +53,9 @@ suite('Activation of Environments in Terminal', () => { async function testActivation(envPath){ await updateSetting('terminal.activateEnvironment', true, vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); await setPythonPathInWorkspaceRoot(envPath); + const pyPath = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders[0].uri); + // tslint:disable-next-line:no-console + console.log(`Set pythonPath to ${pyPath.inspect('pythonPath').workspaceFolderValue}`); const terminal = vscode.window.createTerminal(); await sleep(waitTimeForActivation); terminal.sendText(`python ${file}`, true); From e02793cbe0884f6491e44a4535979673fd69c188 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 13 Dec 2018 19:06:52 -0800 Subject: [PATCH 22/33] Temporarily removed other tasks for debugging --- build/ci/vscode-python-pr-validation.yaml | 298 +++++++++--------- .../environmentActivationProviders/bash.ts | 4 + 2 files changed, 153 insertions(+), 149 deletions(-) diff --git a/build/ci/vscode-python-pr-validation.yaml b/build/ci/vscode-python-pr-validation.yaml index b8d712200326..20489e01ca17 100644 --- a/build/ci/vscode-python-pr-validation.yaml +++ b/build/ci/vscode-python-pr-validation.yaml @@ -17,20 +17,20 @@ jobs: AzureStorageContainerName: 'vscode-python-ci' -- template: templates/virtual_env_tests.yml - parameters: - name: 'VirtualEnv_Tests_Windows_py37' - PythonVersion: '3.7' - NodeVersion: '8.11.2' - NpmVersion: 'latest' - AzureStorageAccountName: 'vscodepythonci' - AzureStorageContainerName: 'vscode-python-ci' - Platform: 'Windows' - PoolName: 'Hosted VS2017' - EnvironmentExecutableFolder: 'Scripts' - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - TEST_FILES_SUFFIX: 'testvirtualenvs' - TestSuiteName: 'testSingleWorkspace' +# - template: templates/virtual_env_tests.yml +# parameters: +# name: 'VirtualEnv_Tests_Windows_py37' +# PythonVersion: '3.7' +# NodeVersion: '8.11.2' +# NpmVersion: 'latest' +# AzureStorageAccountName: 'vscodepythonci' +# AzureStorageContainerName: 'vscode-python-ci' +# Platform: 'Windows' +# PoolName: 'Hosted VS2017' +# EnvironmentExecutableFolder: 'Scripts' +# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' +# TEST_FILES_SUFFIX: 'testvirtualenvs' +# TestSuiteName: 'testSingleWorkspace' - template: templates/virtual_env_tests.yml @@ -49,142 +49,142 @@ jobs: TestSuiteName: 'testSingleWorkspace' -- job: 'System_Test_macOS' - dependsOn: 'PR_Validate_Windows_py37' - pool: - name: 'Hosted macOS' - steps: - - template: templates/test-phase.yml - strategy: - maxParallel: 3 - matrix: - SingleWorkspace: - TestSuiteName: 'testSingleWorkspace' - BuildNumber: '$(Build.BuildNumber)' - Platform: 'macOS' - PythonVersion: '3.7' - NodeVersion: '8.11.2' - NpmVersion: 'latest' - MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' - MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' - MOCHA_REPORTER_JUNIT: true - AzureStorageAccountName: 'vscodepythonci' - AzureStorageContainerName: 'vscode-python-ci' - MultiWorkspace: - TestSuiteName: 'testMultiWorkspace' - BuildNumber: '$(Build.BuildNumber)' - Platform: 'macOS' - PythonVersion: '3.7' - NodeVersion: '8.11.2' - NpmVersion: 'latest' - MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' - MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' - MOCHA_REPORTER_JUNIT: true - AzureStorageAccountName: 'vscodepythonci' - AzureStorageContainerName: 'vscode-python-ci' - Debugger: - TestSuiteName: 'testDebugger' - BuildNumber: '$(Build.BuildNumber)' - Platform: 'macOS' - PythonVersion: '3.7' - NodeVersion: '8.11.2' - NpmVersion: 'latest' - MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' - MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' - MOCHA_REPORTER_JUNIT: true - AzureStorageAccountName: 'vscodepythonci' - AzureStorageContainerName: 'vscode-python-ci' +# - job: 'System_Test_macOS' +# dependsOn: 'PR_Validate_Windows_py37' +# pool: +# name: 'Hosted macOS' +# steps: +# - template: templates/test-phase.yml +# strategy: +# maxParallel: 3 +# matrix: +# SingleWorkspace: +# TestSuiteName: 'testSingleWorkspace' +# BuildNumber: '$(Build.BuildNumber)' +# Platform: 'macOS' +# PythonVersion: '3.7' +# NodeVersion: '8.11.2' +# NpmVersion: 'latest' +# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' +# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' +# MOCHA_REPORTER_JUNIT: true +# AzureStorageAccountName: 'vscodepythonci' +# AzureStorageContainerName: 'vscode-python-ci' +# MultiWorkspace: +# TestSuiteName: 'testMultiWorkspace' +# BuildNumber: '$(Build.BuildNumber)' +# Platform: 'macOS' +# PythonVersion: '3.7' +# NodeVersion: '8.11.2' +# NpmVersion: 'latest' +# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' +# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' +# MOCHA_REPORTER_JUNIT: true +# AzureStorageAccountName: 'vscodepythonci' +# AzureStorageContainerName: 'vscode-python-ci' +# Debugger: +# TestSuiteName: 'testDebugger' +# BuildNumber: '$(Build.BuildNumber)' +# Platform: 'macOS' +# PythonVersion: '3.7' +# NodeVersion: '8.11.2' +# NpmVersion: 'latest' +# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' +# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' +# MOCHA_REPORTER_JUNIT: true +# AzureStorageAccountName: 'vscodepythonci' +# AzureStorageContainerName: 'vscode-python-ci' -- job: 'System_Test_Windows' - dependsOn: 'PR_Validate_Windows_py37' - pool: - name: 'Hosted VS2017' - steps: - - template: templates/test-phase.yml - strategy: - maxParallel: 3 - matrix: - SingleWorkspace: - TestSuiteName: 'testSingleWorkspace' - BuildNumber: '$(Build.BuildNumber)' - Platform: 'Windows' - PythonVersion: '3.7' - NodeVersion: '8.11.2' - NpmVersion: 'latest' - MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' - MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' - MOCHA_REPORTER_JUNIT: true - AzureStorageAccountName: 'vscodepythonci' - AzureStorageContainerName: 'vscode-python-ci' - MultiWorkspace: - TestSuiteName: 'testMultiWorkspace' - BuildNumber: '$(Build.BuildNumber)' - Platform: 'Windows' - PythonVersion: '3.7' - NodeVersion: '8.11.2' - NpmVersion: 'latest' - MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' - MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' - MOCHA_REPORTER_JUNIT: true - AzureStorageAccountName: 'vscodepythonci' - AzureStorageContainerName: 'vscode-python-ci' - Debugger: - TestSuiteName: 'testDebugger' - BuildNumber: '$(Build.BuildNumber)' - Platform: 'Windows' - PythonVersion: '3.7' - NodeVersion: '8.11.2' - NpmVersion: 'latest' - MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' - MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' - MOCHA_REPORTER_JUNIT: true - AzureStorageAccountName: 'vscodepythonci' - AzureStorageContainerName: 'vscode-python-ci' +# - job: 'System_Test_Windows' +# dependsOn: 'PR_Validate_Windows_py37' +# pool: +# name: 'Hosted VS2017' +# steps: +# - template: templates/test-phase.yml +# strategy: +# maxParallel: 3 +# matrix: +# SingleWorkspace: +# TestSuiteName: 'testSingleWorkspace' +# BuildNumber: '$(Build.BuildNumber)' +# Platform: 'Windows' +# PythonVersion: '3.7' +# NodeVersion: '8.11.2' +# NpmVersion: 'latest' +# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' +# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' +# MOCHA_REPORTER_JUNIT: true +# AzureStorageAccountName: 'vscodepythonci' +# AzureStorageContainerName: 'vscode-python-ci' +# MultiWorkspace: +# TestSuiteName: 'testMultiWorkspace' +# BuildNumber: '$(Build.BuildNumber)' +# Platform: 'Windows' +# PythonVersion: '3.7' +# NodeVersion: '8.11.2' +# NpmVersion: 'latest' +# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' +# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' +# MOCHA_REPORTER_JUNIT: true +# AzureStorageAccountName: 'vscodepythonci' +# AzureStorageContainerName: 'vscode-python-ci' +# Debugger: +# TestSuiteName: 'testDebugger' +# BuildNumber: '$(Build.BuildNumber)' +# Platform: 'Windows' +# PythonVersion: '3.7' +# NodeVersion: '8.11.2' +# NpmVersion: 'latest' +# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' +# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' +# MOCHA_REPORTER_JUNIT: true +# AzureStorageAccountName: 'vscodepythonci' +# AzureStorageContainerName: 'vscode-python-ci' -- job: 'System_Test_Run_Linux' - dependsOn: 'PR_Validate_Windows_py37' - pool: - name: 'Hosted Ubuntu 1604' - steps: - - template: templates/test-phase.yml - strategy: - maxParallel: 10 - matrix: - SingleWorkspace: - TestSuiteName: 'testSingleWorkspace' - BuildNumber: '$(Build.BuildNumber)' - Platform: 'Linux' - PythonVersion: '3.7' - NodeVersion: '8.11.2' - NpmVersion: 'latest' - MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' - MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' - MOCHA_REPORTER_JUNIT: true - AzureStorageAccountName: 'vscodepythonci' - AzureStorageContainerName: 'vscode-python-ci' - MultiWorkspace: - TestSuiteName: 'testMultiWorkspace' - BuildNumber: '$(Build.BuildNumber)' - Platform: 'Linux' - PythonVersion: '3.7' - NodeVersion: '8.11.2' - NpmVersion: 'latest' - MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' - MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' - MOCHA_REPORTER_JUNIT: true - AzureStorageAccountName: 'vscodepythonci' - AzureStorageContainerName: 'vscode-python-ci' - Debugger: - TestSuiteName: 'testDebugger' - BuildNumber: '$(Build.BuildNumber)' - Platform: 'Linux' - PythonVersion: '3.7' - NodeVersion: '8.11.2' - NpmVersion: 'latest' - MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' - MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' - MOCHA_REPORTER_JUNIT: true - AzureStorageAccountName: 'vscodepythonci' - AzureStorageContainerName: 'vscode-python-ci' +# - job: 'System_Test_Run_Linux' +# dependsOn: 'PR_Validate_Windows_py37' +# pool: +# name: 'Hosted Ubuntu 1604' +# steps: +# - template: templates/test-phase.yml +# strategy: +# maxParallel: 10 +# matrix: +# SingleWorkspace: +# TestSuiteName: 'testSingleWorkspace' +# BuildNumber: '$(Build.BuildNumber)' +# Platform: 'Linux' +# PythonVersion: '3.7' +# NodeVersion: '8.11.2' +# NpmVersion: 'latest' +# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' +# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' +# MOCHA_REPORTER_JUNIT: true +# AzureStorageAccountName: 'vscodepythonci' +# AzureStorageContainerName: 'vscode-python-ci' +# MultiWorkspace: +# TestSuiteName: 'testMultiWorkspace' +# BuildNumber: '$(Build.BuildNumber)' +# Platform: 'Linux' +# PythonVersion: '3.7' +# NodeVersion: '8.11.2' +# NpmVersion: 'latest' +# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' +# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' +# MOCHA_REPORTER_JUNIT: true +# AzureStorageAccountName: 'vscodepythonci' +# AzureStorageContainerName: 'vscode-python-ci' +# Debugger: +# TestSuiteName: 'testDebugger' +# BuildNumber: '$(Build.BuildNumber)' +# Platform: 'Linux' +# PythonVersion: '3.7' +# NodeVersion: '8.11.2' +# NpmVersion: 'latest' +# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' +# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' +# MOCHA_REPORTER_JUNIT: true +# AzureStorageAccountName: 'vscodepythonci' +# AzureStorageContainerName: 'vscode-python-ci' diff --git a/src/client/common/terminal/environmentActivationProviders/bash.ts b/src/client/common/terminal/environmentActivationProviders/bash.ts index d330ec60d690..950caa798bf6 100644 --- a/src/client/common/terminal/environmentActivationProviders/bash.ts +++ b/src/client/common/terminal/environmentActivationProviders/bash.ts @@ -24,7 +24,11 @@ export class Bash extends BaseActivationCommandProvider { } public async getActivationCommandsForInterpreter(pythonPath: string, targetShell: TerminalShellType): Promise { const scriptFile = await this.findScriptFile(pythonPath, this.getScriptsInOrderOfPreference(targetShell)); + // tslint:disable-next-line:no-console + console.log('I am here'); if (!scriptFile) { + // tslint:disable-next-line:no-console + console.log('I should not be here'); return; } return [`source ${scriptFile.fileToCommandArgument()}`]; From d1b981b0e3cdd3ddbc7989b9ac13b0957e0229cb Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 14 Dec 2018 13:30:56 -0800 Subject: [PATCH 23/33] Debugging --- src/client/common/terminal/activator/base.ts | 4 ++++ .../common/terminal/activator/powershellFailedHandler.ts | 4 ++++ .../baseActivationProvider.ts | 2 ++ .../common/terminal/environmentActivationProviders/bash.ts | 2 +- src/client/common/terminal/helper.ts | 4 ++++ .../terminalActivation.testvirtualenvs.ts | 6 +++--- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/client/common/terminal/activator/base.ts b/src/client/common/terminal/activator/base.ts index b74287a99f2a..ec3f3ea3893a 100644 --- a/src/client/common/terminal/activator/base.ts +++ b/src/client/common/terminal/activator/base.ts @@ -20,9 +20,13 @@ export class BaseTerminalActivator implements ITerminalActivator { const terminalShellType = !shellPath || shellPath.length === 0 ? TerminalShellType.other : this.helper.identifyTerminalShell(shellPath); const activationCommamnds = await this.helper.getEnvironmentActivationCommands(terminalShellType, resource); + // tslint:disable-next-line:no-console + console.log('Base.ts returned command', activationCommamnds); let activated = false; if (activationCommamnds) { for (const command of activationCommamnds!) { + // tslint:disable-next-line:no-console + console.log('in base.ts', command); terminal.show(preserveFocus); terminal.sendText(command); await this.waitForCommandToProcess(terminalShellType); diff --git a/src/client/common/terminal/activator/powershellFailedHandler.ts b/src/client/common/terminal/activator/powershellFailedHandler.ts index a8ecba9f6da0..bdc3afde1d6c 100644 --- a/src/client/common/terminal/activator/powershellFailedHandler.ts +++ b/src/client/common/terminal/activator/powershellFailedHandler.ts @@ -26,6 +26,10 @@ export class PowershellTerminalActivationFailedHandler implements ITerminalActiv } // Check if we can activate in Command Prompt. const activationCommands = await this.helper.getEnvironmentActivationCommands(TerminalShellType.commandPrompt, resource); + // tslint:disable-next-line:no-console + console.log('In powershellFailed.ts'); + // tslint:disable-next-line:no-console + console.log(activationCommands); if (!activationCommands || !Array.isArray(activationCommands) || activationCommands.length === 0) { return; } diff --git a/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts b/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts index 2f2ce9532403..2d87e876e9b1 100644 --- a/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts +++ b/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts @@ -16,6 +16,8 @@ export abstract class BaseActivationCommandProvider implements ITerminalActivati public abstract isShellSupported(targetShell: TerminalShellType): boolean; public getActivationCommands(resource: Uri | undefined, targetShell: TerminalShellType): Promise { const pythonPath = this.serviceContainer.get(IConfigurationService).getSettings(resource).pythonPath; + // tslint:disable-next-line:no-console + console.log('In baseActivation.ts', pythonPath); return this.getActivationCommandsForInterpreter(pythonPath, targetShell); } public abstract getActivationCommandsForInterpreter(pythonPath: string, targetShell: TerminalShellType): Promise; diff --git a/src/client/common/terminal/environmentActivationProviders/bash.ts b/src/client/common/terminal/environmentActivationProviders/bash.ts index 950caa798bf6..234a154bedf8 100644 --- a/src/client/common/terminal/environmentActivationProviders/bash.ts +++ b/src/client/common/terminal/environmentActivationProviders/bash.ts @@ -25,7 +25,7 @@ export class Bash extends BaseActivationCommandProvider { public async getActivationCommandsForInterpreter(pythonPath: string, targetShell: TerminalShellType): Promise { const scriptFile = await this.findScriptFile(pythonPath, this.getScriptsInOrderOfPreference(targetShell)); // tslint:disable-next-line:no-console - console.log('I am here'); + console.log('In bash.ts', pythonPath, '---', scriptFile, scriptFile.fileToCommandArgument()); if (!scriptFile) { // tslint:disable-next-line:no-console console.log('I should not be here'); diff --git a/src/client/common/terminal/helper.ts b/src/client/common/terminal/helper.ts index 41708be66388..e723c61b3e1e 100644 --- a/src/client/common/terminal/helper.ts +++ b/src/client/common/terminal/helper.ts @@ -91,6 +91,8 @@ export class TerminalHelper implements ITerminalHelper { if (isCondaEnvironment) { const condaActivationProvider = new CondaActivationCommandProvider(this.serviceContainer); const activationCommands = await condaActivationProvider.getActivationCommands(resource, terminalShellType); + // tslint:disable-next-line:no-console + console.log('In conda helper.ts', activationCommands); if (Array.isArray(activationCommands)) { return activationCommands; } @@ -102,6 +104,8 @@ export class TerminalHelper implements ITerminalHelper { for (const provider of supportedProviders) { const activationCommands = await provider.getActivationCommands(resource, terminalShellType); + // tslint:disable-next-line:no-console + console.log('In helper.ts', activationCommands); if (Array.isArray(activationCommands)) { return activationCommands; } diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index dd7ba68adda7..957dbe06c988 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -53,9 +53,9 @@ suite('Activation of Environments in Terminal', () => { async function testActivation(envPath){ await updateSetting('terminal.activateEnvironment', true, vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); await setPythonPathInWorkspaceRoot(envPath); - const pyPath = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders[0].uri); - // tslint:disable-next-line:no-console - console.log(`Set pythonPath to ${pyPath.inspect('pythonPath').workspaceFolderValue}`); + // const pyPath = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders[0].uri); + // // tslint:disable-next-line:no-console + // console.log(`Set pythonPath to ${pyPath.inspect('pythonPath').workspaceFolderValue}`); const terminal = vscode.window.createTerminal(); await sleep(waitTimeForActivation); terminal.sendText(`python ${file}`, true); From 66c5a2bf571c028bccabed3b2de2249e53fb5795 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 14 Dec 2018 16:13:30 -0800 Subject: [PATCH 24/33] Debugging promise resolve --- build/ci/templates/virtual_env_tests.yml | 10 ++++ src/client/common/terminal/activator/base.ts | 7 ++- .../activator/powershellFailedHandler.ts | 4 -- .../baseActivationProvider.ts | 2 - .../environmentActivationProviders/bash.ts | 4 -- src/client/common/terminal/helper.ts | 5 -- .../terminalActivation.testvirtualenvs.ts | 48 ++++++++++++++++--- 7 files changed, 56 insertions(+), 24 deletions(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 9f699d26bb87..a2a958e6cf25 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -173,6 +173,16 @@ jobs: condition: and(succeeded(), eq(variables['Platform'], 'Linux')) + - bash: | + echo "SHELL: $SHELL, shell: $shell, ARGV[0]: $0, PS1: $PS1, prompt: $prompt" + + if test -z "$(type -p)" ; then echo bash ; else echo sh ; fi + + displayName: 'Echo shell' + env: + DISPLAY: :10 + + - task: Npm@1 displayName: 'run $(TestSuiteName)' inputs: diff --git a/src/client/common/terminal/activator/base.ts b/src/client/common/terminal/activator/base.ts index ec3f3ea3893a..4a7f0528f531 100644 --- a/src/client/common/terminal/activator/base.ts +++ b/src/client/common/terminal/activator/base.ts @@ -17,11 +17,14 @@ export class BaseTerminalActivator implements ITerminalActivator { const deferred = createDeferred(); this.activatedTerminals.set(terminal, deferred.promise); const shellPath = this.helper.getTerminalShellPath(); + // // tslint:disable-next-line:no-console + // console.log(shellPath); + // const shellPath = '/usr/bin/bash'; const terminalShellType = !shellPath || shellPath.length === 0 ? TerminalShellType.other : this.helper.identifyTerminalShell(shellPath); - const activationCommamnds = await this.helper.getEnvironmentActivationCommands(terminalShellType, resource); // tslint:disable-next-line:no-console - console.log('Base.ts returned command', activationCommamnds); + console.log('in base.ts, terminalShellType', terminalShellType); + const activationCommamnds = await this.helper.getEnvironmentActivationCommands(terminalShellType, resource); let activated = false; if (activationCommamnds) { for (const command of activationCommamnds!) { diff --git a/src/client/common/terminal/activator/powershellFailedHandler.ts b/src/client/common/terminal/activator/powershellFailedHandler.ts index bdc3afde1d6c..a8ecba9f6da0 100644 --- a/src/client/common/terminal/activator/powershellFailedHandler.ts +++ b/src/client/common/terminal/activator/powershellFailedHandler.ts @@ -26,10 +26,6 @@ export class PowershellTerminalActivationFailedHandler implements ITerminalActiv } // Check if we can activate in Command Prompt. const activationCommands = await this.helper.getEnvironmentActivationCommands(TerminalShellType.commandPrompt, resource); - // tslint:disable-next-line:no-console - console.log('In powershellFailed.ts'); - // tslint:disable-next-line:no-console - console.log(activationCommands); if (!activationCommands || !Array.isArray(activationCommands) || activationCommands.length === 0) { return; } diff --git a/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts b/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts index 2d87e876e9b1..2f2ce9532403 100644 --- a/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts +++ b/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts @@ -16,8 +16,6 @@ export abstract class BaseActivationCommandProvider implements ITerminalActivati public abstract isShellSupported(targetShell: TerminalShellType): boolean; public getActivationCommands(resource: Uri | undefined, targetShell: TerminalShellType): Promise { const pythonPath = this.serviceContainer.get(IConfigurationService).getSettings(resource).pythonPath; - // tslint:disable-next-line:no-console - console.log('In baseActivation.ts', pythonPath); return this.getActivationCommandsForInterpreter(pythonPath, targetShell); } public abstract getActivationCommandsForInterpreter(pythonPath: string, targetShell: TerminalShellType): Promise; diff --git a/src/client/common/terminal/environmentActivationProviders/bash.ts b/src/client/common/terminal/environmentActivationProviders/bash.ts index 234a154bedf8..d330ec60d690 100644 --- a/src/client/common/terminal/environmentActivationProviders/bash.ts +++ b/src/client/common/terminal/environmentActivationProviders/bash.ts @@ -24,11 +24,7 @@ export class Bash extends BaseActivationCommandProvider { } public async getActivationCommandsForInterpreter(pythonPath: string, targetShell: TerminalShellType): Promise { const scriptFile = await this.findScriptFile(pythonPath, this.getScriptsInOrderOfPreference(targetShell)); - // tslint:disable-next-line:no-console - console.log('In bash.ts', pythonPath, '---', scriptFile, scriptFile.fileToCommandArgument()); if (!scriptFile) { - // tslint:disable-next-line:no-console - console.log('I should not be here'); return; } return [`source ${scriptFile.fileToCommandArgument()}`]; diff --git a/src/client/common/terminal/helper.ts b/src/client/common/terminal/helper.ts index e723c61b3e1e..f119ed80cf85 100644 --- a/src/client/common/terminal/helper.ts +++ b/src/client/common/terminal/helper.ts @@ -59,7 +59,6 @@ export class TerminalHelper implements ITerminalHelper { public getTerminalShellPath(): string { const workspace = this.serviceContainer.get(IWorkspaceService); const shellConfig = workspace.getConfiguration('terminal.integrated.shell'); - const platformService = this.serviceContainer.get(IPlatformService); let osSection = ''; if (platformService.isWindows) { @@ -91,8 +90,6 @@ export class TerminalHelper implements ITerminalHelper { if (isCondaEnvironment) { const condaActivationProvider = new CondaActivationCommandProvider(this.serviceContainer); const activationCommands = await condaActivationProvider.getActivationCommands(resource, terminalShellType); - // tslint:disable-next-line:no-console - console.log('In conda helper.ts', activationCommands); if (Array.isArray(activationCommands)) { return activationCommands; } @@ -104,8 +101,6 @@ export class TerminalHelper implements ITerminalHelper { for (const provider of supportedProviders) { const activationCommands = await provider.getActivationCommands(resource, terminalShellType); - // tslint:disable-next-line:no-console - console.log('In helper.ts', activationCommands); if (Array.isArray(activationCommands)) { return activationCommands; } diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 957dbe06c988..27d043d04a4f 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -5,6 +5,7 @@ import { expect } from 'chai'; import * as fs from 'fs-extra'; +import * as os from 'os'; import * as path from 'path'; import * as vscode from 'vscode'; import { PYTHON_VIRTUAL_ENVS_LOCATION } from '../../../ciConstants'; @@ -13,6 +14,7 @@ import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../../constants'; import { sleep } from '../../../core'; import { initialize, initializeTest } from '../../../initialize'; +// tslint:disable-next-line:max-func-body-length suite('Activation of Environments in Terminal', () => { const file = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.py'); const outputFile = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.log'); @@ -26,12 +28,17 @@ suite('Activation of Environments in Terminal', () => { virtualEnvPath: string; }; let envPaths: EnvPath; - let defaultShell; + const defaultShell = { + Windows: '', + Linux: '', + MacOS: '' + }; let terminalSettings; suiteSetup(async () => { envPaths = await fs.readJson(envsLocation); terminalSettings = vscode.workspace.getConfiguration('terminal', vscode.workspace.workspaceFolders[0].uri); - defaultShell = terminalSettings.inspect('integrated.shell.windows').globalValue; + defaultShell.Windows = terminalSettings.inspect('integrated.shell.windows').globalValue; + defaultShell.Linux = terminalSettings.inspect('integrated.shell.linux').globalValue; await initialize(); }); setup(async () => { @@ -42,7 +49,8 @@ suite('Activation of Environments in Terminal', () => { suiteTeardown(revertSettings); async function revertSettings() { await updateSetting('terminal.activateEnvironment', undefined , vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); - await terminalSettings.update('integrated.shell.windows', defaultShell, vscode.ConfigurationTarget.Global); + await terminalSettings.update('integrated.shell.windows', defaultShell.Windows, vscode.ConfigurationTarget.Global); + await terminalSettings.update('integrated.shell.linux', defaultShell.Linux, vscode.ConfigurationTarget.Global); await restorePythonPathInWorkspaceRoot(); } async function cleanUp() { @@ -51,17 +59,43 @@ suite('Activation of Environments in Terminal', () => { } } async function testActivation(envPath){ + // tslint:disable-next-line:no-console + console.log(`start1 ${envPath}`); await updateSetting('terminal.activateEnvironment', true, vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); + // tslint:disable-next-line:no-console + console.log('start2'); await setPythonPathInWorkspaceRoot(envPath); - // const pyPath = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders[0].uri); - // // tslint:disable-next-line:no-console - // console.log(`Set pythonPath to ${pyPath.inspect('pythonPath').workspaceFolderValue}`); + // tslint:disable-next-line:no-console + console.log('start3'); + const pyPath = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders[0].uri); + // tslint:disable-next-line:no-console + console.log(`Set pythonPath to ${pyPath.inspect('pythonPath').workspaceFolderValue}`); + if (os.platform() === 'linux'){ + // tslint:disable-next-line:no-console + console.log('OS is linux, updating terminal shell Path'); + await terminalSettings.update('integrated.shell.linux', '\\bin\\bash', vscode.ConfigurationTarget.Global); + } + // tslint:disable-next-line:no-console + console.log('Create terminal'); const terminal = vscode.window.createTerminal(); + // tslint:disable-next-line:no-console + console.log('Waiting for activation'); await sleep(waitTimeForActivation); + // tslint:disable-next-line:no-console + console.log('Done waiting for activation'); + // tslint:disable-next-line:no-console + console.log('Sending text'); terminal.sendText(`python ${file}`, true); + // tslint:disable-next-line:no-console + console.log('Waiting for output'); await waitForCondition(() => fs.pathExists(outputFile), 5_000, '\'testExecInTerminal.log\' file not created'); + // tslint:disable-next-line:no-console + console.log('Read output file'); const content = await fs.readFile(outputFile, 'utf-8'); - + // tslint:disable-next-line:no-console + console.log('Done Reading'); + // tslint:disable-next-line:no-console + console.log('Expect file content: ', content, 'to equal envPath: ', envPath); expect(content).to.equal(envPath); } async function testNonActivation(){ From ddb2caf2a49e0262d08d7aa0e73eddd8d605648e Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 18 Dec 2018 10:25:44 -0800 Subject: [PATCH 25/33] Correct linux shell path --- .../terminalActivation.testvirtualenvs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 27d043d04a4f..43f562deec6b 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -73,7 +73,7 @@ suite('Activation of Environments in Terminal', () => { if (os.platform() === 'linux'){ // tslint:disable-next-line:no-console console.log('OS is linux, updating terminal shell Path'); - await terminalSettings.update('integrated.shell.linux', '\\bin\\bash', vscode.ConfigurationTarget.Global); + await terminalSettings.update('integrated.shell.linux', '/bin/bash', vscode.ConfigurationTarget.Global); } // tslint:disable-next-line:no-console console.log('Create terminal'); From f9b452ff7a9f6122edcab67d65f495dc595cf8d5 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 18 Dec 2018 11:06:55 -0800 Subject: [PATCH 26/33] Testing conda env --- build/ci/templates/compile-and-validate.yml | 12 ++++++------ .../locators/services/condaService.ts | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/build/ci/templates/compile-and-validate.yml b/build/ci/templates/compile-and-validate.yml index d4a4b073ad8d..0ecb0ae9e434 100644 --- a/build/ci/templates/compile-and-validate.yml +++ b/build/ci/templates/compile-and-validate.yml @@ -131,14 +131,14 @@ jobs: customCommand: 'run cover:enable' - - task: Npm@1 - displayName: 'run test:unittests' - inputs: - command: custom + # - task: Npm@1 + # displayName: 'run test:unittests' + # inputs: + # command: custom - verbose: false + # verbose: false - customCommand: 'run test:unittests:cover' + # customCommand: 'run test:unittests:cover' - bash: 'bash <(curl -s https://codecov.io/bash) -t $(COV_UUID)' diff --git a/src/client/interpreter/locators/services/condaService.ts b/src/client/interpreter/locators/services/condaService.ts index 520fc228c98b..bc54c400efcf 100644 --- a/src/client/interpreter/locators/services/condaService.ts +++ b/src/client/interpreter/locators/services/condaService.ts @@ -96,6 +96,8 @@ export class CondaService implements ICondaService { } // tslint:disable-next-line:no-unnecessary-local-variable const condaFile = await this.condaFile!; + // tslint:disable-next-line:no-console + console.log('condaFile ', condaFile); return condaFile!; } @@ -435,6 +437,8 @@ export class CondaService implements ICondaService { * Return the path to the "conda file", if there is one (in known locations). */ private async getCondaFileImpl() { + // tslint:disable-next-line:no-console + console.log('In getCondaFileImpl()'); const settings = this.configService.getSettings(); const setting = settings.condaPath; @@ -442,10 +446,12 @@ export class CondaService implements ICondaService { return setting; } - const isAvailable = await this.isCondaInCurrentPath(); - if (isAvailable) { - return 'conda'; - } + // const isAvailable = await this.isCondaInCurrentPath(); + // if (isAvailable) { + // // tslint:disable-next-line:no-console + // console.log('We found conda in current path'); + // return 'conda'; + // } if (this.platform.isWindows && this.registryLookupForConda) { const interpreters = await this.registryLookupForConda.getInterpreters(); const condaInterpreters = interpreters.filter(this.detectCondaEnvironment); @@ -463,6 +469,8 @@ export class CondaService implements ICondaService { * Note: For now we simply return the first one found. */ private async getCondaFileFromKnownLocations(): Promise { + // tslint:disable-next-line:no-console + console.log('Inside getCondaFileFromKnownLocations'); const globPattern = this.platform.isWindows ? CondaLocationsGlobWin : CondaLocationsGlob; const condaFiles = await this.fileSystem.search(globPattern) .catch((failReason) => { From 5c40164899e40bda46f8d7e65d79357efb7f5091 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 18 Dec 2018 12:46:12 -0800 Subject: [PATCH 27/33] Adding more debug statements --- src/client/interpreter/locators/services/condaService.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/interpreter/locators/services/condaService.ts b/src/client/interpreter/locators/services/condaService.ts index bc54c400efcf..d5c23669a691 100644 --- a/src/client/interpreter/locators/services/condaService.ts +++ b/src/client/interpreter/locators/services/condaService.ts @@ -472,6 +472,8 @@ export class CondaService implements ICondaService { // tslint:disable-next-line:no-console console.log('Inside getCondaFileFromKnownLocations'); const globPattern = this.platform.isWindows ? CondaLocationsGlobWin : CondaLocationsGlob; + // tslint:disable-next-line:no-console + console.log('globPattern', globPattern); const condaFiles = await this.fileSystem.search(globPattern) .catch((failReason) => { Logger.warn( @@ -480,7 +482,11 @@ export class CondaService implements ICondaService { ); return []; }); + // tslint:disable-next-line:no-console + console.log('condafiles', condaFiles); const validCondaFiles = condaFiles.filter(condaPath => condaPath.length > 0); + // tslint:disable-next-line:no-console + console.log('validCondaFiles', validCondaFiles); return validCondaFiles.length === 0 ? 'conda' : validCondaFiles[0]; } From eb2f7d97999fd28513b9d94c6947d3bb4ee60aa4 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 18 Dec 2018 13:18:32 -0800 Subject: [PATCH 28/33] Added /usr/share/miniconda to GlobPattern --- src/client/interpreter/locators/services/condaService.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client/interpreter/locators/services/condaService.ts b/src/client/interpreter/locators/services/condaService.ts index d5c23669a691..745df79d7ba7 100644 --- a/src/client/interpreter/locators/services/condaService.ts +++ b/src/client/interpreter/locators/services/condaService.ts @@ -25,7 +25,13 @@ const untildify: (value: string) => string = require('untildify'); // This glob pattern will match all of the following: // ~/anaconda/bin/conda, ~/anaconda3/bin/conda, ~/miniconda/bin/conda, ~/miniconda3/bin/conda -export const CondaLocationsGlob = untildify('~/*conda*/bin/conda'); +// /usr/share/anaconda/bin/conda, /usr/share/anaconda3/bin/conda, /usr/share/miniconda/bin/conda, /usr/share/miniconda3/bin/conda + +const condaGlobPathsForLinux = [ + '/usr/share/*conda*/bin/conda', + untildify('~/*conda*/bin/conda')]; + +export const CondaLocationsGlob = `{${condaGlobPathsForLinux.join(',')}}`; // ...and for windows, the known default install locations: const condaGlobPathsForWindows = [ From 53f846d75f03221332ec50c6d5d7665553749ec4 Mon Sep 17 00:00:00 2001 From: Derek Keeler Date: Tue, 18 Dec 2018 17:00:45 -0800 Subject: [PATCH 29/33] Add some more logging --- .../locators/services/condaService.ts | 30 +++++++++---------- .../terminalActivation.testvirtualenvs.ts | 26 ++++++++++++---- .../smokeTests/testExecInTerminal2.py | 10 +++++++ 3 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 src/testMultiRootWkspc/smokeTests/testExecInTerminal2.py diff --git a/src/client/interpreter/locators/services/condaService.ts b/src/client/interpreter/locators/services/condaService.ts index 745df79d7ba7..d5a7e8951835 100644 --- a/src/client/interpreter/locators/services/condaService.ts +++ b/src/client/interpreter/locators/services/condaService.ts @@ -58,9 +58,9 @@ export class CondaService implements ICondaService { private condaFile!: Promise; private isAvailable: boolean | undefined; private readonly condaHelper = new CondaHelper(); - private activatedEnvironmentCache : { [key: string] : NodeJS.ProcessEnv } = {}; - private activationProvider : ITerminalActivationCommandProvider; - private shellType : TerminalShellType; + private activatedEnvironmentCache: { [key: string]: NodeJS.ProcessEnv } = {}; + private activationProvider: ITerminalActivationCommandProvider; + private shellType: TerminalShellType; constructor( @inject(IProcessServiceFactory) private processServiceFactory: IProcessServiceFactory, @@ -288,10 +288,10 @@ export class CondaService implements ICondaService { const activateCommands = this.activationProvider.getActivationCommandsForInterpreter ? await this.activationProvider.getActivationCommandsForInterpreter(condaPath, this.shellType) : this.platform.isWindows ? - [`"${path.join(path.dirname(condaPath), 'activate')}"`] : - [`. "${path.join(path.dirname(condaPath), 'activate')}"`]; + [`"${path.join(path.dirname(condaPath), 'activate')}"`] : + [`. "${path.join(path.dirname(condaPath), 'activate')}"`]; - const result = {...input}; + const result = { ...input }; const processService = await this.processServiceFactory.create(); // Run the activate command collect the environment from it. @@ -341,7 +341,7 @@ export class CondaService implements ICondaService { } private parseEnvironmentOutput(output: string, result: NodeJS.ProcessEnv) { - const lines = output.splitLines({trim: true, removeEmptyEntries: true}); + const lines = output.splitLines({ trim: true, removeEmptyEntries: true }); let foundDummyOutput = false; for (let i = 0; i < lines.length; i += 1) { if (foundDummyOutput) { @@ -403,7 +403,7 @@ export class CondaService implements ICondaService { } } - private async getCondaFileFromInterpreter(interpreter: PythonInterpreter | undefined) : Promise { + private async getCondaFileFromInterpreter(interpreter: PythonInterpreter | undefined): Promise { const condaExe = this.platform.isWindows ? 'conda.exe' : 'conda'; const scriptsDir = this.platform.isWindows ? 'Scripts' : 'bin'; const interpreterDir = interpreter ? path.dirname(interpreter.path) : ''; @@ -452,12 +452,12 @@ export class CondaService implements ICondaService { return setting; } - // const isAvailable = await this.isCondaInCurrentPath(); - // if (isAvailable) { - // // tslint:disable-next-line:no-console - // console.log('We found conda in current path'); - // return 'conda'; - // } + const isAvailable = await this.isCondaInCurrentPath(); + if (isAvailable) { + // tslint:disable-next-line:no-console + console.log('We found conda in current path'); + return 'conda'; + } if (this.platform.isWindows && this.registryLookupForConda) { const interpreters = await this.registryLookupForConda.getInterpreters(); const condaInterpreters = interpreters.filter(this.detectCondaEnvironment); @@ -499,7 +499,7 @@ export class CondaService implements ICondaService { /** * Called when the user changes the current interpreter. */ - private onInterpreterChanged() : void { + private onInterpreterChanged(): void { // Clear our activated environment cache as it can't match the current one anymore this.activatedEnvironmentCache = {}; } diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 43f562deec6b..ba21d75ed1bc 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -18,8 +18,10 @@ import { initialize, initializeTest } from '../../../initialize'; suite('Activation of Environments in Terminal', () => { const file = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.py'); const outputFile = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.log'); + const file2 = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal2.py'); + const outputFile2 = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal2.log'); const envsLocation = PYTHON_VIRTUAL_ENVS_LOCATION !== undefined ? - path.join(EXTENSION_ROOT_DIR_FOR_TESTS, PYTHON_VIRTUAL_ENVS_LOCATION) : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); + path.join(EXTENSION_ROOT_DIR_FOR_TESTS, PYTHON_VIRTUAL_ENVS_LOCATION) : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); const waitTimeForActivation = 5000; type EnvPath = { condaPath: string; @@ -34,9 +36,11 @@ suite('Activation of Environments in Terminal', () => { MacOS: '' }; let terminalSettings; + let pythonSettings; suiteSetup(async () => { envPaths = await fs.readJson(envsLocation); terminalSettings = vscode.workspace.getConfiguration('terminal', vscode.workspace.workspaceFolders[0].uri); + pythonSettings = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders[0].uri); defaultShell.Windows = terminalSettings.inspect('integrated.shell.windows').globalValue; defaultShell.Linux = terminalSettings.inspect('integrated.shell.linux').globalValue; await initialize(); @@ -48,7 +52,7 @@ suite('Activation of Environments in Terminal', () => { teardown(cleanUp); suiteTeardown(revertSettings); async function revertSettings() { - await updateSetting('terminal.activateEnvironment', undefined , vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); + await updateSetting('terminal.activateEnvironment', undefined, vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); await terminalSettings.update('integrated.shell.windows', defaultShell.Windows, vscode.ConfigurationTarget.Global); await terminalSettings.update('integrated.shell.linux', defaultShell.Linux, vscode.ConfigurationTarget.Global); await restorePythonPathInWorkspaceRoot(); @@ -58,7 +62,8 @@ suite('Activation of Environments in Terminal', () => { await fs.unlink(outputFile); } } - async function testActivation(envPath){ + + async function testActivation(envPath) { // tslint:disable-next-line:no-console console.log(`start1 ${envPath}`); await updateSetting('terminal.activateEnvironment', true, vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); @@ -70,7 +75,7 @@ suite('Activation of Environments in Terminal', () => { const pyPath = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders[0].uri); // tslint:disable-next-line:no-console console.log(`Set pythonPath to ${pyPath.inspect('pythonPath').workspaceFolderValue}`); - if (os.platform() === 'linux'){ + if (os.platform() === 'linux') { // tslint:disable-next-line:no-console console.log('OS is linux, updating terminal shell Path'); await terminalSettings.update('integrated.shell.linux', '/bin/bash', vscode.ConfigurationTarget.Global); @@ -89,6 +94,8 @@ suite('Activation of Environments in Terminal', () => { // tslint:disable-next-line:no-console console.log('Waiting for output'); await waitForCondition(() => fs.pathExists(outputFile), 5_000, '\'testExecInTerminal.log\' file not created'); + terminal.sendText(`python ${file2}`, true); + await waitForCondition(() => fs.pathExists(outputFile2), 5_000, '\'testExecInTerminal2.log\' file not created'); // tslint:disable-next-line:no-console console.log('Read output file'); const content = await fs.readFile(outputFile, 'utf-8'); @@ -96,9 +103,16 @@ suite('Activation of Environments in Terminal', () => { console.log('Done Reading'); // tslint:disable-next-line:no-console console.log('Expect file content: ', content, 'to equal envPath: ', envPath); + + const extraContent = await fs.readFile(outputFile2, 'utf-8'); + const xtraLines = extraContent.splitLines({ trim: true }); + + // tslint:disable-next-line:no-console + xtraLines.forEach((ln: string) => console.log(ln)); + expect(content).to.equal(envPath); } - async function testNonActivation(){ + async function testNonActivation() { await updateSetting('terminal.activateEnvironment', false, vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); const terminal = vscode.window.createTerminal(); terminal.sendText(`python ${file}`, true); @@ -120,6 +134,8 @@ suite('Activation of Environments in Terminal', () => { }); test('Should activate with conda', async () => { await terminalSettings.update('integrated.shell.windows', 'C:\\Windows\\System32\\cmd.exe', vscode.ConfigurationTarget.Global); + + await pythonSettings.update('condaPath', '/opt/python/versions/miniconda3/bin/conda', vscode.ConfigurationTarget.Global); await testActivation(envPaths.condaPath); }); }); diff --git a/src/testMultiRootWkspc/smokeTests/testExecInTerminal2.py b/src/testMultiRootWkspc/smokeTests/testExecInTerminal2.py new file mode 100644 index 000000000000..4671e279064b --- /dev/null +++ b/src/testMultiRootWkspc/smokeTests/testExecInTerminal2.py @@ -0,0 +1,10 @@ +import sys +import os + + +log_file = os.path.splitext(sys.argv[0])[0] + '.log' +with open(log_file, "w") as outfile: + outfile.write('Env Vars:\n') + for k in os.environ.keys(): + outfile.write(f'{k}: {os.environ[k]}\n') + From 9c4aa62c7fc980ce1822c6c338555332f2605032 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 19 Dec 2018 11:08:23 -0800 Subject: [PATCH 30/33] Using conda executable path instead of conda python path --- build/ci/addEnvPath.py | 5 ++++- build/ci/templates/virtual_env_tests.yml | 4 ++++ .../terminalActivation.testvirtualenvs.ts | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/build/ci/addEnvPath.py b/build/ci/addEnvPath.py index b1e8eb052353..abad9ec3b5c9 100644 --- a/build/ci/addEnvPath.py +++ b/build/ci/addEnvPath.py @@ -19,5 +19,8 @@ data = {} data = {} with open(jsonPath, 'w') as outfile: - data[key] = sys.executable + if key == 'condaExecPath': + data[key] = sys.argv[3] + else: + data[key] = sys.executable json.dump(data, outfile, sort_keys=True, indent=4) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index a2a958e6cf25..b8e6a0ed159c 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -133,13 +133,17 @@ jobs: Write-Host $Env:PYTHON_VIRTUAL_ENVS_LOCATION if( '$(platform)' -eq 'Linux' ){ $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath python + $condaExecPath = which conda }else { $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python + $condaExecPath = which conda } & $condaPythonPath ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) condaPath + & $condaPythonPath ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) condaExecPath $condaExecPath + Get-Content $Env:PYTHON_VIRTUAL_ENVS_LOCATION displayName: 'Save conda environment executable' diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index ba21d75ed1bc..189b22d7800b 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -24,6 +24,7 @@ suite('Activation of Environments in Terminal', () => { path.join(EXTENSION_ROOT_DIR_FOR_TESTS, PYTHON_VIRTUAL_ENVS_LOCATION) : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); const waitTimeForActivation = 5000; type EnvPath = { + condaExecPath: string; condaPath: string; venvPath: string; pipenvPath: string; @@ -75,6 +76,8 @@ suite('Activation of Environments in Terminal', () => { const pyPath = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders[0].uri); // tslint:disable-next-line:no-console console.log(`Set pythonPath to ${pyPath.inspect('pythonPath').workspaceFolderValue}`); + // tslint:disable-next-line:no-console + console.log(`Set condaPath to ${pyPath.inspect('condaPath').workspaceFolderValue}`); if (os.platform() === 'linux') { // tslint:disable-next-line:no-console console.log('OS is linux, updating terminal shell Path'); @@ -134,8 +137,7 @@ suite('Activation of Environments in Terminal', () => { }); test('Should activate with conda', async () => { await terminalSettings.update('integrated.shell.windows', 'C:\\Windows\\System32\\cmd.exe', vscode.ConfigurationTarget.Global); - - await pythonSettings.update('condaPath', '/opt/python/versions/miniconda3/bin/conda', vscode.ConfigurationTarget.Global); + await pythonSettings.update('condaPath', envPaths.condaExecPath, vscode.ConfigurationTarget.Workspace); await testActivation(envPaths.condaPath); }); }); From 65d5b57bb2e0a9e6a6d8fa4e0065459fe85f418c Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 19 Dec 2018 12:42:38 -0800 Subject: [PATCH 31/33] Added event handler for condaPath setting --- build/ci/templates/virtual_env_tests.yml | 4 ++-- .../locators/services/condaService.ts | 16 ++++++++++++++++ src/test/interpreters/condaService.unit.test.ts | 7 ++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index b8e6a0ed159c..ed31e7c12783 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -133,11 +133,11 @@ jobs: Write-Host $Env:PYTHON_VIRTUAL_ENVS_LOCATION if( '$(platform)' -eq 'Linux' ){ $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath python - $condaExecPath = which conda + $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath conda }else { $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python - $condaExecPath = which conda + $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath conda } & $condaPythonPath ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) condaPath diff --git a/src/client/interpreter/locators/services/condaService.ts b/src/client/interpreter/locators/services/condaService.ts index d5a7e8951835..ea819f68b066 100644 --- a/src/client/interpreter/locators/services/condaService.ts +++ b/src/client/interpreter/locators/services/condaService.ts @@ -2,6 +2,8 @@ import { inject, injectable, named, optional } from 'inversify'; import * as path from 'path'; import { parse, SemVer } from 'semver'; +import { ConfigurationChangeEvent, Uri } from 'vscode'; +import { IWorkspaceService } from '../../../common/application/types'; import { Logger } from '../../../common/logger'; import { IFileSystem, IPlatformService } from '../../../common/platform/types'; import { ExecutionResult, IProcessServiceFactory } from '../../../common/process/types'; @@ -72,12 +74,14 @@ export class CondaService implements ICondaService { @inject(IInterpreterService) private interpreterService: IInterpreterService, @inject(IDisposableRegistry) private disposableRegistry: IDisposableRegistry, @inject(IServiceContainer) serviceContainer: IServiceContainer, + @inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService, @inject(IInterpreterLocatorService) @named(WINDOWS_REGISTRY_SERVICE) @optional() private registryLookupForConda?: IInterpreterLocatorService ) { this.disposableRegistry.push(this.interpreterService.onDidChangeInterpreter(this.onInterpreterChanged.bind(this))); this.activationProvider = serviceContainer.get(ITerminalActivationCommandProvider, this.platform.isWindows ? 'commandPromptAndPowerShell' : 'bashCShellFish'); this.shellType = this.platform.isWindows ? TerminalShellType.commandPrompt : TerminalShellType.bash; // Defaults for Child_Process.exec + this.addCondaPathChangedHandler(); } public get condaEnvironmentsFile(): string | undefined { @@ -439,6 +443,18 @@ export class CondaService implements ICondaService { } } + private addCondaPathChangedHandler() { + const disposable = this.workspaceService.onDidChangeConfiguration(this.onDidChangeConfiguration.bind(this)); + this.disposableRegistry.push(disposable); + } + private async onDidChangeConfiguration(event: ConfigurationChangeEvent) { + const workspacesUris: (Uri | undefined)[] = this.workspaceService.hasWorkspaceFolders ? this.workspaceService.workspaceFolders!.map(workspace => workspace.uri) : [undefined]; + if (workspacesUris.findIndex(uri => event.affectsConfiguration('python.condaPath', uri)) === -1) { + return; + } + this.condaFile = undefined; + } + /** * Return the path to the "conda file", if there is one (in known locations). */ diff --git a/src/test/interpreters/condaService.unit.test.ts b/src/test/interpreters/condaService.unit.test.ts index d7f126f0f567..6b356592ac29 100644 --- a/src/test/interpreters/condaService.unit.test.ts +++ b/src/test/interpreters/condaService.unit.test.ts @@ -7,6 +7,7 @@ import { parse } from 'semver'; import * as TypeMoq from 'typemoq'; import { Disposable, EventEmitter } from 'vscode'; +import { IWorkspaceService } from '../../client/common/application/types'; import { FileSystem } from '../../client/common/platform/fileSystem'; import { IFileSystem, IPlatformService } from '../../client/common/platform/types'; import { IProcessService, IProcessServiceFactory } from '../../client/common/process/types'; @@ -56,6 +57,7 @@ suite('Interpreters Conda Service', () => { let interpreterService: TypeMoq.IMock; let mockState : MockState; let terminalProvider : TypeMoq.IMock; + let workspaceService : TypeMoq.IMock; setup(async () => { condaPathSetting = ''; logger = TypeMoq.Mock.ofType(); @@ -65,6 +67,7 @@ suite('Interpreters Conda Service', () => { interpreterService = TypeMoq.Mock.ofType(); registryInterpreterLocatorService = TypeMoq.Mock.ofType(); fileSystem = TypeMoq.Mock.ofType(); + workspaceService = TypeMoq.Mock.ofType(); config = TypeMoq.Mock.ofType(); settings = TypeMoq.Mock.ofType(); procServiceFactory = TypeMoq.Mock.ofType(); @@ -105,6 +108,7 @@ suite('Interpreters Conda Service', () => { interpreterService.object, disposableRegistry, serviceContainer.object, + workspaceService.object, registryInterpreterLocatorService.object); }); @@ -395,7 +399,8 @@ suite('Interpreters Conda Service', () => { logger.object, interpreterService.object, disposableRegistry, - serviceContainer.object); + serviceContainer.object, + workspaceService.object); const result = await condaSrv.getCondaFile(); expect(result).is.equal(expected); From 0cd6e2f9804b351f7f61f56e5ca091bc96d27695 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 19 Dec 2018 13:53:12 -0800 Subject: [PATCH 32/33] Added macOS --- build/ci/templates/virtual_env_tests.yml | 6 +++++- build/ci/vscode-python-pr-validation.yaml | 23 +++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index ed31e7c12783..551569236528 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -135,7 +135,11 @@ jobs: $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath python $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath conda - }else { + } elseif( '$(platform)' -eq 'macOS' ){ + $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath python + $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath conda + + } else { $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath conda } diff --git a/build/ci/vscode-python-pr-validation.yaml b/build/ci/vscode-python-pr-validation.yaml index 20489e01ca17..10e729ef2225 100644 --- a/build/ci/vscode-python-pr-validation.yaml +++ b/build/ci/vscode-python-pr-validation.yaml @@ -33,22 +33,37 @@ jobs: # TestSuiteName: 'testSingleWorkspace' +# - template: templates/virtual_env_tests.yml +# parameters: +# name: 'VirtualEnv_Tests_Linux_py37' +# PythonVersion: '3.7' +# NodeVersion: '8.11.2' +# NpmVersion: 'latest' +# AzureStorageAccountName: 'vscodepythonci' +# AzureStorageContainerName: 'vscode-python-ci' +# Platform: 'Linux' +# PoolName: 'Hosted Ubuntu 1604' +# EnvironmentExecutableFolder: 'bin' +# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' +# TEST_FILES_SUFFIX: 'testvirtualenvs' +# TestSuiteName: 'testSingleWorkspace' + + - template: templates/virtual_env_tests.yml parameters: - name: 'VirtualEnv_Tests_Linux_py37' + name: 'VirtualEnv_Tests_MacOS_py37' PythonVersion: '3.7' NodeVersion: '8.11.2' NpmVersion: 'latest' AzureStorageAccountName: 'vscodepythonci' AzureStorageContainerName: 'vscode-python-ci' - Platform: 'Linux' - PoolName: 'Hosted Ubuntu 1604' + Platform: 'macOS' + PoolName: 'Hosted macOS' EnvironmentExecutableFolder: 'bin' PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' TEST_FILES_SUFFIX: 'testvirtualenvs' TestSuiteName: 'testSingleWorkspace' - # - job: 'System_Test_macOS' # dependsOn: 'PR_Validate_Windows_py37' # pool: From ff6d574809764b57fb3050e83021530e060a6a6a Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 19 Dec 2018 14:30:21 -0800 Subject: [PATCH 33/33] Clean up --- build/ci/templates/compile-and-validate.yml | 12 +- build/ci/templates/virtual_env_tests.yml | 24 +- build/ci/vscode-python-pr-validation.yaml | 326 +++++++++--------- src/client/common/terminal/activator/base.ts | 7 - .../locators/services/condaService.ts | 14 - .../terminalActivation.testvirtualenvs.ts | 46 +-- .../smokeTests/testExecInTerminal2.py | 10 - 7 files changed, 176 insertions(+), 263 deletions(-) delete mode 100644 src/testMultiRootWkspc/smokeTests/testExecInTerminal2.py diff --git a/build/ci/templates/compile-and-validate.yml b/build/ci/templates/compile-and-validate.yml index 0ecb0ae9e434..d4a4b073ad8d 100644 --- a/build/ci/templates/compile-and-validate.yml +++ b/build/ci/templates/compile-and-validate.yml @@ -131,14 +131,14 @@ jobs: customCommand: 'run cover:enable' - # - task: Npm@1 - # displayName: 'run test:unittests' - # inputs: - # command: custom + - task: Npm@1 + displayName: 'run test:unittests' + inputs: + command: custom - # verbose: false + verbose: false - # customCommand: 'run test:unittests:cover' + customCommand: 'run test:unittests:cover' - bash: 'bash <(curl -s https://codecov.io/bash) -t $(COV_UUID)' diff --git a/build/ci/templates/virtual_env_tests.yml b/build/ci/templates/virtual_env_tests.yml index 551569236528..908287f04cbc 100644 --- a/build/ci/templates/virtual_env_tests.yml +++ b/build/ci/templates/virtual_env_tests.yml @@ -128,20 +128,16 @@ jobs: - powershell: | Write-Host $Env:CONDA - Write-Host $Env:environmentExecutableFolder - Write-Host $Env:EnvironmentExecutableFolder Write-Host $Env:PYTHON_VIRTUAL_ENVS_LOCATION - if( '$(platform)' -eq 'Linux' ){ - $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath python - $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath conda - } elseif( '$(platform)' -eq 'macOS' ){ + if( '$(platform)' -eq 'Windows' ){ + $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python + $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath conda + + } else{ $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath python $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath conda - } else { - $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python - $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath conda } & $condaPythonPath ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) condaPath @@ -181,16 +177,6 @@ jobs: condition: and(succeeded(), eq(variables['Platform'], 'Linux')) - - bash: | - echo "SHELL: $SHELL, shell: $shell, ARGV[0]: $0, PS1: $PS1, prompt: $prompt" - - if test -z "$(type -p)" ; then echo bash ; else echo sh ; fi - - displayName: 'Echo shell' - env: - DISPLAY: :10 - - - task: Npm@1 displayName: 'run $(TestSuiteName)' inputs: diff --git a/build/ci/vscode-python-pr-validation.yaml b/build/ci/vscode-python-pr-validation.yaml index 10e729ef2225..bc1b0a1dba0a 100644 --- a/build/ci/vscode-python-pr-validation.yaml +++ b/build/ci/vscode-python-pr-validation.yaml @@ -17,36 +17,36 @@ jobs: AzureStorageContainerName: 'vscode-python-ci' -# - template: templates/virtual_env_tests.yml -# parameters: -# name: 'VirtualEnv_Tests_Windows_py37' -# PythonVersion: '3.7' -# NodeVersion: '8.11.2' -# NpmVersion: 'latest' -# AzureStorageAccountName: 'vscodepythonci' -# AzureStorageContainerName: 'vscode-python-ci' -# Platform: 'Windows' -# PoolName: 'Hosted VS2017' -# EnvironmentExecutableFolder: 'Scripts' -# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' -# TEST_FILES_SUFFIX: 'testvirtualenvs' -# TestSuiteName: 'testSingleWorkspace' +- template: templates/virtual_env_tests.yml + parameters: + name: 'VirtualEnv_Tests_Windows_py37' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' + Platform: 'Windows' + PoolName: 'Hosted VS2017' + EnvironmentExecutableFolder: 'Scripts' + PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' + TEST_FILES_SUFFIX: 'testvirtualenvs' + TestSuiteName: 'testSingleWorkspace' -# - template: templates/virtual_env_tests.yml -# parameters: -# name: 'VirtualEnv_Tests_Linux_py37' -# PythonVersion: '3.7' -# NodeVersion: '8.11.2' -# NpmVersion: 'latest' -# AzureStorageAccountName: 'vscodepythonci' -# AzureStorageContainerName: 'vscode-python-ci' -# Platform: 'Linux' -# PoolName: 'Hosted Ubuntu 1604' -# EnvironmentExecutableFolder: 'bin' -# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' -# TEST_FILES_SUFFIX: 'testvirtualenvs' -# TestSuiteName: 'testSingleWorkspace' +- template: templates/virtual_env_tests.yml + parameters: + name: 'VirtualEnv_Tests_Linux_py37' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' + Platform: 'Linux' + PoolName: 'Hosted Ubuntu 1604' + EnvironmentExecutableFolder: 'bin' + PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' + TEST_FILES_SUFFIX: 'testvirtualenvs' + TestSuiteName: 'testSingleWorkspace' - template: templates/virtual_env_tests.yml @@ -64,142 +64,142 @@ jobs: TEST_FILES_SUFFIX: 'testvirtualenvs' TestSuiteName: 'testSingleWorkspace' -# - job: 'System_Test_macOS' -# dependsOn: 'PR_Validate_Windows_py37' -# pool: -# name: 'Hosted macOS' -# steps: -# - template: templates/test-phase.yml -# strategy: -# maxParallel: 3 -# matrix: -# SingleWorkspace: -# TestSuiteName: 'testSingleWorkspace' -# BuildNumber: '$(Build.BuildNumber)' -# Platform: 'macOS' -# PythonVersion: '3.7' -# NodeVersion: '8.11.2' -# NpmVersion: 'latest' -# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' -# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' -# MOCHA_REPORTER_JUNIT: true -# AzureStorageAccountName: 'vscodepythonci' -# AzureStorageContainerName: 'vscode-python-ci' -# MultiWorkspace: -# TestSuiteName: 'testMultiWorkspace' -# BuildNumber: '$(Build.BuildNumber)' -# Platform: 'macOS' -# PythonVersion: '3.7' -# NodeVersion: '8.11.2' -# NpmVersion: 'latest' -# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' -# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' -# MOCHA_REPORTER_JUNIT: true -# AzureStorageAccountName: 'vscodepythonci' -# AzureStorageContainerName: 'vscode-python-ci' -# Debugger: -# TestSuiteName: 'testDebugger' -# BuildNumber: '$(Build.BuildNumber)' -# Platform: 'macOS' -# PythonVersion: '3.7' -# NodeVersion: '8.11.2' -# NpmVersion: 'latest' -# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' -# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' -# MOCHA_REPORTER_JUNIT: true -# AzureStorageAccountName: 'vscodepythonci' -# AzureStorageContainerName: 'vscode-python-ci' +- job: 'System_Test_macOS' + dependsOn: 'PR_Validate_Windows_py37' + pool: + name: 'Hosted macOS' + steps: + - template: templates/test-phase.yml + strategy: + maxParallel: 3 + matrix: + SingleWorkspace: + TestSuiteName: 'testSingleWorkspace' + BuildNumber: '$(Build.BuildNumber)' + Platform: 'macOS' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' + MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' + MOCHA_REPORTER_JUNIT: true + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' + MultiWorkspace: + TestSuiteName: 'testMultiWorkspace' + BuildNumber: '$(Build.BuildNumber)' + Platform: 'macOS' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' + MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' + MOCHA_REPORTER_JUNIT: true + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' + Debugger: + TestSuiteName: 'testDebugger' + BuildNumber: '$(Build.BuildNumber)' + Platform: 'macOS' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' + MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' + MOCHA_REPORTER_JUNIT: true + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' -# - job: 'System_Test_Windows' -# dependsOn: 'PR_Validate_Windows_py37' -# pool: -# name: 'Hosted VS2017' -# steps: -# - template: templates/test-phase.yml -# strategy: -# maxParallel: 3 -# matrix: -# SingleWorkspace: -# TestSuiteName: 'testSingleWorkspace' -# BuildNumber: '$(Build.BuildNumber)' -# Platform: 'Windows' -# PythonVersion: '3.7' -# NodeVersion: '8.11.2' -# NpmVersion: 'latest' -# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' -# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' -# MOCHA_REPORTER_JUNIT: true -# AzureStorageAccountName: 'vscodepythonci' -# AzureStorageContainerName: 'vscode-python-ci' -# MultiWorkspace: -# TestSuiteName: 'testMultiWorkspace' -# BuildNumber: '$(Build.BuildNumber)' -# Platform: 'Windows' -# PythonVersion: '3.7' -# NodeVersion: '8.11.2' -# NpmVersion: 'latest' -# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' -# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' -# MOCHA_REPORTER_JUNIT: true -# AzureStorageAccountName: 'vscodepythonci' -# AzureStorageContainerName: 'vscode-python-ci' -# Debugger: -# TestSuiteName: 'testDebugger' -# BuildNumber: '$(Build.BuildNumber)' -# Platform: 'Windows' -# PythonVersion: '3.7' -# NodeVersion: '8.11.2' -# NpmVersion: 'latest' -# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' -# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' -# MOCHA_REPORTER_JUNIT: true -# AzureStorageAccountName: 'vscodepythonci' -# AzureStorageContainerName: 'vscode-python-ci' +- job: 'System_Test_Windows' + dependsOn: 'PR_Validate_Windows_py37' + pool: + name: 'Hosted VS2017' + steps: + - template: templates/test-phase.yml + strategy: + maxParallel: 3 + matrix: + SingleWorkspace: + TestSuiteName: 'testSingleWorkspace' + BuildNumber: '$(Build.BuildNumber)' + Platform: 'Windows' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' + MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' + MOCHA_REPORTER_JUNIT: true + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' + MultiWorkspace: + TestSuiteName: 'testMultiWorkspace' + BuildNumber: '$(Build.BuildNumber)' + Platform: 'Windows' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' + MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' + MOCHA_REPORTER_JUNIT: true + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' + Debugger: + TestSuiteName: 'testDebugger' + BuildNumber: '$(Build.BuildNumber)' + Platform: 'Windows' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' + MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' + MOCHA_REPORTER_JUNIT: true + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' -# - job: 'System_Test_Run_Linux' -# dependsOn: 'PR_Validate_Windows_py37' -# pool: -# name: 'Hosted Ubuntu 1604' -# steps: -# - template: templates/test-phase.yml -# strategy: -# maxParallel: 10 -# matrix: -# SingleWorkspace: -# TestSuiteName: 'testSingleWorkspace' -# BuildNumber: '$(Build.BuildNumber)' -# Platform: 'Linux' -# PythonVersion: '3.7' -# NodeVersion: '8.11.2' -# NpmVersion: 'latest' -# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' -# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' -# MOCHA_REPORTER_JUNIT: true -# AzureStorageAccountName: 'vscodepythonci' -# AzureStorageContainerName: 'vscode-python-ci' -# MultiWorkspace: -# TestSuiteName: 'testMultiWorkspace' -# BuildNumber: '$(Build.BuildNumber)' -# Platform: 'Linux' -# PythonVersion: '3.7' -# NodeVersion: '8.11.2' -# NpmVersion: 'latest' -# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' -# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' -# MOCHA_REPORTER_JUNIT: true -# AzureStorageAccountName: 'vscodepythonci' -# AzureStorageContainerName: 'vscode-python-ci' -# Debugger: -# TestSuiteName: 'testDebugger' -# BuildNumber: '$(Build.BuildNumber)' -# Platform: 'Linux' -# PythonVersion: '3.7' -# NodeVersion: '8.11.2' -# NpmVersion: 'latest' -# MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' -# MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' -# MOCHA_REPORTER_JUNIT: true -# AzureStorageAccountName: 'vscodepythonci' -# AzureStorageContainerName: 'vscode-python-ci' +- job: 'System_Test_Run_Linux' + dependsOn: 'PR_Validate_Windows_py37' + pool: + name: 'Hosted Ubuntu 1604' + steps: + - template: templates/test-phase.yml + strategy: + maxParallel: 10 + matrix: + SingleWorkspace: + TestSuiteName: 'testSingleWorkspace' + BuildNumber: '$(Build.BuildNumber)' + Platform: 'Linux' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' + MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' + MOCHA_REPORTER_JUNIT: true + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' + MultiWorkspace: + TestSuiteName: 'testMultiWorkspace' + BuildNumber: '$(Build.BuildNumber)' + Platform: 'Linux' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' + MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' + MOCHA_REPORTER_JUNIT: true + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' + Debugger: + TestSuiteName: 'testDebugger' + BuildNumber: '$(Build.BuildNumber)' + Platform: 'Linux' + PythonVersion: '3.7' + NodeVersion: '8.11.2' + NpmVersion: 'latest' + MOCHA_CI_REPORTER_ID: '$(Build.SourcesDirectory)/build/ci/mocha-vsts-reporter.js' + MOCHA_CI_REPORTFILE: '$(Build.ArtifactStagingDirectory)/reports/junit-report.xml' + MOCHA_REPORTER_JUNIT: true + AzureStorageAccountName: 'vscodepythonci' + AzureStorageContainerName: 'vscode-python-ci' diff --git a/src/client/common/terminal/activator/base.ts b/src/client/common/terminal/activator/base.ts index 4a7f0528f531..b74287a99f2a 100644 --- a/src/client/common/terminal/activator/base.ts +++ b/src/client/common/terminal/activator/base.ts @@ -17,19 +17,12 @@ export class BaseTerminalActivator implements ITerminalActivator { const deferred = createDeferred(); this.activatedTerminals.set(terminal, deferred.promise); const shellPath = this.helper.getTerminalShellPath(); - // // tslint:disable-next-line:no-console - // console.log(shellPath); - // const shellPath = '/usr/bin/bash'; const terminalShellType = !shellPath || shellPath.length === 0 ? TerminalShellType.other : this.helper.identifyTerminalShell(shellPath); - // tslint:disable-next-line:no-console - console.log('in base.ts, terminalShellType', terminalShellType); const activationCommamnds = await this.helper.getEnvironmentActivationCommands(terminalShellType, resource); let activated = false; if (activationCommamnds) { for (const command of activationCommamnds!) { - // tslint:disable-next-line:no-console - console.log('in base.ts', command); terminal.show(preserveFocus); terminal.sendText(command); await this.waitForCommandToProcess(terminalShellType); diff --git a/src/client/interpreter/locators/services/condaService.ts b/src/client/interpreter/locators/services/condaService.ts index ea819f68b066..f7a8dd9be4ca 100644 --- a/src/client/interpreter/locators/services/condaService.ts +++ b/src/client/interpreter/locators/services/condaService.ts @@ -106,8 +106,6 @@ export class CondaService implements ICondaService { } // tslint:disable-next-line:no-unnecessary-local-variable const condaFile = await this.condaFile!; - // tslint:disable-next-line:no-console - console.log('condaFile ', condaFile); return condaFile!; } @@ -459,8 +457,6 @@ export class CondaService implements ICondaService { * Return the path to the "conda file", if there is one (in known locations). */ private async getCondaFileImpl() { - // tslint:disable-next-line:no-console - console.log('In getCondaFileImpl()'); const settings = this.configService.getSettings(); const setting = settings.condaPath; @@ -470,8 +466,6 @@ export class CondaService implements ICondaService { const isAvailable = await this.isCondaInCurrentPath(); if (isAvailable) { - // tslint:disable-next-line:no-console - console.log('We found conda in current path'); return 'conda'; } if (this.platform.isWindows && this.registryLookupForConda) { @@ -491,11 +485,7 @@ export class CondaService implements ICondaService { * Note: For now we simply return the first one found. */ private async getCondaFileFromKnownLocations(): Promise { - // tslint:disable-next-line:no-console - console.log('Inside getCondaFileFromKnownLocations'); const globPattern = this.platform.isWindows ? CondaLocationsGlobWin : CondaLocationsGlob; - // tslint:disable-next-line:no-console - console.log('globPattern', globPattern); const condaFiles = await this.fileSystem.search(globPattern) .catch((failReason) => { Logger.warn( @@ -504,11 +494,7 @@ export class CondaService implements ICondaService { ); return []; }); - // tslint:disable-next-line:no-console - console.log('condafiles', condaFiles); const validCondaFiles = condaFiles.filter(condaPath => condaPath.length > 0); - // tslint:disable-next-line:no-console - console.log('validCondaFiles', validCondaFiles); return validCondaFiles.length === 0 ? 'conda' : validCondaFiles[0]; } diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 189b22d7800b..0afd5c99b564 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -5,7 +5,6 @@ import { expect } from 'chai'; import * as fs from 'fs-extra'; -import * as os from 'os'; import * as path from 'path'; import * as vscode from 'vscode'; import { PYTHON_VIRTUAL_ENVS_LOCATION } from '../../../ciConstants'; @@ -18,8 +17,6 @@ import { initialize, initializeTest } from '../../../initialize'; suite('Activation of Environments in Terminal', () => { const file = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.py'); const outputFile = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.log'); - const file2 = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal2.py'); - const outputFile2 = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal2.log'); const envsLocation = PYTHON_VIRTUAL_ENVS_LOCATION !== undefined ? path.join(EXTENSION_ROOT_DIR_FOR_TESTS, PYTHON_VIRTUAL_ENVS_LOCATION) : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); const waitTimeForActivation = 5000; @@ -44,6 +41,7 @@ suite('Activation of Environments in Terminal', () => { pythonSettings = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders[0].uri); defaultShell.Windows = terminalSettings.inspect('integrated.shell.windows').globalValue; defaultShell.Linux = terminalSettings.inspect('integrated.shell.linux').globalValue; + await terminalSettings.update('integrated.shell.linux', '/bin/bash', vscode.ConfigurationTarget.Global); await initialize(); }); setup(async () => { @@ -56,6 +54,7 @@ suite('Activation of Environments in Terminal', () => { await updateSetting('terminal.activateEnvironment', undefined, vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); await terminalSettings.update('integrated.shell.windows', defaultShell.Windows, vscode.ConfigurationTarget.Global); await terminalSettings.update('integrated.shell.linux', defaultShell.Linux, vscode.ConfigurationTarget.Global); + await pythonSettings.update('condaPath', undefined, vscode.ConfigurationTarget.Workspace); await restorePythonPathInWorkspaceRoot(); } async function cleanUp() { @@ -65,54 +64,13 @@ suite('Activation of Environments in Terminal', () => { } async function testActivation(envPath) { - // tslint:disable-next-line:no-console - console.log(`start1 ${envPath}`); await updateSetting('terminal.activateEnvironment', true, vscode.workspace.workspaceFolders[0].uri, vscode.ConfigurationTarget.WorkspaceFolder); - // tslint:disable-next-line:no-console - console.log('start2'); await setPythonPathInWorkspaceRoot(envPath); - // tslint:disable-next-line:no-console - console.log('start3'); - const pyPath = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders[0].uri); - // tslint:disable-next-line:no-console - console.log(`Set pythonPath to ${pyPath.inspect('pythonPath').workspaceFolderValue}`); - // tslint:disable-next-line:no-console - console.log(`Set condaPath to ${pyPath.inspect('condaPath').workspaceFolderValue}`); - if (os.platform() === 'linux') { - // tslint:disable-next-line:no-console - console.log('OS is linux, updating terminal shell Path'); - await terminalSettings.update('integrated.shell.linux', '/bin/bash', vscode.ConfigurationTarget.Global); - } - // tslint:disable-next-line:no-console - console.log('Create terminal'); const terminal = vscode.window.createTerminal(); - // tslint:disable-next-line:no-console - console.log('Waiting for activation'); await sleep(waitTimeForActivation); - // tslint:disable-next-line:no-console - console.log('Done waiting for activation'); - // tslint:disable-next-line:no-console - console.log('Sending text'); terminal.sendText(`python ${file}`, true); - // tslint:disable-next-line:no-console - console.log('Waiting for output'); await waitForCondition(() => fs.pathExists(outputFile), 5_000, '\'testExecInTerminal.log\' file not created'); - terminal.sendText(`python ${file2}`, true); - await waitForCondition(() => fs.pathExists(outputFile2), 5_000, '\'testExecInTerminal2.log\' file not created'); - // tslint:disable-next-line:no-console - console.log('Read output file'); const content = await fs.readFile(outputFile, 'utf-8'); - // tslint:disable-next-line:no-console - console.log('Done Reading'); - // tslint:disable-next-line:no-console - console.log('Expect file content: ', content, 'to equal envPath: ', envPath); - - const extraContent = await fs.readFile(outputFile2, 'utf-8'); - const xtraLines = extraContent.splitLines({ trim: true }); - - // tslint:disable-next-line:no-console - xtraLines.forEach((ln: string) => console.log(ln)); - expect(content).to.equal(envPath); } async function testNonActivation() { diff --git a/src/testMultiRootWkspc/smokeTests/testExecInTerminal2.py b/src/testMultiRootWkspc/smokeTests/testExecInTerminal2.py deleted file mode 100644 index 4671e279064b..000000000000 --- a/src/testMultiRootWkspc/smokeTests/testExecInTerminal2.py +++ /dev/null @@ -1,10 +0,0 @@ -import sys -import os - - -log_file = os.path.splitext(sys.argv[0])[0] + '.log' -with open(log_file, "w") as outfile: - outfile.write('Env Vars:\n') - for k in os.environ.keys(): - outfile.write(f'{k}: {os.environ[k]}\n') -