Welp, that broke everything!
I added this to my test setup:
[SetUp]
public void SetUp() {
inputTester.Setup();
}
[TearDown]
public void TearDown() {
inputTester.TearDown();
}
When that’s there, interacting with the inputTester during tests causes nullRefs deep in the input system. This line of code:
inputTester.PressAndRelease(gamePad.buttonSouth);
Gives this error:
TestLedgeHandling_Blink1 (0,316s)
---
System.NullReferenceException : Object reference not set to an instance of an object
---
at UnityEngine.InputSystem.LowLevel.InputStateBuffers+DoubleBuffers.GetFrontBuffer (System.Int32 deviceIndex) [0x00001] in E:\Teslagrad2\Library\PackageCache\com.unity.inputsystem@1.1.0-preview.1\InputSystem\State\InputStateBuffers.cs:73
at UnityEngine.InputSystem.LowLevel.InputStateBuffers.GetFrontBufferForDevice (System.Int32 deviceIndex) [0x00001] in E:\Teslagrad2\Library\PackageCache\com.unity.inputsystem@1.1.0-preview.1\InputSystem\State\InputStateBuffers.cs:126
at UnityEngine.InputSystem.InputControl.get_currentStatePtr () [0x00000] in E:\Teslagrad2\Library\PackageCache\com.unity.inputsystem@1.1.0-preview.1\InputSystem\Controls\InputControl.cs:788
at UnityEngine.InputSystem.LowLevel.DeltaStateEvent.From (UnityEngine.InputSystem.InputControl control, UnityEngine.InputSystem.LowLevel.InputEventPtr& eventPtr, Unity.Collections.Allocator allocator) [0x00074] in E:\Teslagrad2\Library\PackageCache\com.unity.inputsystem@1.1.0-preview.1\InputSystem\Events\DeltaStateEvent.cs:88
at UnityEngine.InputSystem.InputTestFixture.Set[TValue] (UnityEngine.InputSystem.InputControl`1[TValue] control, TValue state, System.Double time, System.Double timeOffset, System.Boolean queueEventOnly) [0x000b4] in E:\Teslagrad2\Library\PackageCache\com.unity.inputsystem@1.1.0-preview.1\Tests\TestFixture\InputTestFixture.cs:457
at UnityEngine.InputSystem.InputTestFixture.Press (UnityEngine.InputSystem.Controls.ButtonControl button, System.Double time, System.Double timeOffset, System.Boolean queueEventOnly) [0x00001] in E:\Teslagrad2\Library\PackageCache\com.unity.inputsystem@1.1.0-preview.1\Tests\TestFixture\InputTestFixture.cs:347
at UnityEngine.InputSystem.InputTestFixture.PressAndRelease (UnityEngine.InputSystem.Controls.ButtonControl button, System.Double time, System.Double timeOffset, System.Boolean queueEventOnly) [0x00001] in E:\Teslagrad2\Library\PackageCache\com.unity.inputsystem@1.1.0-preview.1\Tests\TestFixture\InputTestFixture.cs:359
at Tests.TestLedgeGrab+<TestLedgeHandlingForSpawnPoint>d__24.MoveNext () [0x00186] in E:\Teslagrad2\Assets\Scripts\Editor\Unit Tests\Runtime Tests\TestLedgeGrab.cs:89
at UnityEngine.TestTools.TestEnumerator+<Execute>d__6.MoveNext () [0x0004c] in E:\Teslagrad2\Library\PackageCache\com.unity.test-framework@1.1.18\UnityEngine.TestRunner\NUnitExtensions\Attributes\TestEnumerator.cs:36
I also managed to break Unity completely when doing things. I did it by messing up stuff when experimenting, but it’s a very easy repro; run this code:
[MenuItem("Test/Break Unity Kinda")]
public static void EnoughToBreakUnity() {
new InputTestFixture().TearDown();
}
And then recompile anything. Unity will start spamming two errors outside of play mode until the editor is restarted completely:
Error 1:
TypeInitializationException during event processing of Editor update; resetting event buffer
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
Error 2:
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.InputSystem.InputSystem.InitializeInEditor (UnityEngine.InputSystem.LowLevel.IInputRuntime runtime) (at Library/PackageCache/com.unity.inputsystem@1.1.0-preview.1/InputSystem/InputSystem.cs:2999)
UnityEngine.InputSystem.InputSystem..cctor () (at Library/PackageCache/com.unity.inputsystem@1.1.0-preview.1/InputSystem/InputSystem.cs:2916)
Rethrow as TypeInitializationException: The type initializer for 'UnityEngine.InputSystem.InputSystem' threw an exception.
UnityEngine.InputSystem.InputAnalytics.OnStartup (UnityEngine.InputSystem.InputManager manager) (at Library/PackageCache/com.unity.inputsystem@1.1.0-preview.1/InputSystem/InputAnalytics.cs:25)
UnityEngine.InputSystem.InputManager.OnUpdate (UnityEngine.InputSystem.LowLevel.InputUpdateType updateType, UnityEngine.InputSystem.LowLevel.InputEventBuffer& eventBuffer) (at Library/PackageCache/com.unity.inputsystem@1.1.0-preview.1/InputSystem/InputManager.cs:2537)
UnityEngine.InputSystem.LowLevel.NativeInputRuntime+<>c__DisplayClass7_0.<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType updateType, UnityEngineInternal.Input.NativeInputEventBuffer* eventBufferPtr) (at Library/PackageCache/com.unity.inputsystem@1.1.0-preview.1/InputSystem/NativeInputRuntime.cs:60)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
So right now it looks to me like any call to InputTestFixture.SetUp or TearDown will break the tests, and also maybe Unity.