I added the Debounce
class taken from here: https://stackoverflow.com/a/59296478/945247
This class has the unit test below which passes locally but fails on AppCenter with the error "Variable used within its own initial value":
func test_entering_text_delays_processing_until_settled() {
let expect = expectation(description: "processing completed")
var finalString: String = ""
var timesCalled: Int = 0
let process: (String) -> () = {
finalString = $0
timesCalled += 1
expect.fulfill()
}
Debounce<String>.input("A", comparedAgainst: "AB", perform: process)
Debounce<String>.input("AB", comparedAgainst: "ABCD", perform: process)
Debounce<String>.input("ABCD", comparedAgainst: "ABC", perform: process)
Debounce<String>.input("ABC", comparedAgainst: "ABC", perform: process)
wait(for: [expect], timeout: 2.0)
XCTAssertEqual(finalString, "ABC")
XCTAssertEqual(timesCalled, 1)
}
I can't see anyting in that code which would cause that error, let alone just on AppCenter.
Edit:
Here's the full details I have from the AppCenter logs:
2021-10-06T16:05:31.0647180Z Testing failed:
2021-10-06T16:05:31.0647560Z Variable used within its own initial value
2021-10-06T16:05:31.0647980Z Testing cancelled because the build failed.
2021-10-06T16:05:31.0648180Z
2021-10-06T16:05:31.0648460Z ** TEST FAILED **
2021-10-06T16:05:31.0648610Z
2021-10-06T16:05:31.0648720Z
2021-10-06T16:05:31.0649050Z The following build commands failed:
2021-10-06T16:05:31.0649560Z CompileSwift normal x86_64 /Users/runner/work/1/s/AppTests/Utilities/DebounceTests.swift
2021-10-06T16:05:31.0650120Z CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
I have been able to confirm that it's the debounce tests which are causing the failure because I commented out the above test and the app built, when I uncommented it the build failed with the same error.