A game about forced loneliness, made by TACStudios
1using System;
2using System.Collections;
3using NUnit.Framework.Interfaces;
4using NUnit.Framework.Internal;
5using NUnit.Framework.Internal.Commands;
6using UnityEditor;
7using UnityEngine.TestRunner.NUnitExtensions.Runner;
8#if UNITY_EDITOR
9using UnityEditorInternal;
10#endif
11
12namespace UnityEngine.TestTools
13{
14 internal class StrictCheckCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
15 {
16 public StrictCheckCommand(TestCommand innerCommand) : base(innerCommand)
17 {
18 }
19
20 public override TestResult Execute(ITestExecutionContext context)
21 {
22 throw new NotImplementedException();
23 }
24
25 public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
26 {
27 var unityContext = UnityTestExecutionContext.CurrentContext;
28 var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
29 foreach (var iterator in executeEnumerable)
30 {
31 yield return iterator;
32 }
33
34 if (!unityContext.FeatureFlags.strictDomainReload)
35 {
36 yield break;
37 }
38 // Refreshing the asset database before the check, to ensure that
39 // no potential pending domain reloads propagate to the following test
40 // (due to ex. creation or deletion of asset files in the TearDown of a test).
41#if UNITY_EDITOR
42 AssetDatabase.Refresh();
43#endif
44 if (isDomainReloadPending())
45 {
46 context.CurrentResult.SetResult(ResultState.Failure, "A pending domain reload was detected.");
47 }
48 }
49 private static bool isDomainReloadPending()
50 {
51#if UNITY_EDITOR
52 return (InternalEditorUtility.IsScriptReloadRequested() || EditorApplication.isCompiling);
53#else
54 return false;
55#endif
56 }
57 }
58}