Как собрать ошибки stdout и std из пакета .xcresult, сгенерированного моими модульными тестами XCUI? - PullRequest
1 голос
/ 01 октября 2019

В Xcode 10 и ниже, stdout и stderror прогона набора тестов могут быть найдены и извлечены из указанного -resultBundlePath с помощью этой команды оболочки:

cp -fv $(find $resultBundlePath/1_Test -print | grep TestSuite1 | grep 'StandardOutputAndStandardError.txt' | xargs) TestSuite1Xctestrun.log"

В Xcode 11+ этот файл больше не находится в комплекте.

Где и как извлечь его из xcbundle?

1 Ответ

2 голосов
/ 01 октября 2019

xcrun xcresulttool --formatDescription показывает, что существует ключ logRef с уникальным значением, указывающим на журнал, который мы можем запросить, если знаем идентификатор элемента.

Используя jq, я смог выполнить эту задачу.

Сначала мы получаем идентификатор logRef, затем извлекаем его значение из пакета .xcresult в текстовый файл.

# find the id that points to the location of the encoded file in the .xcresult bundle
id=$(xcrun xcresulttool get --format json --path Tests.xcresult | jq '.actions._values[]' | jq -r '.actionResult.logRef.id._value')
# export the log found at the the id in the .xcresult bundle
xcrun xcresulttool export --path Tests.xcresult --id $id --output-path TestsStdErrorStdout.log --type file
...