Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
cf6c2b98
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
cf6c2b98
编写于
6月 05, 2019
作者:
S
Sam Harwell
提交者:
GitHub
6月 05, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #36100 from ivanbasov/retry
support retries in integration tests
上级
c78f1e59
555d714e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
92 addition
and
8 deletion
+92
-8
eng/build.ps1
eng/build.ps1
+1
-0
src/EditorFeatures/TestUtilities/Threading/TestInfo.cs
src/EditorFeatures/TestUtilities/Threading/TestInfo.cs
+41
-0
src/EditorFeatures/TestUtilities/Threading/WpfTestRunner.cs
src/EditorFeatures/TestUtilities/Threading/WpfTestRunner.cs
+17
-3
src/EditorFeatures/TestUtilities/Threading/WpfTheoryTestCase.cs
...itorFeatures/TestUtilities/Threading/WpfTheoryTestCase.cs
+4
-1
src/Tools/Source/RunTests/ProcessTestExecutor.cs
src/Tools/Source/RunTests/ProcessTestExecutor.cs
+29
-4
未找到文件。
eng/build.ps1
浏览文件 @
cf6c2b98
...
...
@@ -378,6 +378,7 @@ function TestUsingOptimizedRunner() {
}
$dlls
+=
@(
Get-ChildItem
-Recurse
-Include
"*.IntegrationTests.dll"
$binDir
)
$args
+=
" -testVsi"
}
else
{
$dlls
=
Get-ChildItem
-Recurse
-Include
"*.IntegrationTests.dll"
$binDir
$args
+=
" -trait:Feature=NetCore"
...
...
src/EditorFeatures/TestUtilities/Threading/TestInfo.cs
0 → 100644
浏览文件 @
cf6c2b98
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System.Collections.Immutable
;
using
System.IO
;
using
System.Xml.Linq
;
using
System.Xml.XPath
;
namespace
Roslyn.Test.Utilities
{
public
readonly
struct
TestInfo
{
public
decimal
Time
{
get
;
}
public
TestInfo
(
decimal
time
)
{
Time
=
time
;
}
public
static
ImmutableDictionary
<
string
,
TestInfo
>
GetPassedTestsInfo
()
{
var
result
=
ImmutableDictionary
.
CreateBuilder
<
string
,
TestInfo
>();
var
filePath
=
System
.
Environment
.
GetEnvironmentVariable
(
"OutputXmlFilePath"
);
if
(
filePath
!=
null
)
{
if
(
File
.
Exists
(
filePath
))
{
var
doc
=
XDocument
.
Load
(
filePath
);
foreach
(
var
test
in
doc
.
XPathSelectElements
(
"/assemblies/assembly/collection/test[@result='Pass']"
))
{
if
(
decimal
.
TryParse
(
test
.
Attribute
(
"time"
).
Value
,
out
var
time
))
{
result
.
Add
(
test
.
Attribute
(
"name"
).
Value
,
new
TestInfo
(
time
));
}
}
}
}
return
result
.
ToImmutable
();
}
}
}
src/EditorFeatures/TestUtilities/Threading/WpfTestRunner.cs
浏览文件 @
cf6c2b98
...
...
@@ -2,6 +2,7 @@
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Reflection
;
using
System.Threading
;
...
...
@@ -25,10 +26,16 @@ namespace Roslyn.Test.Utilities
/// </summary>
public
sealed
class
WpfTestRunner
:
XunitTestRunner
{
private
static
readonly
ImmutableDictionary
<
string
,
TestInfo
>
_passedTests
;
private
static
string
s_wpfFactRequirementReason
;
public
WpfTestSharedData
SharedData
{
get
;
}
static
WpfTestRunner
()
{
_passedTests
=
TestInfo
.
GetPassedTestsInfo
();
}
public
WpfTestRunner
(
WpfTestSharedData
sharedData
,
ITest
test
,
...
...
@@ -63,9 +70,16 @@ protected override Task<decimal> InvokeTestMethodAsync(ExceptionAggregator aggre
// Reset our flag ensuring that part of this test actually needs WpfFact
s_wpfFactRequirementReason
=
null
;
// Just call back into the normal xUnit dispatch process now that we are on an STA Thread with no synchronization context.
var
invoker
=
new
XunitTestInvoker
(
Test
,
MessageBus
,
TestClass
,
ConstructorArguments
,
TestMethod
,
TestMethodArguments
,
BeforeAfterAttributes
,
aggregator
,
CancellationTokenSource
);
return
invoker
.
RunAsync
().
JoinUsingDispatcher
(
CancellationTokenSource
.
Token
);
if
(
_passedTests
.
TryGetValue
(
Test
.
DisplayName
,
out
var
info
))
{
return
info
.
Time
;
}
else
{
// Just call back into the normal xUnit dispatch process now that we are on an STA Thread with no synchronization context.
var
invoker
=
new
XunitTestInvoker
(
Test
,
MessageBus
,
TestClass
,
ConstructorArguments
,
TestMethod
,
TestMethodArguments
,
BeforeAfterAttributes
,
aggregator
,
CancellationTokenSource
);
return
invoker
.
RunAsync
().
JoinUsingDispatcher
(
CancellationTokenSource
.
Token
);
}
}
finally
{
...
...
src/EditorFeatures/TestUtilities/Threading/WpfTheoryTestCase.cs
浏览文件 @
cf6c2b98
...
...
@@ -13,12 +13,15 @@ public class WpfTheoryTestCase : XunitTheoryTestCase
{
[
EditorBrowsable
(
EditorBrowsableState
.
Never
)]
[
Obsolete
(
"Called by the de-serializer; should only be called by deriving classes for de-serialization purposes"
)]
public
WpfTheoryTestCase
()
{
}
public
WpfTheoryTestCase
()
{
}
public
WpfTheoryTestCase
(
IMessageSink
diagnosticMessageSink
,
TestMethodDisplay
defaultMethodDisplay
,
TestMethodDisplayOptions
defaultMethodDisplayOptions
,
ITestMethod
testMethod
)
:
base
(
diagnosticMessageSink
,
defaultMethodDisplay
,
defaultMethodDisplayOptions
,
testMethod
)
{
}
public
override
Task
<
RunSummary
>
RunAsync
(
IMessageSink
diagnosticMessageSink
,
IMessageBus
messageBus
,
object
[]
constructorArguments
,
ExceptionAggregator
aggregator
,
CancellationTokenSource
cancellationTokenSource
)
{
var
runner
=
new
WpfTheoryTestCaseRunner
(
WpfTestSharedData
.
Instance
,
this
,
DisplayName
,
SkipReason
,
constructorArguments
,
diagnosticMessageSink
,
messageBus
,
aggregator
,
cancellationTokenSource
);
...
...
src/Tools/Source/RunTests/ProcessTestExecutor.cs
浏览文件 @
cf6c2b98
...
...
@@ -69,6 +69,19 @@ private string GetResultsFilePath(AssemblyInfo assemblyInfo)
}
public
async
Task
<
TestResult
>
RunTestAsync
(
AssemblyInfo
assemblyInfo
,
CancellationToken
cancellationToken
)
{
var
result
=
await
RunTestAsyncInternal
(
assemblyInfo
,
retry
:
false
,
cancellationToken
);
// For integration tests (TestVsi), we make one more attempt to re-run failed tests.
if
(
Options
.
TestVsi
&&
!
Options
.
UseHtml
&&
!
result
.
Succeeded
)
{
return
await
RunTestAsyncInternal
(
assemblyInfo
,
retry
:
true
,
cancellationToken
);
}
return
result
;
}
private
async
Task
<
TestResult
>
RunTestAsyncInternal
(
AssemblyInfo
assemblyInfo
,
bool
retry
,
CancellationToken
cancellationToken
)
{
try
{
...
...
@@ -81,14 +94,26 @@ public async Task<TestResult> RunTestAsync(AssemblyInfo assemblyInfo, Cancellati
// NOTE: xUnit doesn't always create the log directory
Directory
.
CreateDirectory
(
resultsDir
);
// NOTE: xUnit seems to have an occasional issue creating logs create
// an empty log just in case, so our runner will still fail.
File
.
Create
(
resultsFilePath
).
Close
();
// Define environment variables for processes started via ProcessRunner.
var
environmentVariables
=
new
Dictionary
<
string
,
string
>();
Options
.
ProcDumpInfo
?.
WriteEnvironmentVariables
(
environmentVariables
);
if
(
retry
)
{
// Copy the results file path, since the new xunit run will overwrite it
var
backupResultsFilePath
=
Path
.
ChangeExtension
(
resultsFilePath
,
".old"
);
File
.
Copy
(
resultsFilePath
,
backupResultsFilePath
,
overwrite
:
true
);
ConsoleUtil
.
WriteLine
(
"Starting a retry. It will run once again tests failed."
);
// If running the process with this varialbe added, we assume that this file contains
// xml logs from the first attempt.
environmentVariables
.
Add
(
"OutputXmlFilePath"
,
backupResultsFilePath
);
}
// NOTE: xUnit seems to have an occasional issue creating logs create
// an empty log just in case, so our runner will still fail.
File
.
Create
(
resultsFilePath
).
Close
();
var
start
=
DateTime
.
UtcNow
;
var
xunitProcessInfo
=
ProcessRunner
.
CreateProcess
(
ProcessRunner
.
CreateProcessStartInfo
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录