Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
362d3454
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
362d3454
编写于
7月 09, 2020
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adding tests for opening markdown document links
上级
eb29e868
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
130 addition
and
16 deletion
+130
-16
.vscode/launch.json
.vscode/launch.json
+1
-1
extensions/markdown-language-features/src/test/documentLink.test.ts
.../markdown-language-features/src/test/documentLink.test.ts
+112
-0
extensions/markdown-language-features/src/test/documentLinkProvider.test.ts
...n-language-features/src/test/documentLinkProvider.test.ts
+10
-10
extensions/markdown-language-features/src/test/test-fixtures/marker.txt
...kdown-language-features/src/test/test-fixtures/marker.txt
+0
-1
extensions/markdown-language-features/test-workspace/a.md
extensions/markdown-language-features/test-workspace/a.md
+0
-0
extensions/markdown-language-features/test-workspace/b.md
extensions/markdown-language-features/test-workspace/b.md
+1
-0
extensions/markdown-language-features/test-workspace/sub/c.md
...nsions/markdown-language-features/test-workspace/sub/c.md
+2
-0
extensions/markdown-language-features/test-workspace/sub/d.md
...nsions/markdown-language-features/test-workspace/sub/d.md
+0
-0
extensions/vscode-web-playground/src/exampleFiles.ts
extensions/vscode-web-playground/src/exampleFiles.ts
+1
-1
scripts/test-integration.bat
scripts/test-integration.bat
+1
-1
scripts/test-integration.sh
scripts/test-integration.sh
+2
-2
未找到文件。
.vscode/launch.json
浏览文件 @
362d3454
...
...
@@ -319,7 +319,7 @@
"name"
:
"Markdown Extension Tests"
,
"runtimeExecutable"
:
"${execPath}"
,
"args"
:
[
"${workspaceFolder}/extensions/markdown-language-features/test-
fixtures
"
,
"${workspaceFolder}/extensions/markdown-language-features/test-
workspace
"
,
"--extensionDevelopmentPath=${workspaceFolder}/extensions/markdown-language-features"
,
"--extensionTestsPath=${workspaceFolder}/extensions/markdown-language-features/out/test"
],
...
...
extensions/markdown-language-features/src/test/documentLink.test.ts
0 → 100644
浏览文件 @
362d3454
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
'
mocha
'
;
import
*
as
vscode
from
'
vscode
'
;
const
testFileA
=
workspaceFile
(
'
a.md
'
);
function
workspaceFile
(...
segments
:
string
[])
{
return
vscode
.
Uri
.
joinPath
(
vscode
.
workspace
.
workspaceFolders
!
[
0
].
uri
,
...
segments
);
}
async
function
getLinksForFile
(
file
:
vscode
.
Uri
):
Promise
<
vscode
.
DocumentLink
[]
>
{
return
(
await
vscode
.
commands
.
executeCommand
<
vscode
.
DocumentLink
[]
>
(
'
vscode.executeLinkProvider
'
,
file
))
!
;
}
suite
(
'
Markdown Document links
'
,
()
=>
{
teardown
(
async
()
=>
{
await
vscode
.
commands
.
executeCommand
(
'
workbench.action.closeAllEditors
'
);
});
test
(
'
Should navigate to markdown file
'
,
async
()
=>
{
await
withFileContents
(
testFileA
,
'
[b](b.md)
'
);
const
[
link
]
=
await
getLinksForFile
(
testFileA
);
await
executeLink
(
link
);
assertActiveDocumentUri
(
workspaceFile
(
'
b.md
'
));
});
test
(
'
Should navigate to markdown file with leading ./
'
,
async
()
=>
{
await
withFileContents
(
testFileA
,
'
[b](./b.md)
'
);
const
[
link
]
=
await
getLinksForFile
(
testFileA
);
await
executeLink
(
link
);
assertActiveDocumentUri
(
workspaceFile
(
'
b.md
'
));
});
test
(
'
Should navigate to markdown file with leading /
'
,
async
()
=>
{
await
withFileContents
(
testFileA
,
'
[b](./b.md)
'
);
const
[
link
]
=
await
getLinksForFile
(
testFileA
);
await
executeLink
(
link
);
assertActiveDocumentUri
(
workspaceFile
(
'
b.md
'
));
});
test
(
'
Should navigate to markdown file without file extension
'
,
async
()
=>
{
await
withFileContents
(
testFileA
,
'
[b](b)
'
);
const
[
link
]
=
await
getLinksForFile
(
testFileA
);
await
executeLink
(
link
);
assertActiveDocumentUri
(
workspaceFile
(
'
b.md
'
));
});
test
(
'
Should navigate to markdown file in directory
'
,
async
()
=>
{
await
withFileContents
(
testFileA
,
'
[b](sub/c)
'
);
const
[
link
]
=
await
getLinksForFile
(
testFileA
);
await
executeLink
(
link
);
assertActiveDocumentUri
(
workspaceFile
(
'
sub
'
,
'
c.md
'
));
});
test
(
'
Should navigate to fragment by title in file
'
,
async
()
=>
{
await
withFileContents
(
testFileA
,
'
[b](sub/c#second)
'
);
const
[
link
]
=
await
getLinksForFile
(
testFileA
);
await
executeLink
(
link
);
assertActiveDocumentUri
(
workspaceFile
(
'
sub
'
,
'
c.md
'
));
assert
.
strictEqual
(
vscode
.
window
.
activeTextEditor
!
.
selection
.
start
.
line
,
1
);
});
test
(
'
Should navigate to fragment by line
'
,
async
()
=>
{
await
withFileContents
(
testFileA
,
'
[b](sub/c#L2)
'
);
const
[
link
]
=
await
getLinksForFile
(
testFileA
);
await
executeLink
(
link
);
assertActiveDocumentUri
(
workspaceFile
(
'
sub
'
,
'
c.md
'
));
assert
.
strictEqual
(
vscode
.
window
.
activeTextEditor
!
.
selection
.
start
.
line
,
1
);
});
});
function
assertActiveDocumentUri
(
expectedUri
:
vscode
.
Uri
)
{
assert
.
strictEqual
(
vscode
.
window
.
activeTextEditor
!
.
document
.
uri
.
fsPath
,
expectedUri
.
fsPath
);
}
async
function
withFileContents
(
file
:
vscode
.
Uri
,
contents
:
string
):
Promise
<
void
>
{
const
document
=
await
vscode
.
workspace
.
openTextDocument
(
file
);
const
editor
=
await
vscode
.
window
.
showTextDocument
(
document
);
await
editor
.
edit
(
edit
=>
{
edit
.
replace
(
new
vscode
.
Range
(
0
,
0
,
1000
,
0
),
contents
);
});
}
async
function
executeLink
(
link
:
vscode
.
DocumentLink
)
{
const
args
=
JSON
.
parse
(
decodeURIComponent
(
link
.
target
!
.
query
));
await
vscode
.
commands
.
executeCommand
(
link
.
target
!
.
path
,
args
);
}
extensions/markdown-language-features/src/test/documentLinkProvider.test.ts
浏览文件 @
362d3454
...
...
@@ -10,7 +10,7 @@ import LinkProvider from '../features/documentLinkProvider';
import
{
InMemoryDocument
}
from
'
./inMemoryDocument
'
;
const
testFile
Name
=
vscode
.
Uri
.
file
(
'
test
.md
'
);
const
testFile
=
vscode
.
Uri
.
joinPath
(
vscode
.
workspace
.
workspaceFolders
!
[
0
].
uri
,
'
x
.md
'
);
const
noopToken
=
new
class
implements
vscode
.
CancellationToken
{
private
_onCancellationRequestedEmitter
=
new
vscode
.
EventEmitter
<
void
>
();
...
...
@@ -20,7 +20,7 @@ const noopToken = new class implements vscode.CancellationToken {
};
function
getLinksForFile
(
fileContents
:
string
)
{
const
doc
=
new
InMemoryDocument
(
testFile
Name
,
fileContents
);
const
doc
=
new
InMemoryDocument
(
testFile
,
fileContents
);
const
provider
=
new
LinkProvider
();
return
provider
.
provideDocumentLinks
(
doc
,
noopToken
);
}
...
...
@@ -118,24 +118,24 @@ suite('markdown.DocumentLinkProvider', () => {
const
links
=
getLinksForFile
(
'
[![alt text](image.jpg)](https://example.com)
'
);
assert
.
strictEqual
(
links
.
length
,
2
);
const
[
link1
,
link2
]
=
links
;
assertRangeEqual
(
link1
.
range
,
new
vscode
.
Range
(
0
,
13
,
0
,
22
));
assertRangeEqual
(
link2
.
range
,
new
vscode
.
Range
(
0
,
25
,
0
,
44
));
assertRangeEqual
(
link1
.
range
,
new
vscode
.
Range
(
0
,
13
,
0
,
22
));
assertRangeEqual
(
link2
.
range
,
new
vscode
.
Range
(
0
,
25
,
0
,
44
));
}
{
const
links
=
getLinksForFile
(
'
[![a]( whitespace.jpg )]( https://whitespace.com )
'
);
assert
.
strictEqual
(
links
.
length
,
2
);
const
[
link1
,
link2
]
=
links
;
assertRangeEqual
(
link1
.
range
,
new
vscode
.
Range
(
0
,
7
,
0
,
21
));
assertRangeEqual
(
link2
.
range
,
new
vscode
.
Range
(
0
,
26
,
0
,
48
));
assertRangeEqual
(
link1
.
range
,
new
vscode
.
Range
(
0
,
7
,
0
,
21
));
assertRangeEqual
(
link2
.
range
,
new
vscode
.
Range
(
0
,
26
,
0
,
48
));
}
{
const
links
=
getLinksForFile
(
'
[![a](img1.jpg)](file1.txt) text [![a](img2.jpg)](file2.txt)
'
);
assert
.
strictEqual
(
links
.
length
,
4
);
const
[
link1
,
link2
,
link3
,
link4
]
=
links
;
assertRangeEqual
(
link1
.
range
,
new
vscode
.
Range
(
0
,
6
,
0
,
14
));
assertRangeEqual
(
link2
.
range
,
new
vscode
.
Range
(
0
,
17
,
0
,
26
));
assertRangeEqual
(
link3
.
range
,
new
vscode
.
Range
(
0
,
39
,
0
,
47
));
assertRangeEqual
(
link4
.
range
,
new
vscode
.
Range
(
0
,
50
,
0
,
59
));
assertRangeEqual
(
link1
.
range
,
new
vscode
.
Range
(
0
,
6
,
0
,
14
));
assertRangeEqual
(
link2
.
range
,
new
vscode
.
Range
(
0
,
17
,
0
,
26
));
assertRangeEqual
(
link3
.
range
,
new
vscode
.
Range
(
0
,
39
,
0
,
47
));
assertRangeEqual
(
link4
.
range
,
new
vscode
.
Range
(
0
,
50
,
0
,
59
));
}
});
});
...
...
extensions/markdown-language-features/src/test/test-fixtures/marker.txt
已删除
100644 → 0
浏览文件 @
eb29e868
DO NOT DELETE, USED BY INTEGRATION TESTS
extensions/markdown-language-features/test-workspace/a.md
0 → 100644
浏览文件 @
362d3454
extensions/markdown-language-features/test-workspace/b.md
0 → 100644
浏览文件 @
362d3454
![](
./a
)
\ No newline at end of file
extensions/markdown-language-features/test-workspace/sub/c.md
0 → 100644
浏览文件 @
362d3454
# First
# Second
extensions/markdown-language-features/test-workspace/sub/d.md
0 → 100644
浏览文件 @
362d3454
extensions/vscode-web-playground/src/exampleFiles.ts
浏览文件 @
362d3454
...
...
@@ -282,7 +282,7 @@ Or discuss debug adapters on Gitter:
You can now 'step through' the 'readme.md' file, set and hit breakpoints, and run into exceptions (if the word exception appears in a line).
![Mock Debug](
images/mock-debug.gif
)
![Mock Debug](
file.jpg
)
## Build and Run
...
...
scripts/test-integration.bat
浏览文件 @
362d3454
...
...
@@ -59,7 +59,7 @@ if %errorlevel% neq 0 exit /b %errorlevel%
REM call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\typescript-language-features\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\typescript-language-features --extensionTestsPath=%~dp0\..\extensions\typescript-language-features\out\test --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
REM if %errorlevel% neq 0 exit /b %errorlevel%
call
"
%INTEGRATION_TEST_ELECTRON_PATH%
"
%~dp0
\..\extensions\markdown
-language-features
\
out\test\test
-fixtures
--extensionDevelopmentPath
=
%~dp0
\..\extensions\markdown
-language-features --extensionTestsPath
=
%~dp0
\..\extensions\markdown
-language-features
\out\test
--disable-telemetry --crash-reporter-directory
=
%VSCODECRASHDIR%
--no-cached-data --disable-updates --disable-extensions --user-data-dir
=
%VSCODEUSERDATADIR%
call
"
%INTEGRATION_TEST_ELECTRON_PATH%
"
%~dp0
\..\extensions\markdown
-language-features
\
test
-workspace
--extensionDevelopmentPath
=
%~dp0
\..\extensions\markdown
-language-features --extensionTestsPath
=
%~dp0
\..\extensions\markdown
-language-features
\out\test
--disable-telemetry --crash-reporter-directory
=
%VSCODECRASHDIR%
--no-cached-data --disable-updates --disable-extensions --user-data-dir
=
%VSCODEUSERDATADIR%
if
%errorlevel%
neq
0
exit
/b
%errorlevel%
call
"
%INTEGRATION_TEST_ELECTRON_PATH%
"
$
%~dp0
\..\extensions\emmet\out\test\test
-fixtures --extensionDevelopmentPath
=
%~dp0
\..\extensions\emmet
--extensionTestsPath
=
%~dp0
\..\extensions\emmet\out\test
--disable-telemetry --crash-reporter-directory
=
%VSCODECRASHDIR%
--no-cached-data --disable-updates --disable-extensions --user-data-dir
=
%VSCODEUSERDATADIR%
.
...
...
scripts/test-integration.sh
浏览文件 @
362d3454
...
...
@@ -53,8 +53,8 @@ fi
"
$INTEGRATION_TEST_ELECTRON_PATH
"
$LINUX_NO_SANDBOX
$ROOT
/extensions/vscode-api-tests/testWorkspace
--enable-proposed-api
=
vscode.vscode-api-tests
--extensionDevelopmentPath
=
$ROOT
/extensions/vscode-api-tests
--extensionTestsPath
=
$ROOT
/extensions/vscode-api-tests/out/singlefolder-tests
--disable-telemetry
--crash-reporter-directory
=
$VSCODECRASHDIR
--no-cached-data
--disable-updates
--disable-extensions
--user-data-dir
=
$VSCODEUSERDATADIR
"
$INTEGRATION_TEST_ELECTRON_PATH
"
$LINUX_NO_SANDBOX
$ROOT
/extensions/vscode-api-tests/testworkspace.code-workspace
--enable-proposed-api
=
vscode.vscode-api-tests
--extensionDevelopmentPath
=
$ROOT
/extensions/vscode-api-tests
--extensionTestsPath
=
$ROOT
/extensions/vscode-api-tests/out/workspace-tests
--disable-telemetry
--crash-reporter-directory
=
$VSCODECRASHDIR
--no-cached-data
--disable-updates
--disable-extensions
--user-data-dir
=
$VSCODEUSERDATADIR
"
$INTEGRATION_TEST_ELECTRON_PATH
"
$LINUX_NO_SANDBOX
$ROOT
/extensions/vscode-colorize-tests/test
--extensionDevelopmentPath
=
$ROOT
/extensions/vscode-colorize-tests
--extensionTestsPath
=
$ROOT
/extensions/vscode-colorize-tests/out
--disable-telemetry
--crash-reporter-directory
=
$VSCODECRASHDIR
--no-cached-data
--disable-updates
--disable-extensions
--user-data-dir
=
$VSCODEUSERDATADIR
"
$INTEGRATION_TEST_ELECTRON_PATH
"
$LINUX_NO_SANDBOX
$ROOT
/extensions/markdown-language-features/
out/test/test-fixtures
--extensionDevelopmentPath
=
$ROOT
/extensions/markdown-language-features
--extensionTestsPath
=
$ROOT
/extensions/markdown-language-features/out/test
--disable-telemetry
--crash-reporter-directory
=
$VSCODECRASHDIR
--no-cached-data
--disable-updates
--disable-extensions
--user-data-dir
=
$VSCODEUSERDATADIR
#
"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_NO_SANDBOX $ROOT/extensions/typescript-language-features/test-workspace --extensionDevelopmentPath=$ROOT/extensions/typescript-language-features --extensionTestsPath=$ROOT/extensions/typescript-language-features/out/test --disable-telemetry --crash-reporter-directory=$VSCODECRASHDIR --no-cached-data --disable-updates --disable-extensions --user-data-dir=$VSCODEUSERDATADIR
"
$INTEGRATION_TEST_ELECTRON_PATH
"
$LINUX_NO_SANDBOX
$ROOT
/extensions/markdown-language-features/
test-workspace
--extensionDevelopmentPath
=
$ROOT
/extensions/markdown-language-features
--extensionTestsPath
=
$ROOT
/extensions/markdown-language-features/out/test
--disable-telemetry
--crash-reporter-directory
=
$VSCODECRASHDIR
--no-cached-data
--disable-updates
--disable-extensions
--user-data-dir
=
$VSCODEUSERDATADIR
#"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_NO_SANDBOX $ROOT/extensions/typescript-language-features/test-workspace --extensionDevelopmentPath=$ROOT/extensions/typescript-language-features --extensionTestsPath=$ROOT/extensions/typescript-language-features/out/test --disable-telemetry --crash-reporter-directory=$VSCODECRASHDIR --no-cached-data --disable-updates --disable-extensions --user-data-dir=$VSCODEUSERDATADIR
"
$INTEGRATION_TEST_ELECTRON_PATH
"
$LINUX_NO_SANDBOX
$ROOT
/extensions/emmet/out/test/test-fixtures
--extensionDevelopmentPath
=
$ROOT
/extensions/emmet
--extensionTestsPath
=
$ROOT
/extensions/emmet/out/test
--disable-telemetry
--crash-reporter-directory
=
$VSCODECRASHDIR
--no-cached-data
--disable-updates
--disable-extensions
--user-data-dir
=
$VSCODEUSERDATADIR
"
$INTEGRATION_TEST_ELECTRON_PATH
"
$LINUX_NO_SANDBOX
$(
mktemp
-d
2>/dev/null
)
--enable-proposed-api
=
vscode.git
--extensionDevelopmentPath
=
$ROOT
/extensions/git
--extensionTestsPath
=
$ROOT
/extensions/git/out/test
--disable-telemetry
--crash-reporter-directory
=
$VSCODECRASHDIR
--no-cached-data
--disable-updates
--disable-extensions
--user-data-dir
=
$VSCODEUSERDATADIR
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录