Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
399a0b9d
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,发现更多精彩内容 >>
提交
399a0b9d
编写于
2月 04, 2016
作者:
J
Jared Parsons
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added diagnostics to the determinism testing
上级
63063347
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
92 addition
and
7 deletion
+92
-7
build/scripts/test-determinism.ps1
build/scripts/test-determinism.ps1
+30
-6
cibuild.cmd
cibuild.cmd
+1
-1
src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs
src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs
+61
-0
未找到文件。
build/scripts/test-determinism.ps1
浏览文件 @
399a0b9d
param
([
string
]
$buildDir
=
$
(
throw
"Need a directory containing a compiler build to test with"
))
$rootDir
=
split-path
-parent
(
split-path
-parent
$PSScriptRoot
)
$debugDir
=
resolve-path
(
join-path
$rootDir
"Binaries\Debug"
)
if
(
-not
([
IO.Path
]::
IsPathRooted
(
$buildDir
)))
{
write-error
"The build path must be absolute"
exit
1
}
$rootDir
=
resolve-path
(
split-path
-parent
(
split-path
-parent
$PSScriptRoot
))
$sln
=
join-path
$rootDir
"Compilers.sln"
$debugDir
=
join-path
$rootDir
"Binaries\Debug"
# Create directories that may or may not exist to make the script execution below
# clean in either case.
mkdir
$debugDir
-errorAction
SilentlyContinue
|
out-null
mkdir
(
join-path
$rootDir
"Binaries\Obj"
)
-errorAction
SilentlyContinue
|
out-null
pushd
$rootDir
$skipList
=
@(
"Microsoft.CodeAnalysis.Test.Resources.Proprietary.dll"
)
$allGood
=
$true
$map
=
@{}
$i
=
0
;
...
...
@@ -13,25 +27,32 @@ while ($i -lt 3 -and $allGood) {
# Clean out the previous run
write-host
"Cleaning the Binaries"
rm
-re
-fo
"Binaries\Debug"
rm
-re
-fo
"Binaries\Debug"
rm
-re
-fo
"Binaries\Obj"
msbuild
/nologo
/v:m
/t:clean
$sln
&
msbuild
/nologo
/v:m
/t:clean
$sln
write-host
"Building the Solution"
msbuild
/nologo
/v:m
/m
$sln
&
msbuild
/nologo
/v:m
/m
/p:BootstrapBuildPath
=
$buildDir
/p:Features
=
"debug-determinism=
$debugDir
"
/p:UseRoslynAnalyzers
=
false
$sln
pushd
$debugDir
write-host
"Testing the binaries"
foreach
(
$dll
in
gci
-re
-in
Microsoft.CodeAnalysis.
*
dll
,
Roslyn.
*
dll
,
cs
*
exe
,
vb
*
exe
)
{
foreach
(
$dll
in
gci
Microsoft.CodeAnalysis.
*
dll
,
Roslyn.
*
dll
,
cs
*
exe
,
vb
*
exe
)
{
$dllFullName
=
$dll
.
FullName
$dllName
=
split-path
-leaf
$dllFullName
$dllHash
=
get-md5
$dll
$dllKeyName
=
$dllFullName
+
".key"
if
(
$skipList
.
Contains
(
$dllName
))
{
continue
;
}
if
(
$i
-eq
0
)
{
write-host
"
`t
Recording
$dllName
=
$dllHash
"
$data
=
@{}
$data
[
"Hash"
]
=
$dllHash
$data
[
"Content"
]
=
[
IO.File
]::
ReadAllBytes
(
$dllFullName
)
$data
[
"Key"
]
=
[
IO.File
]::
ReadAllBytes
(
$dllFullName
+
".key"
)
$map
[
$dllFullName
]
=
$data
}
else
{
...
...
@@ -43,6 +64,7 @@ while ($i -lt 3 -and $allGood) {
else
{
write-host
"
`t
ERROR!
$dllName
changed (
$dllFullName
)"
[
IO.File
]::
WriteAllBytes
(
$dllFullName
+
".baseline"
,
$data
.
Content
)
[
IO.File
]::
WriteAllBytes
(
$dllFullName
+
".baseline.key"
,
$data
.
Key
)
$allGood
=
$false
}
}
...
...
@@ -62,6 +84,8 @@ while ($i -lt 3 -and $allGood) {
popd
&
$buildDir
\VBCSCompiler.exe
-shutdown
if
(
-not
$allGood
)
{
exit
1
}
...
...
cibuild.cmd
浏览文件 @
399a0b9d
...
...
@@ -67,7 +67,7 @@ msbuild %MSBuildAdditionalCommandLineArgs% /t:Clean build/Toolset.sln /p:Configu
call
:TerminateBuildProcesses
if
defined
TestDeterminism
(
powershell
-noprofile -executionPolicy
RemoteSigned
-command
"
%RoslynRoot%
\build\scripts\test-determinism.ps1
%bindir%
\Bootstrap"
||
goto
:BuildFailed
powershell
-noprofile -executionPolicy
RemoteSigned
-command
"
%RoslynRoot%
\build\scripts\test-determinism.ps1
%
RoslynRoot%
\
%
bindir%
\Bootstrap"
||
goto
:BuildFailed
exit
/b
0
)
...
...
src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs
浏览文件 @
399a0b9d
...
...
@@ -58,6 +58,14 @@ public CommonCompiler(CommandLineParser parser, string responseFile, string[] ar
this
.
Arguments
=
parser
.
Parse
(
allArgs
,
baseDirectory
,
sdkDirectoryOpt
,
additionalReferenceDirectories
);
this
.
MessageProvider
=
parser
.
MessageProvider
;
this
.
AnalyzerLoader
=
analyzerLoader
;
#if DEBUG
string
value
;
if
(
Arguments
.
ParseOptions
.
Features
.
TryGetValue
(
"debug-determinism"
,
out
value
))
{
EmitDeterminismKey
(
Arguments
,
args
,
baseDirectory
,
parser
,
value
);
}
#endif
}
internal
abstract
bool
SuppressDefaultResponseFile
(
IEnumerable
<
string
>
args
);
...
...
@@ -847,5 +855,58 @@ protected virtual CultureInfo Culture
return
Arguments
.
PreferredUILang
??
CultureInfo
.
CurrentUICulture
;
}
}
private
static
void
EmitDeterminismKey
(
CommandLineArguments
args
,
string
[]
rawArgs
,
string
baseDirectory
,
CommandLineParser
parser
,
string
outputDirectory
)
{
var
key
=
CreateDeterminismKey
(
args
,
rawArgs
,
baseDirectory
,
parser
);
var
filePath
=
Path
.
Combine
(
outputDirectory
,
args
.
OutputFileName
+
".key"
);
using
(
var
stream
=
PortableShim
.
File
.
Create
(
filePath
))
{
var
bytes
=
Encoding
.
UTF8
.
GetBytes
(
key
);
stream
.
Write
(
bytes
,
0
,
bytes
.
Length
);
}
}
private
static
string
CreateDeterminismKey
(
CommandLineArguments
args
,
string
[]
rawArgs
,
string
baseDirectory
,
CommandLineParser
parser
)
{
List
<
Diagnostic
>
diagnostics
=
new
List
<
Diagnostic
>();
List
<
string
>
flattenedArgs
=
new
List
<
string
>();
parser
.
FlattenArgs
(
rawArgs
,
diagnostics
,
flattenedArgs
,
null
,
baseDirectory
);
var
builder
=
new
StringBuilder
();
var
name
=
!
string
.
IsNullOrEmpty
(
args
.
OutputFileName
)
?
Path
.
GetFileNameWithoutExtension
(
Path
.
GetFileName
(
args
.
OutputFileName
))
:
$"no-output-name-
{
Guid
.
NewGuid
().
ToString
()}
"
;
builder
.
AppendLine
(
$"
{
name
}
"
);
builder
.
AppendLine
(
$"Command Line:"
);
foreach
(
var
current
in
flattenedArgs
)
{
builder
.
AppendLine
(
$"\t
{
current
}
"
);
}
builder
.
AppendLine
(
"Source Files:"
);
var
hash
=
new
MD5CryptoServiceProvider
();
foreach
(
var
sourceFile
in
args
.
SourceFiles
)
{
var
sourceFileName
=
Path
.
GetFileName
(
sourceFile
.
Path
);
string
hashValue
;
try
{
var
bytes
=
PortableShim
.
File
.
ReadAllBytes
(
sourceFile
.
Path
);
var
hashBytes
=
hash
.
ComputeHash
(
bytes
);
var
data
=
BitConverter
.
ToString
(
hashBytes
);
hashValue
=
data
.
Replace
(
"-"
,
""
);
}
catch
(
Exception
ex
)
{
hashValue
=
$"Could not compute
{
ex
.
Message
}
"
;
}
builder
.
AppendLine
(
$"\t
{
sourceFileName
}
-
{
hashValue
}
"
);
}
return
builder
.
ToString
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录