We use .xcresult
files on our CI and recently noticed that size of file significantly increased. So previously we had files ~ 50 MB but now they are ~ 300 MB.
After investigation of .xcresult
contents we found that it contains macOS Logs - test-session-systemlogs-2022.01.05_13-13-07-+0000
In testmanagerd .log we see in a last line:
Moved logarchive from /var/tmp/test-session-systemlogs-2022.01.05_13-13-07-+0000.logarchive to ../Staging/1_Test/Diagnostics/My Mac_4203018E-580F-C1B5-9525-B745CECA79EB/test-session-systemlogs-2022.01.05_13-13-07-+0000.logarchive
Issue is reproducible on a new project. Steps:
- File -> New -> Project
- Select macOS -> App
- Enable include test
- For simplicity disable(comment) all the UITests except ResultSampleUITests::testExample
- Add XCTAssertTrue(false) after app.launch()
- Run tests from console and specify path to resultBundlePath
xcodebuild -project ResultSample.xcodeproj -scheme ResultSample -resultBundlePath ~/Downloads/2/all-tests -test-timeouts-enabled YES test
7. When tests are finished navigate to resultBundlePath and check size of all-tests.xcresult.
It has size 51.6 MB for me.
If change XCTAssertTrue(false
) to XCTAssertTrue(true)
then size of all-tests.xcresult is decreased to 31 KB.
Any idea how to disable/delete macOS diagnostic logs or decrease a size of .xcresult
You can stop XCTest from collecting test diagnostics when it encounters a failure or error in 1 of 2 ways:
- From within the test plan. You can set the
Collect test diagnostics on failure
setting toNever
- Or from the Command-line, with the flag
-collect-test-diagnostics never
The command line setting overrides the test plan setting, so opposing values have a deterministic behavior. For example, if you set the test plan to Always
but the commandline to Never
, then test diagnostics are not collected.