Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

| `release` branch | `master` branch | Nightly CI | coverage (`master` branch) |
|-|-|-|-|
| [![Build Status](https://dev.azure.com/ms/vscode-python/_apis/build/status/CI?branchName=release)](https://dev.azure.com/ms/vscode-python/_build/latest?definitionId=88&branchName=release) | [![Build Status](https://dev.azure.com/ms/vscode-python/_apis/build/status/CI?branchName=master)](https://dev.azure.com/ms/vscode-python/_build/latest?definitionId=88&branchName=master) | [![Build Status](https://dev.azure.com/ms/vscode-python/_apis/build/status/Nightly%20Build?branchName=master)](https://dev.azure.com/ms/vscode-python/_build/latest?definitionId=85&branchName=master) | [![Coverage Status](https://coveralls.io/repos/github/microsoft/vscode-python/badge.svg?branch=master)](https://coveralls.io/github/microsoft/vscode-python?branch=master) |
| [![Build Status](https://dev.azure.com/ms/vscode-python/_apis/build/status/CI?branchName=release)](https://dev.azure.com/ms/vscode-python/_build/latest?definitionId=88&branchName=release) | [![Build Status](https://dev.azure.com/ms/vscode-python/_apis/build/status/CI?branchName=master)](https://dev.azure.com/ms/vscode-python/_build/latest?definitionId=88&branchName=master) | [![Build Status](https://dev.azure.com/ms/vscode-python/_apis/build/status/Nightly%20Build?branchName=master)](https://dev.azure.com/ms/vscode-python/_build/latest?definitionId=85&branchName=master) | [![codecov](https://codecov.io/gh/microsoft/vscode-python/branch/master/graph/badge.svg)](https://codecov.io/gh/microsoft/vscode-python) |

[[Development build](https://pvsc.blob.core.windows.net/extension-builds/ms-python-insiders.vsix)]

Expand Down
27 changes: 27 additions & 0 deletions build/ci/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
codecov:
notify:
require_ci_to_pass: yes

coverage:
precision: 0
round: down
range: "70...100"

status:
project: yes
patch: yes
changes: no

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
branch: !release*
layout: "header, diff, files"
behavior: default
require_changes: no
15 changes: 0 additions & 15 deletions build/ci/templates/generate_upload_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@ steps:
summaryFileLocation: "$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml"
reportDirectory: "$(System.DefaultWorkingDirectory)/coverage"

- bash: cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
displayName: 'Upload coverage to coveralls'
continueOnError: true
condition: contains(variables['TestsToRun'], 'testUnitTests')
failOnStderr: false
# Set necessary env variables for coveralls, as they don't support Azure Devops.
# Set variables based on documentation and the coveralls (npm package) source code. 😊.
env:
COVERALLS_SERVICE_JOB_ID: $(Build.BuildId)
COVERALLS_REPO_TOKEN: $(COVERALLS_REPO_TOKEN)
COVERALLS_SERVICE_NAME: $(COVERALLS_SERVICE_NAME)
COVERALLS_GIT_COMMIT: $(Build.SourceVersion)
COVERALLS_GIT_BRANCH: $(Build.SourceBranchName)
CI_PULL_REQUEST: $(System.PullRequest.PullRequestNumber)

- bash: cat ./coverage/lcov.info | ./node_modules/.bin/codecov --pipe
displayName: 'Upload coverage to codecov'
continueOnError: true
Expand Down
2 changes: 1 addition & 1 deletion build/ci/templates/test_phases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ steps:
npm run package
npx gulp clean:cleanExceptTests
cp -r ./tmp/test ./out/test
npm run testSmoke
node ./out/test/smokeTest.js
displayName: 'Run Smoke Tests'
condition: and(succeeded(), contains(variables['TestsToRun'], 'testSmoke'))
env:
Expand Down
2 changes: 2 additions & 0 deletions news/2 Fixes/6813.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Drop dedent-on-enter for "return" statements. It will be addressed in:
https://github.com/microsoft/vscode-python/issues/6564
1 change: 1 addition & 0 deletions news/2 Fixes/6940.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix failing functional tests (for pytest) in the extension.
1 change: 1 addition & 0 deletions news/3 Code Health/6938.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upload coverage reports to [codecov](https://codecov.io/gh/microsoft/vscode-python).
4 changes: 4 additions & 0 deletions news/3 Code Health/6961.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Bump version of [PTVSD](https://pypi.org/project/ptvsd/) to `4.3.2`
* Fix an issue with Jump to cursor command. [#1667](https://github.com/microsoft/ptvsd/issues/1667)
* Fix "Unable to find threadStateIndex for the current thread" message in terminal. [#1587](https://github.com/microsoft/ptvsd/issues/1587)
* Fixes crash when using python 3.7.4. [#1688](https://github.com/microsoft/ptvsd/issues/1688)
26 changes: 0 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2545,8 +2545,8 @@
"@types/glob": "^5.0.35",
"@types/html-webpack-plugin": "^3.2.0",
"@types/iconv-lite": "^0.0.1",
"@types/jsdom": "^11.12.0",
"@types/jquery": "^1.10.35",
"@types/jsdom": "^11.12.0",
"@types/loader-utils": "^1.1.3",
"@types/lodash": "^4.14.104",
"@types/md5": "^2.1.32",
Expand Down Expand Up @@ -2592,7 +2592,6 @@
"codecov": "^3.5.0",
"colors": "^1.2.1",
"copy-webpack-plugin": "^4.6.0",
"coveralls": "^3.0.4",
"cross-spawn": "^6.0.5",
"css-loader": "^1.0.1",
"cucumber-html-reporter": "^4.0.5",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jedi==0.13.3
parso==0.5.0
isort==4.3.21
ptvsd==4.3.0
ptvsd==4.3.2
6 changes: 3 additions & 3 deletions src/client/common/platform/fileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ export class FileSystem implements IFileSystem {
return deferred.promise;
}

public getFileHash(filePath: string): Promise<string | undefined> {
return new Promise<string | undefined>(resolve => {
public getFileHash(filePath: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
fs.lstat(filePath, (err, stats) => {
if (err) {
resolve();
reject(err);
} else {
const actual = createHash('sha512').update(`${stats.ctimeMs}-${stats.mtimeMs}`).digest('hex');
resolve(actual);
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/platform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface IFileSystem {
getRealPath(path: string): Promise<string>;
copyFile(src: string, dest: string): Promise<void>;
deleteFile(filename: string): Promise<void>;
getFileHash(filePath: string): Promise<string | undefined>;
getFileHash(filePath: string): Promise<string>;
search(globPattern: string): Promise<string[]>;
createTemporaryFile(extension: string): Promise<TemporaryFile>;
createWriteStream(path: string): fs.WriteStream;
Expand Down
22 changes: 22 additions & 0 deletions src/client/common/utils/regexp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

/* Generate a RegExp from a "verbose" pattern.
*
* All whitespace in the pattern is removed, including newlines. This
* allows the pattern to be much more readable by allowing it to span
* multiple lines and to separate tokens with insignificant whitespace.
* The functionality is similar to the VERBOSE ("x") flag in Python's
* regular expressions.
*
* Note that significant whitespace in the pattern must be explicitly
* indicated by "\s". Also, unlike with regular expression literals,
* backslashes must be escaped. Conversely, forward slashes do not
* need to be escaped.
*/
export function verboseRegExp(pattern: string): RegExp {
pattern = pattern.replace(/\s+?/g, '');
return RegExp(pattern);
}
118 changes: 94 additions & 24 deletions src/client/language/languageConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,111 @@
// Licensed under the MIT License.
'use strict';

import { IndentAction } from 'vscode';
import { IndentAction, LanguageConfiguration } from 'vscode';
import { verboseRegExp } from '../common/utils/regexp';

export const MULTILINE_SEPARATOR_INDENT_REGEX = /^(?!\s+\\)[^#\n]+\\$/;
/**
* This does not handle all cases. However, it does handle nearly all usage.
* Here's what it does not cover:
* - the statement is split over multiple lines (and hence the ":" is on a different line)
* - the code block is inlined (after the ":")
* - there are multiple statements on the line (separated by semicolons)
* Also note that `lambda` is purposefully excluded.
*/
export const INCREASE_INDENT_REGEX = /^\s*(?:(?:async|class|def|elif|except|for|if|while|with)\b.*|(else|finally|try))\s*:\s*(#.*)?$/;
export const DECREASE_INDENT_REGEX = /^\s*(?:else|finally|(?:elif|except)\b.*)\s*:\s*(#.*)?$/;
export const OUTDENT_ONENTER_REGEX = /^\s*(?:break|continue|pass|(?:raise|return)\b.*)\s*(#.*)?$/;
// tslint:disable:no-multiline-string

export function getLanguageConfiguration() {
// tslint:disable-next-line:max-func-body-length
export function getLanguageConfiguration(): LanguageConfiguration {
return {
onEnterRules: [
// multi-line separator
{
beforeText: MULTILINE_SEPARATOR_INDENT_REGEX,
action: { indentAction: IndentAction.Indent }
beforeText: verboseRegExp(`
^
(?! \\s+ \\\\ )
[^#\n]+
\\\\
$
`),
action: {
indentAction: IndentAction.Indent
}
},
// continue comments
{
beforeText: /^\s*#.*/,
afterText: /.+$/,
action: { indentAction: IndentAction.None, appendText: '# ' }
action: {
indentAction: IndentAction.None,
appendText: '# '
}
},
// indent on enter (block-beginning statements)
{
beforeText: OUTDENT_ONENTER_REGEX,
action: { indentAction: IndentAction.Outdent }
/**
* This does not handle all cases. However, it does handle nearly all usage.
* Here's what it does not cover:
* - the statement is split over multiple lines (and hence the ":" is on a different line)
* - the code block is inlined (after the ":")
* - there are multiple statements on the line (separated by semicolons)
* Also note that `lambda` is purposefully excluded.
*/
beforeText: verboseRegExp(`
^
\\s*
(?:
(?:
(?:
class |
def |
async \\s+ def |
except |
for |
if |
elif |
while |
with
)
\\b .*
) |
else |
try |
finally
)
\\s*
[:]
\\s*
(?: [#] .* )?
$
`),
action: {
indentAction: IndentAction.Indent
}
},
// outdent on enter (block-ending statements)
{
beforeText: verboseRegExp(`
^
(?:
(?:
\\s*
(?:
pass |
raise \\s+ [^#\\s] [^#]*
)
) |
(?:
\\s+
(?:
raise |
break |
continue
)
)
)
\\s*
(?: [#] .* )?
$
`),
action: {
indentAction: IndentAction.Outdent
}
}
],
indentationRules: {
increaseIndentPattern: INCREASE_INDENT_REGEX,
decreaseIndentPattern: DECREASE_INDENT_REGEX
}
// Note that we do not currently have an auto-dedent
// solution for "elif", "else", "except", and "finally".
// We had one but had to remove it (see issue #6886).
]
};
}
11 changes: 11 additions & 0 deletions src/test/common/platform/filesystem.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FileSystem } from '../../../client/common/platform/fileSystem';
import { IFileSystem, IPlatformService, TemporaryFile } from '../../../client/common/platform/types';
// tslint:disable-next-line:no-require-imports no-var-requires
const assertArrays = require('chai-arrays');
use(require('chai-as-promised'));
use(assertArrays);

// tslint:disable-next-line:max-func-body-length
Expand Down Expand Up @@ -116,4 +117,14 @@ suite('FileSystem', () => {
});
});
});
test('Getting hash for non existent file should throw error', async () => {
const promise = fileSystem.getFileHash('some unknown file');

await expect(promise).to.eventually.be.rejected;
});
test('Getting hash for a file should return non-empty string', async () => {
const hash = await fileSystem.getFileHash(__filename);

expect(hash).to.be.length.greaterThan(0);
});
});
Loading