How do I collect the stdout and std error from the .xcresult bundle generated by my XCUI Unit Tests? - xcode11

In Xcode 10 and below, the stdout and stderror of the test suite run could be found and extracted from inside the specified -resultBundlePath using this shell command:
cp -fv $(find $resultBundlePath/1_Test -print | grep TestSuite1 | grep 'StandardOutputAndStandardError.txt' | xargs) TestSuite1Xctestrun.log"
With Xcode 11+, this file no longer is found in the bundle.
Where and how do I extract it from the xcbundle?

xcrun xcresulttool --formatDescription shows that there is a logRef key with a unique value pointing to the log that we can query for if we know the item's ID.
Using jq, I was able accomplish this task.
First we get the id of the logRef, then we extract its value from the .xcresult bundle into a text file.
# 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

Related

Bash script to download latest release from GitHub

Looking for a simple way to download a .zip from a latest GitHub release.
There are other similar questions, but I havent been able to get them to work. :(
Trying to pull latest release from https://github.com/CTCaer/hekate
Currently ive got:
#!/bin/bash
curl -s https://api.github.com/repos/CTCaer/hekate/releases/latest | jq -r ".assets[] | select(.name | test(\"hekate_ctcaer\")) | .browser_download_url"
trying to fetch the url of the latest .zip and only grab the "hekate_ctcaer_X.X.X_Nyx_X.X.X.zip"
I saw someone trying to achieve this with 'Xidel', so im open to trying that if someone knows the syntax to grab a specific file from the GitHub api.
As I understand it (?), the Github API spits out an array for the release 'assets', so im trying to specify an item in this array that matches "hekate_ctcaer", and download the specified file.
Github is also a compatible git repo. I provide a new train of thought.
use git ls-remote to fetch last release tag.
git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' http://github.com/CTCaer/hekate.git
| tail --lines=1
| cut --delimiter='/' --fields=3
Here this examples outputs v5.8.0
then clone remote repo
git clone --branch v5.8.0 http://github.com/CTCaer/hekate.git
zip repos to zipped file.
zip hekate.zip -r hekate/
This will print out the url to the zip file of the latest release:
curl -sL https://api.github.com/repos/CTCaer/hekate/tags \
| jq -r '.[0].zipball_url' \
| xargs -I {} curl -sL {} -o latest.zip
I saw someone trying to achieve this with 'Xidel'
I assume you're referring to my answer here. That answer is tagged batch-file, so you first of all have to swop the quotes for bash ("function('string')" --> 'function("string")'). And secondly, you're right. You have to select the appropriate object in the "assets"-array.
$ xidel -s "https://api.github.com/repos/CTCaer/hekate/releases/latest" \
-f '$json/(assets)()[starts-with(name,"hekate_ctcaer")]/browser_download_url' \
--download '{substring-after($headers[starts-with(.,"Content-Disposition")],"filename=")}'
This downloads 'hekate_ctcaer_5.8.0_Nyx_1.3.0.zip' in the current dir.
With r8389 or newer you can just use --download ..
also how would I modify this for the following: github.com/Atmosphere-NX/Atmosphere/releases/tag/1.3.2 the .zip AND the .bin
Strictly speaking you'd have to raise a new question for this, but ok.
It appears that (at the moment) v1.3.2 is also the latest release for this repo, so you can use...
$ xidel -s "https://api.github.com/repos/Atmosphere-NX/Atmosphere/releases/latest" \
-e '$json'
or alternatively...
$ xidel -s "https://api.github.com/repos/Atmosphere-NX/Atmosphere/releases" \
-e '$json()[tag_name="1.3.2"]'
The "assets"-array here has just 2 objects; one with the zip-file and one with the bin-file, so just "follow" (--follow / -f) the 2 "browser_download_url"-keys to download:
$ xidel -s "https://api.github.com/repos/Atmosphere-NX/Atmosphere/releases" \
-f '$json()[tag_name="1.3.2"]//browser_download_url' \
--download .

docker mkdir won't create a directory

I am trying to run a bash script which should load data into jena. This script comes from a github repository and was allegedly working on the owner's machine but on mine it won't run, even though I followed the instructions. So let me first describe what the script does based on my understanding: It should load .nt data (RDF data) into Jena using docker by using the docker image of jena, named stain/jena. Here is the script:
#/bin/bash
files=$(echo $(pwd)/rawdata-bearb/hour/alldata.IC.nt/*.nt | sed "s%$(pwd)/rawdata-bearb/hour/alldata.IC.nt%/var/data/in%g")
mkdir output # added
for file in $files; do
v=$(echo $file | sed "s/^.*\/\([0-9][0-9]*\)\.nt$/\1-1/" | bc)
echo "$v"
mkdir -p /var/data/out/ic/$v
time docker run \
-it \
--rm \
-v $(pwd)/tdb-bearb-hour/:/var/data/out/ \
-v $(pwd)/rawdata-bearb/hour/alldata.IC.nt/:/var/data/in/ \
stain/jena /jena/bin/tdbloader2 \
--sort-args "-S=16G" \
--loc /var/data/out/ic/$v $file \
> output/load-bearb-hour-ic-$v-.txt
done
However, when I execute the script, I get following message from the saved log file:
13:12:46 INFO -- TDB Bulk Loader Start
mkdir: cannot create directory ‘/var/data/out/ic/0’: No such file or directory
13:12:46 ERROR Failed during data phase
According to the tdbloader2 manual the --loc parameter should create the directory if it does not exist
-- loc: Sets the location in which the database should be created.
This location must be a directory and must be empty,
if a non-existent path is specified it will be created as a new directory.
I created the directories /var/data/out/ic/0 - /var/data/out/ic/10 manually and re-executed the script. Still, I got the same error message. My first guess was that tdbloader2 or docker use the mkdir command without the -p parameter but since I manually created the directories, thus, they existed before the execution and I still got the same error, it must be something else. I am kindly asking for your help

Get an xcode project's bundle id from bash

How can I get the bundle identifier of the project from bash?
I've got a couple of similar xcode projects for iOS. I'm trying to get some thing done via scripts but can't figure out how to get/change project configurations (like bundle id and version) from bash.
How can I get the bundle identifier of the project from bash?
Run the following command inside the code directory:
$ grep -R PRODUCT_BUNDLE_IDENTIFIER *
$ grep -R PRODUCT_BUNDLE_IDENTIFIER *|awk -F= '{print $2}'|sed 's/ //g'|sed 's/;//g'

Unable to generate HTML Report

I use the below mentioned command to generate HTML Report in jmeter.
D:\JmeterTool\apache-jmeter-5.0\bin>jmeter -n
-t "D:\JmeterTool\coreApi's.jmx"
-l D:\JmeterTool\JmeterReports\16012019.csv
-e -o D:\JmeterTool\HTMLReports
Whenever I run this command I get an error:
Error in NonGUIDriver java.lang.IllegalArgumentException:
Results file:D:\JmeterTool\JmeterReports\16012019.csv is not empty
although this CSV file is empty.
You should use -f or --forceDeleteResultFile flag to override results file
force delete existing results files before start the test
jmeter -n -t "D:\JmeterTool\coreApi's.jmx" -f -l D:\JmeterTool\JmeterReports\16012019.csv -e -o D:\JmeterTool\HTMLReports

mv command not working on mac

Here is the part of the makefile that is giving me issues:
-#mv -f -t ./ $(LIBPATH)/userfiles/*
When I run the makefile on Ubuntu it works fine however when running on my Mac I get the following error:
mv: illegal option -- t usage: mv [-f | -i | -n] [-v] source target
mv [-f | -i | -n] [-v] source ... directory
The -t flag is not defined in the man pages of my mac so I'm wondering how I can get around this.
Just put the destination at the end like how mv is normally used:
-#mv -f $(LIBPATH)/userfiles/* .
You are allowed to have multiple sources (such as the expanded wildcard here). The last argument is the destination. The -t flag is just a way to change this ordering if you have to for some reason, and (as you discovered) it is not always available.
Install coreutils by typing the following command in the terminal:
brew install coreutils
Commands also provided by macOS and the commands dir, dircolors, vdir have been installed with the prefix "g".
If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH with:
PATH="$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"
Reference:
coreutils - Homebrew Formulae

Resources