Closed EaseTheWorld closed 1 year ago
Yes, it should be possible. Unfortunately the paths in the xcresult file are absolut and it is not easy to figure out the relative path names. Sonar however requires the relative paths. In order for the xcresultparser to figure out how to convert to relative paths you need to pass the root directory as parameter. Then the paths can be converted.
Oh maybe I remember wrong and mixed up requirements.
Read the chapter "About paths for the sonarqube scanner" at the end of the Readme. For me that works with sonarqube.
I read the chapter but it is two different things to me.
<file path="Full/Path/LoggingTests.swift">
.<file path="LoggingTests">
My case is 2. but you're saying 1. For 1, I can use for sonarqube by replacing some path absolute->relative. but For 2, I can't do anything about it because I don't have any info about directory.
Am I missing something? or my xcresult file is wrong?(I'm using XCode 14.3, MacOS 13.2)
I will look into it, whether xcresult changed lately in this regard. We use the sonar scanner as well with our project and there we can see the tests. I will see, what I can find out.
The xcresult file only shows the class name of the test class. xcresultparser now uses grep
to find the file, where your test class is defined. It searches through all files in your "project root" folder for "class
Thank you for check. Then xcresult never provides full path but only classname, and you've grepped to get fullpath and pass to sonarqube?
or it depends on xcode version?
2023년 5월 19일 (금) 오후 9:46, alex da franca @.***>님이 작성:
The xcresult file only shows the class name of the test class. xcresultparser now uses grep to find the file, where your test class is defined. It searches through all files in your "project root" folder for "class " and very naively uses the first matching file. If the string "class " appears more than once it might be the case, that the wrong file is found.
— Reply to this email directly, view it on GitHub https://github.com/a7ex/xcresultparser/issues/18#issuecomment-1554520466, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIEPKY62B6LS4NVFQDFHVLXG5TSHANCNFSM6AAAAAAYGFJ3YM . You are receiving this because you authored the thread.Message ID: @.***>
Yes, that's exactly what xcresultparser does. The xcresult file provides the name of the test class and xcresultparser greps in the provided project folder for swift files which contain the string 'class name-of-the-testclass' (I just realised, that what I did in my last response got chopped by GitHub, where I used 'opening-bracket' name-of-test-class 'closing-bracket'). That is a rather "naive" approach and it will break easily, but as far as my research goes, it is the only tool, which converts xcresult files to expose the tests to SonarQube due to this "dirty trick".
If you do not run the SonarQube command line tool in the source folder of your project, but rather only have the xcresult file, there is not much I can do about it. The sonarqube command line tool needs to run in the sources folder where the tests are, which created the xcresult. It needs to scan the test files themselves.
I looked into the logic and found ActionTestableSummary
includes projectRelativePath
, ex. Module1/Domain1/Module1Domain1.xcodeproj.
I think this can optimize the grep logic by narrowing down the search scope. especially for multi-module project.
Thanks for the hint. I will look into that.
When I run
xcresultparser -o xml Test-logging.xcresult
output is like below.but when I passed this to sonar-scanner, it wasn't processed. because sonar-scanner expects,
<file path="Full/Path/LoggingTests.swift">
https://docs.sonarqube.org/latest/analyzing-source-code/test-coverage/generic-test-data/#generic-test-executionIs it possible to put the fullpath info here?