-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration tests fail: TempFolder not working if TMP/TEMP are not set correct #1949
Comments
Hello @elviiix, we are using https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/.travis.yml and https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/appveyor.yml to build and verify the plugin, both are working. Maybe you can have a look into the log files if you see any differences.
The allowed characters are not defined by us, they are defined from SQ core. We can't change this. Regards, |
Ok, I'll try to have a look later.
About underscore - with patch I provided in first message - SQ 7.9 successfully imports rules. They are filtered by your code and not SonarQube. |
@elviiix thx, I will verify this. |
Tried to debug a little. First for some reason TemporaryFolder from
is not created. If I remove @rule string it creates ok, but even with that in I'll try to have a more detailed look when a have a free time, but can you possibly comment about these problems? |
@Rule
public TemporaryFolder base = new TemporaryFolder(); @elviiix something special with your temp folder or OS?
java.io.tmpdir pointing to an invalid folder? |
No nothing special, tried even setting to C:/Tmp using environment variables, same effect. I have tried on 2 computers - one with Win10, second with Windows Server and have the same errors during build on both.
As I have already said then I make base a member variable - I do see files in right location (don't know junit well enough to understand why it works this way and not another), but DirectoryScanner is still unable to find them. P.S. To me it looks more like problems with directory separator and not access rights. |
Found out the reason. Problem is in case sensitivity. Windows by default sets temp directory inside user profile. And if user name is in uppercase path in environmnent variable has that part of path in uppercase but the profile folder itself on disk is created in lowercase. And it looks like TemporaryFolder has a problem with such setting. I think you can reproduce the problem if you set env variable on Windows to differ in case from real folder. With this patch 1.3.2 builds successfully. Not sure it's the best way, but i think idea is clear (If you plan on changing anything probaly it would be better to alter other TemporaryFolder as well).
|
@elviiix thx for your investigations, I will have a look to it. |
Source code for TemporaryFolder is here: https://github.com/junit-team/junit4/blob/main/src/main/java/org/junit/rules/TemporaryFolder.java#L257 |
hi, I am getting this error The plugin [cxx] does not support Java 1.8.0_275 in my jenkins when i build my java project. Is it enough to upgrade the Jenkins, SonarQube & SonarScanner to Java 11 to use the cxx 2.0 plugin or I must also upgrade my source code to Java 11? I cannot currently upgrade my source code to Java 11. Is there any other alternate solution to use the 3 Metrics (Public API, Public Documented API (%) & Public Undocumented API) in sonarqube? or directly in the Java sourceCode perhaps? |
Hi @Bhushetti, for the cxx plugin you have to use Java 11 , see https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Upgrade-the-Plugin
Think you are speaking about your Java source code? You can use Java 11 VM but analyse Java 8. For that it's recommended to use the setting sonar.java.source: see description on page https://docs.sonarqube.org/latest/analysis/languages/java/.
The cxx plugin works only with C/C++ code. So I don't see how you can use it with Java code? Regards, |
The component
Sample for GitHub Actions: # for tests on Windows we need a valid TMP folder
# - necessary for org.junit.rules.TemporaryFolder
#
- name: Adapt TMP folder on Windows OS
shell: bash
run: |
echo "TMP=$USERPROFILE\AppData\Local\Temp" >> $GITHUB_ENV
echo "TEMP=$USERPROFILE\AppData\Local\Temp" >> $GITHUB_ENV |
Description
Build of sonar-cxx on Windows with OpenJDK produces errors
Steps to reproduce the problem
Install OpenJDK from https://adoptopenjdk.net/index.html
(either OpenJDK 8 or OpenJDK 11).
Install Apache Maven 3.6.3
run
mvn clean install
Expected behavior
build finishes without errors
Actual behavior
Some tests result in errors
[ERROR] Failures:
[ERROR] CxxReportPatternMatchingTest.getReports_patternMatching:87 [Failed for pattern: {}] expected:<[[C:\Users\ALEXMI~1\AppData\Local\Temp\junit9123077941808277150\A.ext]]> but was:<[[]]>
[ERROR] CxxReportSensor_getReports_Test.testAbsoluteInsideBasedir:48 expected:<[1]> but was:<[0]>
[ERROR] CxxReportSensor_getReports_Test.testAbsoluteOutsideBasedirAndRelative:84 expected:<[2]> but was:<[1]>
[ERROR] CxxReportSensor_getReports_Test.testAbsoluteOutsideBasedirWithGlobbingAndNestedRelativeWithGlobbing:121 expected:<[6]> but was:<[2]>
[ERROR] CxxReportSensor_getReports_Test.testAbsoluteOutsideBasedirWithGlobbingAndRelativeWithGlobbing:103 expected:<[7]> but was:<[2]>
[ERROR] CxxReportSensor_getReports_Test.testRelativeBackticksOutsideBasedirThenBackInside:134 expected:<[4]> but was:<[0]>
Known workarounds
Commenting out tests mentioned above results in successful build
Related information
build results in theese errors both for 1.3.2 and master (I was able to build master only with JDK 11).
P.S. And one more thing. Can you allow underscore character in clang-tidy rules, it's allowed there by clang-tidy itself and warnings not importing in SonarQube was rather unexpected.
The text was updated successfully, but these errors were encountered: