Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xulijie Li
MathsEngine
Commits
af571a61
Commit
af571a61
authored
May 03, 2021
by
BlackAngle233
Browse files
212
parent
1d9b5391
Changes
756
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
756 of 756+
files are displayed.
Plain diff
Email patch
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/ResultsWriter.cs
View file @
af571a61
using
System
;
using
System.IO
;
using
System.Xml
;
using
NUnit.Framework.Interfaces
;
using
UnityEditor.TestTools.TestRunner.Api
;
using
UnityEngine
;
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
internal
class
ResultsWriter
{
private
const
string
k_nUnitVersion
=
"3.5.0.0"
;
private
const
string
k_TestRunNode
=
"test-run"
;
private
const
string
k_Id
=
"id"
;
private
const
string
k_Testcasecount
=
"testcasecount"
;
private
const
string
k_Result
=
"result"
;
private
const
string
k_Total
=
"total"
;
private
const
string
k_Passed
=
"passed"
;
private
const
string
k_Failed
=
"failed"
;
private
const
string
k_Inconclusive
=
"inconclusive"
;
private
const
string
k_Skipped
=
"skipped"
;
private
const
string
k_Asserts
=
"asserts"
;
private
const
string
k_EngineVersion
=
"engine-version"
;
private
const
string
k_ClrVersion
=
"clr-version"
;
private
const
string
k_StartTime
=
"start-time"
;
private
const
string
k_EndTime
=
"end-time"
;
private
const
string
k_Duration
=
"duration"
;
private
const
string
k_TimeFormat
=
"u"
;
public
void
WriteResultToFile
(
ITestResultAdaptor
result
,
string
filePath
)
{
Debug
.
LogFormat
(
LogType
.
Log
,
LogOption
.
NoStacktrace
,
null
,
"Saving results to: {0}"
,
filePath
);
try
{
if
(!
Directory
.
Exists
(
filePath
))
{
CreateDirectory
(
filePath
);
}
using
(
var
fileStream
=
File
.
CreateText
(
filePath
))
{
WriteResultToStream
(
result
,
fileStream
);
}
}
catch
(
Exception
ex
)
{
Debug
.
LogError
(
"Saving result file failed."
);
Debug
.
LogException
(
ex
);
}
}
void
CreateDirectory
(
string
filePath
)
{
var
driectoryPath
=
Path
.
GetDirectoryName
(
filePath
);
if
(!
String
.
IsNullOrEmpty
(
driectoryPath
))
{
Directory
.
CreateDirectory
(
driectoryPath
);
}
}
public
void
WriteResultToStream
(
ITestResultAdaptor
result
,
StreamWriter
streamWriter
,
XmlWriterSettings
settings
=
null
)
{
settings
=
settings
??
new
XmlWriterSettings
();
settings
.
Indent
=
true
;
settings
.
NewLineOnAttributes
=
false
;
using
(
var
xmlWriter
=
XmlWriter
.
Create
(
streamWriter
,
settings
))
{
WriteResultsToXml
(
result
,
xmlWriter
);
}
}
void
WriteResultsToXml
(
ITestResultAdaptor
result
,
XmlWriter
xmlWriter
)
{
// XML format as specified at https://github.com/nunit/docs/wiki/Test-Result-XML-Format
var
testRunNode
=
new
TNode
(
k_TestRunNode
);
testRunNode
.
AddAttribute
(
k_Id
,
"2"
);
testRunNode
.
AddAttribute
(
k_Testcasecount
,
(
result
.
PassCount
+
result
.
FailCount
+
result
.
SkipCount
+
result
.
InconclusiveCount
).
ToString
());
testRunNode
.
AddAttribute
(
k_Result
,
result
.
ResultState
.
ToString
());
testRunNode
.
AddAttribute
(
k_Total
,
(
result
.
PassCount
+
result
.
FailCount
+
result
.
SkipCount
+
result
.
InconclusiveCount
).
ToString
());
testRunNode
.
AddAttribute
(
k_Passed
,
result
.
PassCount
.
ToString
());
testRunNode
.
AddAttribute
(
k_Failed
,
result
.
FailCount
.
ToString
());
testRunNode
.
AddAttribute
(
k_Inconclusive
,
result
.
InconclusiveCount
.
ToString
());
testRunNode
.
AddAttribute
(
k_Skipped
,
result
.
SkipCount
.
ToString
());
testRunNode
.
AddAttribute
(
k_Asserts
,
result
.
AssertCount
.
ToString
());
testRunNode
.
AddAttribute
(
k_EngineVersion
,
k_nUnitVersion
);
testRunNode
.
AddAttribute
(
k_ClrVersion
,
Environment
.
Version
.
ToString
());
testRunNode
.
AddAttribute
(
k_StartTime
,
result
.
StartTime
.
ToString
(
k_TimeFormat
));
testRunNode
.
AddAttribute
(
k_EndTime
,
result
.
EndTime
.
ToString
(
k_TimeFormat
));
testRunNode
.
AddAttribute
(
k_Duration
,
result
.
Duration
.
ToString
());
var
resultNode
=
result
.
ToXml
();
testRunNode
.
ChildNodes
.
Add
(
resultNode
);
testRunNode
.
WriteTo
(
xmlWriter
);
}
}
}
using
System
;
using
System.IO
;
using
System.Xml
;
using
NUnit.Framework.Interfaces
;
using
UnityEditor.TestTools.TestRunner.Api
;
using
UnityEngine
;
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
internal
class
ResultsWriter
{
private
const
string
k_nUnitVersion
=
"3.5.0.0"
;
private
const
string
k_TestRunNode
=
"test-run"
;
private
const
string
k_Id
=
"id"
;
private
const
string
k_Testcasecount
=
"testcasecount"
;
private
const
string
k_Result
=
"result"
;
private
const
string
k_Total
=
"total"
;
private
const
string
k_Passed
=
"passed"
;
private
const
string
k_Failed
=
"failed"
;
private
const
string
k_Inconclusive
=
"inconclusive"
;
private
const
string
k_Skipped
=
"skipped"
;
private
const
string
k_Asserts
=
"asserts"
;
private
const
string
k_EngineVersion
=
"engine-version"
;
private
const
string
k_ClrVersion
=
"clr-version"
;
private
const
string
k_StartTime
=
"start-time"
;
private
const
string
k_EndTime
=
"end-time"
;
private
const
string
k_Duration
=
"duration"
;
private
const
string
k_TimeFormat
=
"u"
;
public
void
WriteResultToFile
(
ITestResultAdaptor
result
,
string
filePath
)
{
Debug
.
LogFormat
(
LogType
.
Log
,
LogOption
.
NoStacktrace
,
null
,
"Saving results to: {0}"
,
filePath
);
try
{
if
(!
Directory
.
Exists
(
filePath
))
{
CreateDirectory
(
filePath
);
}
using
(
var
fileStream
=
File
.
CreateText
(
filePath
))
{
WriteResultToStream
(
result
,
fileStream
);
}
}
catch
(
Exception
ex
)
{
Debug
.
LogError
(
"Saving result file failed."
);
Debug
.
LogException
(
ex
);
}
}
void
CreateDirectory
(
string
filePath
)
{
var
driectoryPath
=
Path
.
GetDirectoryName
(
filePath
);
if
(!
String
.
IsNullOrEmpty
(
driectoryPath
))
{
Directory
.
CreateDirectory
(
driectoryPath
);
}
}
public
void
WriteResultToStream
(
ITestResultAdaptor
result
,
StreamWriter
streamWriter
,
XmlWriterSettings
settings
=
null
)
{
settings
=
settings
??
new
XmlWriterSettings
();
settings
.
Indent
=
true
;
settings
.
NewLineOnAttributes
=
false
;
using
(
var
xmlWriter
=
XmlWriter
.
Create
(
streamWriter
,
settings
))
{
WriteResultsToXml
(
result
,
xmlWriter
);
}
}
void
WriteResultsToXml
(
ITestResultAdaptor
result
,
XmlWriter
xmlWriter
)
{
// XML format as specified at https://github.com/nunit/docs/wiki/Test-Result-XML-Format
var
testRunNode
=
new
TNode
(
k_TestRunNode
);
testRunNode
.
AddAttribute
(
k_Id
,
"2"
);
testRunNode
.
AddAttribute
(
k_Testcasecount
,
(
result
.
PassCount
+
result
.
FailCount
+
result
.
SkipCount
+
result
.
InconclusiveCount
).
ToString
());
testRunNode
.
AddAttribute
(
k_Result
,
result
.
ResultState
.
ToString
());
testRunNode
.
AddAttribute
(
k_Total
,
(
result
.
PassCount
+
result
.
FailCount
+
result
.
SkipCount
+
result
.
InconclusiveCount
).
ToString
());
testRunNode
.
AddAttribute
(
k_Passed
,
result
.
PassCount
.
ToString
());
testRunNode
.
AddAttribute
(
k_Failed
,
result
.
FailCount
.
ToString
());
testRunNode
.
AddAttribute
(
k_Inconclusive
,
result
.
InconclusiveCount
.
ToString
());
testRunNode
.
AddAttribute
(
k_Skipped
,
result
.
SkipCount
.
ToString
());
testRunNode
.
AddAttribute
(
k_Asserts
,
result
.
AssertCount
.
ToString
());
testRunNode
.
AddAttribute
(
k_EngineVersion
,
k_nUnitVersion
);
testRunNode
.
AddAttribute
(
k_ClrVersion
,
Environment
.
Version
.
ToString
());
testRunNode
.
AddAttribute
(
k_StartTime
,
result
.
StartTime
.
ToString
(
k_TimeFormat
));
testRunNode
.
AddAttribute
(
k_EndTime
,
result
.
EndTime
.
ToString
(
k_TimeFormat
));
testRunNode
.
AddAttribute
(
k_Duration
,
result
.
Duration
.
ToString
());
var
resultNode
=
result
.
ToXml
();
testRunNode
.
ChildNodes
.
Add
(
resultNode
);
testRunNode
.
WriteTo
(
xmlWriter
);
}
}
}
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/ResultsWriter.cs.meta
View file @
af571a61
fileFormatVersion: 2
guid: 29d603e0a726a9043b3503112271844a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 29d603e0a726a9043b3503112271844a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/RunData.cs
View file @
af571a61
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
internal
class
RunData
:
ScriptableSingleton
<
RunData
>
{
public
bool
isRunning
;
public
ExecutionSettings
executionSettings
;
}
}
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
internal
class
RunData
:
ScriptableSingleton
<
RunData
>
{
public
bool
isRunning
;
public
ExecutionSettings
executionSettings
;
}
}
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/RunData.cs.meta
View file @
af571a61
fileFormatVersion: 2
guid: 3f8c1075884df0249b80e23a0598f9c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 3f8c1075884df0249b80e23a0598f9c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/RunSettings.cs
View file @
af571a61
using
UnityEditor.TestTools.TestRunner.Api
;
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
internal
class
RunSettings
:
ITestRunSettings
{
private
ITestSettings
m_TestSettings
;
public
RunSettings
(
ITestSettings
testSettings
)
{
this
.
m_TestSettings
=
testSettings
;
}
public
void
Apply
()
{
if
(
m_TestSettings
!=
null
)
{
m_TestSettings
.
SetupProjectParameters
();
}
}
public
void
Dispose
()
{
if
(
m_TestSettings
!=
null
)
{
m_TestSettings
.
Dispose
();
}
}
}
}
using
UnityEditor.TestTools.TestRunner.Api
;
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
internal
class
RunSettings
:
ITestRunSettings
{
private
ITestSettings
m_TestSettings
;
public
RunSettings
(
ITestSettings
testSettings
)
{
this
.
m_TestSettings
=
testSettings
;
}
public
void
Apply
()
{
if
(
m_TestSettings
!=
null
)
{
m_TestSettings
.
SetupProjectParameters
();
}
}
public
void
Dispose
()
{
if
(
m_TestSettings
!=
null
)
{
m_TestSettings
.
Dispose
();
}
}
}
}
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/RunSettings.cs.meta
View file @
af571a61
fileFormatVersion: 2
guid: 59d3f5586b341a74c84c8f72144a4568
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 59d3f5586b341a74c84c8f72144a4568
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/SettingsBuilder.cs
View file @
af571a61
using
System
;
using
System.IO
;
using
UnityEditor.TestRunner.CommandLineParser
;
using
UnityEditor.TestTools.TestRunner.Api
;
using
UnityEngine.TestTools.TestRunner.GUI
;
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
internal
class
SettingsBuilder
:
ISettingsBuilder
{
private
ITestSettingsDeserializer
m_TestSettingsDeserializer
;
private
Action
<
string
>
m_LogAction
;
private
Action
<
string
>
m_LogWarningAction
;
private
Func
<
string
,
bool
>
m_FileExistsCheck
;
private
Func
<
bool
>
m_ScriptCompilationFailedCheck
;
public
SettingsBuilder
(
ITestSettingsDeserializer
testSettingsDeserializer
,
Action
<
string
>
logAction
,
Action
<
string
>
logWarningAction
,
Func
<
string
,
bool
>
fileExistsCheck
,
Func
<
bool
>
scriptCompilationFailedCheck
)
{
m_LogAction
=
logAction
;
m_LogWarningAction
=
logWarningAction
;
m_FileExistsCheck
=
fileExistsCheck
;
m_ScriptCompilationFailedCheck
=
scriptCompilationFailedCheck
;
m_TestSettingsDeserializer
=
testSettingsDeserializer
;
}
public
Api
.
ExecutionSettings
BuildApiExecutionSettings
(
string
[]
commandLineArgs
)
{
var
quit
=
false
;
string
testPlatform
=
TestMode
.
EditMode
.
ToString
();
string
[]
testFilters
=
null
;
string
[]
testCategories
=
null
;
string
testSettingsFilePath
=
null
;
int
testRepetitions
=
1
;
int
?
playerHeartbeatTimeout
=
null
;
bool
runSynchronously
=
false
;
string
[]
testAssemblyNames
=
null
;
var
optionSet
=
new
CommandLineOptionSet
(
new
CommandLineOption
(
"quit"
,
()
=>
{
quit
=
true
;
}),
new
CommandLineOption
(
"testPlatform"
,
platform
=>
{
testPlatform
=
platform
;
}),
new
CommandLineOption
(
"editorTestsFilter"
,
filters
=>
{
testFilters
=
filters
;
}),
new
CommandLineOption
(
"testFilter"
,
filters
=>
{
testFilters
=
filters
;
}),
new
CommandLineOption
(
"editorTestsCategories"
,
catagories
=>
{
testCategories
=
catagories
;
}),
new
CommandLineOption
(
"testCategory"
,
catagories
=>
{
testCategories
=
catagories
;
}),
new
CommandLineOption
(
"testSettingsFile"
,
settingsFilePath
=>
{
testSettingsFilePath
=
settingsFilePath
;
}),
new
CommandLineOption
(
"testRepetitions"
,
reps
=>
{
testRepetitions
=
int
.
Parse
(
reps
);
}),
new
CommandLineOption
(
"playerHeartbeatTimeout"
,
timeout
=>
{
playerHeartbeatTimeout
=
int
.
Parse
(
timeout
);
}),
new
CommandLineOption
(
"runSynchronously"
,
()
=>
{
runSynchronously
=
true
;
}),
new
CommandLineOption
(
"assemblyNames"
,
assemblyNames
=>
{
testAssemblyNames
=
assemblyNames
;
})
);
optionSet
.
Parse
(
commandLineArgs
);
DisplayQuitWarningIfQuitIsGiven
(
quit
);
CheckForScriptCompilationErrors
();
LogParametersForRun
(
testPlatform
,
testFilters
,
testCategories
,
testSettingsFilePath
);
var
testSettings
=
GetTestSettings
(
testSettingsFilePath
);
var
filter
=
new
Filter
()
{
groupNames
=
testFilters
,
categoryNames
=
testCategories
,
assemblyNames
=
testAssemblyNames
};
var
buildTarget
=
SetFilterAndGetBuildTarget
(
testPlatform
,
filter
);
RerunCallbackData
.
instance
.
runFilters
=
new
[]{
new
TestRunnerFilter
()
{
categoryNames
=
filter
.
categoryNames
,
groupNames
=
filter
.
groupNames
,
testRepetitions
=
testRepetitions
}};
RerunCallbackData
.
instance
.
testMode
=
filter
.
testMode
;
var
settings
=
new
Api
.
ExecutionSettings
()
{
filters
=
new
[]{
filter
},
overloadTestRunSettings
=
new
RunSettings
(
testSettings
),
targetPlatform
=
buildTarget
,
runSynchronously
=
runSynchronously
};
if
(
playerHeartbeatTimeout
!=
null
)
{
settings
.
playerHeartbeatTimeout
=
playerHeartbeatTimeout
.
Value
;
}
return
settings
;
}
public
ExecutionSettings
BuildExecutionSettings
(
string
[]
commandLineArgs
)
{
string
resultFilePath
=
null
;
string
deviceLogsDirectory
=
null
;
var
optionSet
=
new
CommandLineOptionSet
(
new
CommandLineOption
(
"editorTestsResultFile"
,
filePath
=>
{
resultFilePath
=
filePath
;
}),
new
CommandLineOption
(
"testResults"
,
filePath
=>
{
resultFilePath
=
filePath
;
}),
new
CommandLineOption
(
"deviceLogs"
,
dirPath
=>
{
deviceLogsDirectory
=
dirPath
;
})
);
optionSet
.
Parse
(
commandLineArgs
);
return
new
ExecutionSettings
()
{
TestResultsFile
=
resultFilePath
,
DeviceLogsDirectory
=
deviceLogsDirectory
};
}
void
DisplayQuitWarningIfQuitIsGiven
(
bool
quitIsGiven
)
{
if
(
quitIsGiven
)
{
m_LogWarningAction
(
"Running tests from command line arguments will not work when \"quit\" is specified."
);
}
}
void
CheckForScriptCompilationErrors
()
{
if
(
m_ScriptCompilationFailedCheck
())
{
throw
new
SetupException
(
SetupException
.
ExceptionType
.
ScriptCompilationFailed
);
}
}
void
LogParametersForRun
(
string
testPlatform
,
string
[]
testFilters
,
string
[]
testCategories
,
string
testSettingsFilePath
)
{
m_LogAction
(
"Running tests for "
+
testPlatform
);
if
(
testFilters
!=
null
&&
testFilters
.
Length
>
0
)
{
m_LogAction
(
"With test filter: "
+
string
.
Join
(
", "
,
testFilters
));
}
if
(
testCategories
!=
null
&&
testCategories
.
Length
>
0
)
{
m_LogAction
(
"With test categories: "
+
string
.
Join
(
", "
,
testCategories
));
}
if
(!
string
.
IsNullOrEmpty
(
testSettingsFilePath
))
{
m_LogAction
(
"With test settings file: "
+
testSettingsFilePath
);
}
}
ITestSettings
GetTestSettings
(
string
testSettingsFilePath
)
{
ITestSettings
testSettings
=
null
;
if
(!
string
.
IsNullOrEmpty
(
testSettingsFilePath
))
{
if
(!
m_FileExistsCheck
(
testSettingsFilePath
))
{
throw
new
SetupException
(
SetupException
.
ExceptionType
.
TestSettingsFileNotFound
,
testSettingsFilePath
);
}
testSettings
=
m_TestSettingsDeserializer
.
GetSettingsFromJsonFile
(
testSettingsFilePath
);
}
return
testSettings
;
}
static
BuildTarget
?
SetFilterAndGetBuildTarget
(
string
testPlatform
,
Filter
filter
)
{
BuildTarget
?
buildTarget
=
null
;
if
(
testPlatform
.
ToLower
()
==
"editmode"
)
{
filter
.
testMode
=
TestMode
.
EditMode
;
}
else
if
(
testPlatform
.
ToLower
()
==
"playmode"
)
{
filter
.
testMode
=
TestMode
.
PlayMode
;
}
else
{
try
{
buildTarget
=
(
BuildTarget
)
Enum
.
Parse
(
typeof
(
BuildTarget
),
testPlatform
,
true
);
filter
.
testMode
=
TestMode
.
PlayMode
;
}
catch
(
ArgumentException
)
{
throw
new
SetupException
(
SetupException
.
ExceptionType
.
PlatformNotFound
,
testPlatform
);
}
}
return
buildTarget
;
}
}
}
using
System
;
using
System.IO
;
using
UnityEditor.TestRunner.CommandLineParser
;
using
UnityEditor.TestTools.TestRunner.Api
;
using
UnityEngine.TestTools.TestRunner.GUI
;
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
internal
class
SettingsBuilder
:
ISettingsBuilder
{
private
ITestSettingsDeserializer
m_TestSettingsDeserializer
;
private
Action
<
string
>
m_LogAction
;
private
Action
<
string
>
m_LogWarningAction
;
private
Func
<
string
,
bool
>
m_FileExistsCheck
;
private
Func
<
bool
>
m_ScriptCompilationFailedCheck
;
public
SettingsBuilder
(
ITestSettingsDeserializer
testSettingsDeserializer
,
Action
<
string
>
logAction
,
Action
<
string
>
logWarningAction
,
Func
<
string
,
bool
>
fileExistsCheck
,
Func
<
bool
>
scriptCompilationFailedCheck
)
{
m_LogAction
=
logAction
;
m_LogWarningAction
=
logWarningAction
;
m_FileExistsCheck
=
fileExistsCheck
;
m_ScriptCompilationFailedCheck
=
scriptCompilationFailedCheck
;
m_TestSettingsDeserializer
=
testSettingsDeserializer
;
}
public
Api
.
ExecutionSettings
BuildApiExecutionSettings
(
string
[]
commandLineArgs
)
{
var
quit
=
false
;
string
testPlatform
=
TestMode
.
EditMode
.
ToString
();
string
[]
testFilters
=
null
;
string
[]
testCategories
=
null
;
string
testSettingsFilePath
=
null
;
int
testRepetitions
=
1
;
int
?
playerHeartbeatTimeout
=
null
;
bool
runSynchronously
=
false
;
string
[]
testAssemblyNames
=
null
;
var
optionSet
=
new
CommandLineOptionSet
(
new
CommandLineOption
(
"quit"
,
()
=>
{
quit
=
true
;
}),
new
CommandLineOption
(
"testPlatform"
,
platform
=>
{
testPlatform
=
platform
;
}),
new
CommandLineOption
(
"editorTestsFilter"
,
filters
=>
{
testFilters
=
filters
;
}),
new
CommandLineOption
(
"testFilter"
,
filters
=>
{
testFilters
=
filters
;
}),
new
CommandLineOption
(
"editorTestsCategories"
,
catagories
=>
{
testCategories
=
catagories
;
}),
new
CommandLineOption
(
"testCategory"
,
catagories
=>
{
testCategories
=
catagories
;
}),
new
CommandLineOption
(
"testSettingsFile"
,
settingsFilePath
=>
{
testSettingsFilePath
=
settingsFilePath
;
}),
new
CommandLineOption
(
"testRepetitions"
,
reps
=>
{
testRepetitions
=
int
.
Parse
(
reps
);
}),
new
CommandLineOption
(
"playerHeartbeatTimeout"
,
timeout
=>
{
playerHeartbeatTimeout
=
int
.
Parse
(
timeout
);
}),
new
CommandLineOption
(
"runSynchronously"
,
()
=>
{
runSynchronously
=
true
;
}),
new
CommandLineOption
(
"assemblyNames"
,
assemblyNames
=>
{
testAssemblyNames
=
assemblyNames
;
})
);
optionSet
.
Parse
(
commandLineArgs
);
DisplayQuitWarningIfQuitIsGiven
(
quit
);
CheckForScriptCompilationErrors
();
LogParametersForRun
(
testPlatform
,
testFilters
,
testCategories
,
testSettingsFilePath
);
var
testSettings
=
GetTestSettings
(
testSettingsFilePath
);
var
filter
=
new
Filter
()
{
groupNames
=
testFilters
,
categoryNames
=
testCategories
,
assemblyNames
=
testAssemblyNames
};
var
buildTarget
=
SetFilterAndGetBuildTarget
(
testPlatform
,
filter
);
RerunCallbackData
.
instance
.
runFilters
=
new
[]{
new
TestRunnerFilter
()
{
categoryNames
=
filter
.
categoryNames
,
groupNames
=
filter
.
groupNames
,
testRepetitions
=
testRepetitions
}};
RerunCallbackData
.
instance
.
testMode
=
filter
.
testMode
;
var
settings
=
new
Api
.
ExecutionSettings
()
{
filters
=
new
[]{
filter
},
overloadTestRunSettings
=
new
RunSettings
(
testSettings
),
targetPlatform
=
buildTarget
,
runSynchronously
=
runSynchronously
};
if
(
playerHeartbeatTimeout
!=
null
)
{
settings
.
playerHeartbeatTimeout
=
playerHeartbeatTimeout
.
Value
;
}
return
settings
;
}
public
ExecutionSettings
BuildExecutionSettings
(
string
[]
commandLineArgs
)
{
string
resultFilePath
=
null
;
string
deviceLogsDirectory
=
null
;
var
optionSet
=
new
CommandLineOptionSet
(
new
CommandLineOption
(
"editorTestsResultFile"
,
filePath
=>
{
resultFilePath
=
filePath
;
}),
new
CommandLineOption
(
"testResults"
,
filePath
=>
{
resultFilePath
=
filePath
;
}),
new
CommandLineOption
(
"deviceLogs"
,
dirPath
=>
{
deviceLogsDirectory
=
dirPath
;
})
);
optionSet
.
Parse
(
commandLineArgs
);
return
new
ExecutionSettings
()
{
TestResultsFile
=
resultFilePath
,
DeviceLogsDirectory
=
deviceLogsDirectory
};
}
void
DisplayQuitWarningIfQuitIsGiven
(
bool
quitIsGiven
)
{
if
(
quitIsGiven
)
{
m_LogWarningAction
(
"Running tests from command line arguments will not work when \"quit\" is specified."
);
}
}
void
CheckForScriptCompilationErrors
()
{
if
(
m_ScriptCompilationFailedCheck
())
{
throw
new
SetupException
(
SetupException
.
ExceptionType
.
ScriptCompilationFailed
);
}
}
void
LogParametersForRun
(
string
testPlatform
,
string
[]
testFilters
,
string
[]
testCategories
,
string
testSettingsFilePath
)
{
m_LogAction
(
"Running tests for "
+
testPlatform
);
if
(
testFilters
!=
null
&&
testFilters
.
Length
>
0
)
{
m_LogAction
(
"With test filter: "
+
string
.
Join
(
", "
,
testFilters
));
}
if
(
testCategories
!=
null
&&
testCategories
.
Length
>
0
)
{
m_LogAction
(
"With test categories: "
+
string
.
Join
(
", "
,
testCategories
));
}
if
(!
string
.
IsNullOrEmpty
(
testSettingsFilePath
))
{
m_LogAction
(
"With test settings file: "
+
testSettingsFilePath
);
}
}
ITestSettings
GetTestSettings
(
string
testSettingsFilePath
)
{
ITestSettings
testSettings
=
null
;
if
(!
string
.
IsNullOrEmpty
(
testSettingsFilePath
))
{
if
(!
m_FileExistsCheck
(
testSettingsFilePath
))
{
throw
new
SetupException
(
SetupException
.
ExceptionType
.
TestSettingsFileNotFound
,
testSettingsFilePath
);
}
testSettings
=
m_TestSettingsDeserializer
.
GetSettingsFromJsonFile
(
testSettingsFilePath
);
}
return
testSettings
;
}
static
BuildTarget
?
SetFilterAndGetBuildTarget
(
string
testPlatform
,
Filter
filter
)
{
BuildTarget
?
buildTarget
=
null
;
if
(
testPlatform
.
ToLower
()
==
"editmode"
)
{
filter
.
testMode
=
TestMode
.
EditMode
;
}
else
if
(
testPlatform
.
ToLower
()
==
"playmode"
)
{
filter
.
testMode
=
TestMode
.
PlayMode
;
}
else
{
try
{
buildTarget
=
(
BuildTarget
)
Enum
.
Parse
(
typeof
(
BuildTarget
),
testPlatform
,
true
);
filter
.
testMode
=
TestMode
.
PlayMode
;
}
catch
(
ArgumentException
)
{
throw
new
SetupException
(
SetupException
.
ExceptionType
.
PlatformNotFound
,
testPlatform
);
}
}
return
buildTarget
;
}
}
}
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/SettingsBuilder.cs.meta
View file @
af571a61
fileFormatVersion: 2
guid: b7468a027a77337478e133b40b42b4f9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b7468a027a77337478e133b40b42b4f9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/SetupException.cs
View file @
af571a61
using
System
;
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
internal
class
SetupException
:
Exception
{
public
ExceptionType
Type
{
get
;
}
public
object
[]
Details
{
get
;
}
public
SetupException
(
ExceptionType
type
,
params
object
[]
details
)
{
Type
=
type
;
Details
=
details
;
}
public
enum
ExceptionType
{
ScriptCompilationFailed
,
PlatformNotFound
,
TestSettingsFileNotFound
,
}
}
}
using
System
;
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
internal
class
SetupException
:
Exception
{
public
ExceptionType
Type
{
get
;
}
public
object
[]
Details
{
get
;
}
public
SetupException
(
ExceptionType
type
,
params
object
[]
details
)
{
Type
=
type
;
Details
=
details
;
}
public
enum
ExceptionType
{
ScriptCompilationFailed
,
PlatformNotFound
,
TestSettingsFileNotFound
,
}
}
}
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/SetupException.cs.meta
View file @
af571a61
fileFormatVersion: 2
guid: 63572993f2104574099a48392460b211
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 63572993f2104574099a48392460b211
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/TestStarter.cs
View file @
af571a61
using
System
;
using
System.IO
;
using
UnityEditor.TestRunner.CommandLineParser
;
using
UnityEditor.TestTools.TestRunner.Api
;
using
UnityEngine
;
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
[
InitializeOnLoad
]
static
class
TestStarter
{
static
TestStarter
()
{
if
(!
ShouldRunTests
())
{
return
;
}
if
(
EditorApplication
.
isCompiling
)
{
return
;
}
executer
.
ExitOnCompileErrors
();
if
(
RunData
.
instance
.
isRunning
)
{
executer
.
SetUpCallbacks
(
RunData
.
instance
.
executionSettings
);
return
;
}
EditorApplication
.
update
+=
UpdateWatch
;
}
static
void
UpdateWatch
()
{
EditorApplication
.
update
-=
UpdateWatch
;
if
(
RunData
.
instance
.
isRunning
)
{
return
;
}
RunData
.
instance
.
isRunning
=
true
;
var
commandLineArgs
=
Environment
.
GetCommandLineArgs
();
RunData
.
instance
.
executionSettings
=
executer
.
BuildExecutionSettings
(
commandLineArgs
);
executer
.
SetUpCallbacks
(
RunData
.
instance
.
executionSettings
);
executer
.
InitializeAndExecuteRun
(
commandLineArgs
);
}
static
bool
ShouldRunTests
()
{
var
shouldRunTests
=
false
;
var
optionSet
=
new
CommandLineOptionSet
(
new
CommandLineOption
(
"runTests"
,
()
=>
{
shouldRunTests
=
true
;
}),
new
CommandLineOption
(
"runEditorTests"
,
()
=>
{
shouldRunTests
=
true
;
})
);
optionSet
.
Parse
(
Environment
.
GetCommandLineArgs
());
return
shouldRunTests
;
}
static
Executer
s_Executer
;
static
Executer
executer
{
get
{
if
(
s_Executer
==
null
)
{
Func
<
bool
>
compilationCheck
=
()
=>
EditorUtility
.
scriptCompilationFailed
;
Action
<
string
>
actionLogger
=
(
string
msg
)
=>
{
Debug
.
LogFormat
(
LogType
.
Log
,
LogOption
.
NoStacktrace
,
null
,
msg
);
};
var
apiSettingsBuilder
=
new
SettingsBuilder
(
new
TestSettingsDeserializer
(()
=>
new
TestSettings
()),
actionLogger
,
Debug
.
LogWarning
,
File
.
Exists
,
compilationCheck
);
s_Executer
=
new
Executer
(
ScriptableObject
.
CreateInstance
<
TestRunnerApi
>(),
apiSettingsBuilder
,
Debug
.
LogErrorFormat
,
Debug
.
LogException
,
EditorApplication
.
Exit
,
compilationCheck
);
}
return
s_Executer
;
}
}
}
}
using
System
;
using
System.IO
;
using
UnityEditor.TestRunner.CommandLineParser
;
using
UnityEditor.TestTools.TestRunner.Api
;
using
UnityEngine
;
namespace
UnityEditor.TestTools.TestRunner.CommandLineTest
{
[
InitializeOnLoad
]
static
class
TestStarter
{
static
TestStarter
()
{
if
(!
ShouldRunTests
())
{
return
;
}
if
(
EditorApplication
.
isCompiling
)
{
return
;
}
executer
.
ExitOnCompileErrors
();
if
(
RunData
.
instance
.
isRunning
)
{
executer
.
SetUpCallbacks
(
RunData
.
instance
.
executionSettings
);
return
;
}
EditorApplication
.
update
+=
UpdateWatch
;
}
static
void
UpdateWatch
()
{
EditorApplication
.
update
-=
UpdateWatch
;
if
(
RunData
.
instance
.
isRunning
)
{
return
;
}
RunData
.
instance
.
isRunning
=
true
;
var
commandLineArgs
=
Environment
.
GetCommandLineArgs
();
RunData
.
instance
.
executionSettings
=
executer
.
BuildExecutionSettings
(
commandLineArgs
);
executer
.
SetUpCallbacks
(
RunData
.
instance
.
executionSettings
);
executer
.
InitializeAndExecuteRun
(
commandLineArgs
);
}
static
bool
ShouldRunTests
()
{
var
shouldRunTests
=
false
;
var
optionSet
=
new
CommandLineOptionSet
(
new
CommandLineOption
(
"runTests"
,
()
=>
{
shouldRunTests
=
true
;
}),
new
CommandLineOption
(
"runEditorTests"
,
()
=>
{
shouldRunTests
=
true
;
})
);
optionSet
.
Parse
(
Environment
.
GetCommandLineArgs
());
return
shouldRunTests
;
}
static
Executer
s_Executer
;
static
Executer
executer
{
get
{
if
(
s_Executer
==
null
)
{
Func
<
bool
>
compilationCheck
=
()
=>
EditorUtility
.
scriptCompilationFailed
;
Action
<
string
>
actionLogger
=
(
string
msg
)
=>
{
Debug
.
LogFormat
(
LogType
.
Log
,
LogOption
.
NoStacktrace
,
null
,
msg
);
};
var
apiSettingsBuilder
=
new
SettingsBuilder
(
new
TestSettingsDeserializer
(()
=>
new
TestSettings
()),
actionLogger
,
Debug
.
LogWarning
,
File
.
Exists
,
compilationCheck
);
s_Executer
=
new
Executer
(
ScriptableObject
.
CreateInstance
<
TestRunnerApi
>(),
apiSettingsBuilder
,
Debug
.
LogErrorFormat
,
Debug
.
LogException
,
EditorApplication
.
Exit
,
compilationCheck
);
}
return
s_Executer
;
}
}
}
}
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/CommandLineTest/TestStarter.cs.meta
View file @
af571a61
fileFormatVersion: 2
guid: 4d616d1a494edd144b262cf6cd5e5fda
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 4d616d1a494edd144b262cf6cd5e5fda
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/GUI.meta
View file @
af571a61
fileFormatVersion: 2
guid: 7e609b27ad2caa14c83dd9951b6c13c6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 7e609b27ad2caa14c83dd9951b6c13c6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/GUI/AssetsDatabaseHelper.cs
View file @
af571a61
namespace
UnityEditor.TestTools.TestRunner.GUI
{
internal
class
AssetsDatabaseHelper
:
IAssetsDatabaseHelper
{
public
void
OpenAssetInItsDefaultExternalEditor
(
string
assetPath
,
int
line
)
{
var
asset
=
AssetDatabase
.
LoadMainAssetAtPath
(
assetPath
);
AssetDatabase
.
OpenAsset
(
asset
,
line
);
}
}
}
namespace
UnityEditor.TestTools.TestRunner.GUI
{
internal
class
AssetsDatabaseHelper
:
IAssetsDatabaseHelper
{
public
void
OpenAssetInItsDefaultExternalEditor
(
string
assetPath
,
int
line
)
{
var
asset
=
AssetDatabase
.
LoadMainAssetAtPath
(
assetPath
);
AssetDatabase
.
OpenAsset
(
asset
,
line
);
}
}
}
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/GUI/AssetsDatabaseHelper.cs.meta
View file @
af571a61
fileFormatVersion: 2
guid: 740b3785866edda4b8d1e1a05570a5f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 740b3785866edda4b8d1e1a05570a5f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/GUI/GuiHelper.cs
View file @
af571a61
using
System
;
using
System.IO
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text.RegularExpressions
;
using
UnityEditor.Utils
;
using
UnityEngine
;
namespace
UnityEditor.TestTools.TestRunner.GUI
{
internal
class
GuiHelper
:
IGuiHelper
{
public
GuiHelper
(
IMonoCecilHelper
monoCecilHelper
,
IAssetsDatabaseHelper
assetsDatabaseHelper
)
{
MonoCecilHelper
=
monoCecilHelper
;
AssetsDatabaseHelper
=
assetsDatabaseHelper
;
}
protected
IMonoCecilHelper
MonoCecilHelper
{
get
;
private
set
;
}
public
IAssetsDatabaseHelper
AssetsDatabaseHelper
{
get
;
private
set
;
}
public
void
OpenScriptInExternalEditor
(
Type
type
,
MethodInfo
method
)
{
var
fileOpenInfo
=
GetFileOpenInfo
(
type
,
method
);
if
(
string
.
IsNullOrEmpty
(
fileOpenInfo
.
FilePath
))
{
Debug
.
LogWarning
(
"Failed to open test method source code in external editor. Inconsistent filename and yield return operator in target method."
);
return
;
}
if
(
fileOpenInfo
.
LineNumber
==
1
)
{
Debug
.
LogWarning
(
"Failed to get a line number for unity test method. So please find it in opened file in external editor."
);
}
AssetsDatabaseHelper
.
OpenAssetInItsDefaultExternalEditor
(
fileOpenInfo
.
FilePath
,
fileOpenInfo
.
LineNumber
);
}
public
IFileOpenInfo
GetFileOpenInfo
(
Type
type
,
MethodInfo
method
)
{
const
string
fileExtension
=
".cs"
;
var
fileOpenInfo
=
MonoCecilHelper
.
TryGetCecilFileOpenInfo
(
type
,
method
);
if
(
string
.
IsNullOrEmpty
(
fileOpenInfo
.
FilePath
))
{
var
dirPath
=
Paths
.
UnifyDirectorySeparator
(
Application
.
dataPath
);
var
allCsFiles
=
Directory
.
GetFiles
(
dirPath
,
$"*
{
fileExtension
}
"
,
SearchOption
.
AllDirectories
)
.
Select
(
Paths
.
UnifyDirectorySeparator
);
var
fileName
=
allCsFiles
.
FirstOrDefault
(
x
=>
x
.
Split
(
Path
.
DirectorySeparatorChar
).
Last
().
Equals
(
string
.
Concat
(
type
.
Name
,
fileExtension
)));
fileOpenInfo
.
FilePath
=
fileName
??
string
.
Empty
;
}
fileOpenInfo
.
FilePath
=
FilePathToAssetsRelativeAndUnified
(
fileOpenInfo
.
FilePath
);
return
fileOpenInfo
;
}
public
string
FilePathToAssetsRelativeAndUnified
(
string
filePath
)
{
if
(
string
.
IsNullOrEmpty
(
filePath
))
return
string
.
Empty
;
filePath
=
Paths
.
UnifyDirectorySeparator
(
filePath
);
var
length
=
Paths
.
UnifyDirectorySeparator
(
Application
.
dataPath
).
Length
-
"Assets"
.
Length
;
return
filePath
.
Substring
(
length
);
}
public
bool
OpenScriptInExternalEditor
(
string
stacktrace
)
{
if
(
string
.
IsNullOrEmpty
(
stacktrace
))
return
false
;
var
regex
=
new
Regex
(
"in (?<path>.*):{1}(?<line>[0-9]+)"
);
var
matchingLines
=
stacktrace
.
Split
(
new
[]
{
Environment
.
NewLine
},
StringSplitOptions
.
RemoveEmptyEntries
).
Where
(
x
=>
regex
.
IsMatch
(
x
)).
ToList
();
if
(!
matchingLines
.
Any
())
return
false
;
var
fileOpenInfos
=
matchingLines
.
Select
(
x
=>
regex
.
Match
(
x
))
.
Select
(
x
=>
new
FileOpenInfo
{
FilePath
=
x
.
Groups
[
"path"
].
Value
,
LineNumber
=
int
.
Parse
(
x
.
Groups
[
"line"
].
Value
)
}).
ToList
();
var
fileOpenInfo
=
fileOpenInfos
.
FirstOrDefault
(
openInfo
=>
!
string
.
IsNullOrEmpty
(
openInfo
.
FilePath
)
&&
File
.
Exists
(
openInfo
.
FilePath
));
if
(
fileOpenInfo
==
null
)
{
return
false
;
}
var
filePath
=
FilePathToAssetsRelativeAndUnified
(
fileOpenInfo
.
FilePath
);
AssetsDatabaseHelper
.
OpenAssetInItsDefaultExternalEditor
(
filePath
,
fileOpenInfo
.
LineNumber
);
return
true
;
}
}
}
using
System
;
using
System.IO
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text.RegularExpressions
;
using
UnityEditor.Utils
;
using
UnityEngine
;
namespace
UnityEditor.TestTools.TestRunner.GUI
{
internal
class
GuiHelper
:
IGuiHelper
{
public
GuiHelper
(
IMonoCecilHelper
monoCecilHelper
,
IAssetsDatabaseHelper
assetsDatabaseHelper
)
{
MonoCecilHelper
=
monoCecilHelper
;
AssetsDatabaseHelper
=
assetsDatabaseHelper
;
}
protected
IMonoCecilHelper
MonoCecilHelper
{
get
;
private
set
;
}
public
IAssetsDatabaseHelper
AssetsDatabaseHelper
{
get
;
private
set
;
}
public
void
OpenScriptInExternalEditor
(
Type
type
,
MethodInfo
method
)
{
var
fileOpenInfo
=
GetFileOpenInfo
(
type
,
method
);
if
(
string
.
IsNullOrEmpty
(
fileOpenInfo
.
FilePath
))
{
Debug
.
LogWarning
(
"Failed to open test method source code in external editor. Inconsistent filename and yield return operator in target method."
);
return
;
}
if
(
fileOpenInfo
.
LineNumber
==
1
)
{
Debug
.
LogWarning
(
"Failed to get a line number for unity test method. So please find it in opened file in external editor."
);
}
AssetsDatabaseHelper
.
OpenAssetInItsDefaultExternalEditor
(
fileOpenInfo
.
FilePath
,
fileOpenInfo
.
LineNumber
);
}
public
IFileOpenInfo
GetFileOpenInfo
(
Type
type
,
MethodInfo
method
)
{
const
string
fileExtension
=
".cs"
;
var
fileOpenInfo
=
MonoCecilHelper
.
TryGetCecilFileOpenInfo
(
type
,
method
);
if
(
string
.
IsNullOrEmpty
(
fileOpenInfo
.
FilePath
))
{
var
dirPath
=
Paths
.
UnifyDirectorySeparator
(
Application
.
dataPath
);
var
allCsFiles
=
Directory
.
GetFiles
(
dirPath
,
$"*
{
fileExtension
}
"
,
SearchOption
.
AllDirectories
)
.
Select
(
Paths
.
UnifyDirectorySeparator
);
var
fileName
=
allCsFiles
.
FirstOrDefault
(
x
=>
x
.
Split
(
Path
.
DirectorySeparatorChar
).
Last
().
Equals
(
string
.
Concat
(
type
.
Name
,
fileExtension
)));
fileOpenInfo
.
FilePath
=
fileName
??
string
.
Empty
;
}
fileOpenInfo
.
FilePath
=
FilePathToAssetsRelativeAndUnified
(
fileOpenInfo
.
FilePath
);
return
fileOpenInfo
;
}
public
string
FilePathToAssetsRelativeAndUnified
(
string
filePath
)
{
if
(
string
.
IsNullOrEmpty
(
filePath
))
return
string
.
Empty
;
filePath
=
Paths
.
UnifyDirectorySeparator
(
filePath
);
var
length
=
Paths
.
UnifyDirectorySeparator
(
Application
.
dataPath
).
Length
-
"Assets"
.
Length
;
return
filePath
.
Substring
(
length
);
}
public
bool
OpenScriptInExternalEditor
(
string
stacktrace
)
{
if
(
string
.
IsNullOrEmpty
(
stacktrace
))
return
false
;
var
regex
=
new
Regex
(
"in (?<path>.*):{1}(?<line>[0-9]+)"
);
var
matchingLines
=
stacktrace
.
Split
(
new
[]
{
Environment
.
NewLine
},
StringSplitOptions
.
RemoveEmptyEntries
).
Where
(
x
=>
regex
.
IsMatch
(
x
)).
ToList
();
if
(!
matchingLines
.
Any
())
return
false
;
var
fileOpenInfos
=
matchingLines
.
Select
(
x
=>
regex
.
Match
(
x
))
.
Select
(
x
=>
new
FileOpenInfo
{
FilePath
=
x
.
Groups
[
"path"
].
Value
,
LineNumber
=
int
.
Parse
(
x
.
Groups
[
"line"
].
Value
)
}).
ToList
();
var
fileOpenInfo
=
fileOpenInfos
.
FirstOrDefault
(
openInfo
=>
!
string
.
IsNullOrEmpty
(
openInfo
.
FilePath
)
&&
File
.
Exists
(
openInfo
.
FilePath
));
if
(
fileOpenInfo
==
null
)
{
return
false
;
}
var
filePath
=
FilePathToAssetsRelativeAndUnified
(
fileOpenInfo
.
FilePath
);
AssetsDatabaseHelper
.
OpenAssetInItsDefaultExternalEditor
(
filePath
,
fileOpenInfo
.
LineNumber
);
return
true
;
}
}
}
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/GUI/GuiHelper.cs.meta
View file @
af571a61
fileFormatVersion: 2
guid: d0138170d24533e47b8e6c250c6d7fbc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d0138170d24533e47b8e6c250c6d7fbc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/GUI/IAssetsDatabaseHelper.cs
View file @
af571a61
namespace
UnityEditor.TestTools.TestRunner.GUI
{
internal
interface
IAssetsDatabaseHelper
{
void
OpenAssetInItsDefaultExternalEditor
(
string
assetPath
,
int
line
);
}
}
namespace
UnityEditor.TestTools.TestRunner.GUI
{
internal
interface
IAssetsDatabaseHelper
{
void
OpenAssetInItsDefaultExternalEditor
(
string
assetPath
,
int
line
);
}
}
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/GUI/IAssetsDatabaseHelper.cs.meta
View file @
af571a61
fileFormatVersion: 2
guid: 208e46d59ff6e304db0318377d20f5a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 208e46d59ff6e304db0318377d20f5a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
MathTec/Library/PackageCache/com.unity.test-framework@1.1.14/UnityEditor.TestRunner/GUI/IGuiHelper.cs
View file @
af571a61
using
System
;
using
System.Reflection
;
namespace
UnityEditor.TestTools.TestRunner.GUI
{
internal
interface
IGuiHelper
{
bool
OpenScriptInExternalEditor
(
string
stacktrace
);
void
OpenScriptInExternalEditor
(
Type
type
,
MethodInfo
method
);
IFileOpenInfo
GetFileOpenInfo
(
Type
type
,
MethodInfo
method
);
string
FilePathToAssetsRelativeAndUnified
(
string
filePath
);
}
}
using
System
;
using
System.Reflection
;
namespace
UnityEditor.TestTools.TestRunner.GUI
{
internal
interface
IGuiHelper
{
bool
OpenScriptInExternalEditor
(
string
stacktrace
);
void
OpenScriptInExternalEditor
(
Type
type
,
MethodInfo
method
);
IFileOpenInfo
GetFileOpenInfo
(
Type
type
,
MethodInfo
method
);
string
FilePathToAssetsRelativeAndUnified
(
string
filePath
);
}
}
Prev
1
…
14
15
16
17
18
19
20
21
22
…
38
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment