Skip to content
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/boosttest #387

Closed
wants to merge 2 commits into from
Closed

Integration/boosttest #387

wants to merge 2 commits into from

Conversation

guwirth
Copy link
Collaborator

@guwirth guwirth commented Jan 15, 2015

  • add initial files to setup an integration test for boost and boost unit tests
  • currently only files without build & check

@wenns
Copy link
Contributor

wenns commented Jan 16, 2015

1200 files for a sample project? Its way too big for my taste. Can we get it smaller?

@jmecosta
Copy link
Member

Would you consider moving the integration test data into a sub module?

On Fri, Jan 16, 2015, 19:39 Waleri Enns [email protected] wrote:

1200 files for a sample project? Its way too big for my taste. Can we get
it smaller?


Reply to this email directly or view it on GitHub
#387 (comment).

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 16, 2015

;-> that's boost.

Boost test framework is on top of boost. I already removed a lot of directories. Next step would be to cleanup within the directories. Problem I see is that this is a lot of work each time we upgrade to a new boost version. Will try to find out touched files with sysinternal tools...

@wenns
Copy link
Contributor

wenns commented Jan 16, 2015

How about installing it via

$ sudo apt-get install libboost-test-dev

@wenns
Copy link
Contributor

wenns commented Jan 17, 2015

Would you consider moving the integration test data into a sub module?

I dont think its necessary, at least at this point of time. I think we can manage the problem otherwise.

@guwirth guwirth added this to the M 0.9.3 milestone Jan 17, 2015
@guwirth
Copy link
Collaborator Author

guwirth commented Jan 17, 2015

Will try with sudo. Do you know to which location boost will be installed? Are there afterwards environment variables I can use? Someone experience with all that stuff?

@wenns
Copy link
Contributor

wenns commented Jan 17, 2015

Just to be clear: this command line would work on Ubuntu and Debian derivates and looks differently with other package managers. My point is just that: you can install boost test on the system, just like e.g. cppcheck. I.e.:

  • tests, build scripts, scripts for running the tests come into the sample project
  • libs, headers are installed on the system. You need it to only to develop the tests anyway. Once development is ready, you just checkin the ready XML reports and run the tests against them.

As for locations of the libs and headers etc.: on Linux they just land in standard locations (headers in /usr/include, libs in /usr/lib) and it just works. To make building work cross platform, one can just keep (and change, if necessary) in constants inside of build files.

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 18, 2015

@wenns : would like to write the tests now.

  • Should I add it to test_execution_statistics.feature or is it better to split it google-test/boost-test?
  • What is the entry point? Just add a new .feature file?

@wenns
Copy link
Contributor

wenns commented Jan 19, 2015

Please add new scenarios to the test_execution_statistics.feature. Your test cases are the same feature, after all. Behave's execution procedure is like so:

  • behave knows the folder where to look for features via .behaverc
  • the according step implementations (the python code) is found via convention
  • the python code in steps is imported, analysed and put into the library of step implementations
  • the features are read in, the step names parsed, according step implementations lookuped and called

@guwirth guwirth self-assigned this Jan 19, 2015
@guwirth
Copy link
Collaborator Author

guwirth commented Jan 20, 2015

@wenns tried to add a first test to test_execution_statistics.feature but it's not executed. See nothing in the log file on the Travis server. Do you have any idea?



before_install:
- sudo apt-get install libboost-dev libboost-test-dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will not work on windows. or on any non deb base system... isnt there a better way of handling these...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .travis.yml will be executed on a Travis VM, which is garanteed to be a debian derivate ;)
Having said this, the line is not actually needed, as the behave will only run 'sonar-runner' against checked in reports, no?
The boost header, libs, etc. are needed only for developing the tests, i.e. on your workstation. Not on the CI slave.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, did not notice that was in the yaml file.. Good as it is :)

On Wed, Jan 21, 2015, 21:17 Waleri Enns [email protected] wrote:

In .travis.yml
#387 (comment):

@@ -4,7 +4,10 @@ jdk:

  • oraclejdk8
  • openjdk7

+before_install:

  •    - sudo apt-get install libboost-dev libboost-test-dev
    

The .travis.yml will be executed on a Travis VM, which is garanteed to be
a debian derivate ;)
Having said this, the line is not actually needed, as the behave will only
run 'sonar-runner' against checked in reports, no?
The boost header, libs, etc. are needed only for developing the tests,
i.e. on your workstation. Not on the CI slave.

So not probs here

wont be executed on Windows


Reply to this email directly or view it on GitHub
https://github.com/wenns/sonar-cxx/pull/387/files#r23325522.

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 21, 2015

sudo apt-get install libboost-dev libboost-test-dev

@jmecosta: there is also the possibility

  • to download the zip and extract it
  • to mock the boost unit test header with some simple defines

@wenns, @jmecosta:
But maybe some word what I like to do: My main focus is to add new tests for boosttest, here I like to test the filename way and the AST-based way. To test the AST-based way I need the header files to see if the plugin is able to parse boost headers.
At the moment my main interest is to add all needed test and to bring it into operation. This boostlib thing is a priority B point which could be solved at the end.

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 22, 2015

Remove 'Outline' and it will execute.

:-< copied from the wrong example: 'Scenario: googletest report is invalid' is also wrong

The boost header, libs, etc. are needed only for developing the tests

Still not sure about that. Like to test AST based approach for this I need the header files otherwise unit tests can't be parsed in the right way?

@wenns
Copy link
Contributor

wenns commented Jan 22, 2015

:-< copied from the wrong example: 'Scenario: googletest report is invalid' is also wrong

Ahh. Damn. You're right!

The boost header, libs, etc. are needed only for developing the tests
Still not sure about that. Like to test AST based approach for this I need the header files otherwise
unit tests can't be parsed in the right way?

[Had a look into the test files] Oh yes, looks like...

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 25, 2015

  • adapt boost xsl to support changed xunit feature: support all log_level settings
  • extend SourceCodeBuilderVisitor for functions to return qualified names including namespaces
  • extend xunit lookup table: supports search for qualified and unqualified classname now
  • add a new unit test to search for qualified classname with namespace
  • use 'sudo apt-get install libboost-dev libboost-test-dev' for test with real boost
  • add boost test examples
  • add boost test reports
  • add new scenarios to integration tests:
    • add 'Scenario Outline: boosttest reports cannot be found or are empty'
    • add 'Scenario: Importing nested boosttest report in default mode'
    • add 'Scenario: Importing unchanged boosttest reports in default mode'
    • add 'Scenario Outline: Importing unchanged boosttest reports in detailed mode (filename tag)'
    • add 'Scenario Outline: Importing unchanged boosttest reports in detailed mode (AST)'
    • add 'Scenario: Test with real boost test framework'
  • close xunit: nested (qualified) classname #401
  • close Boost Unit Test, xunit.provideDetails=true, filename tag #372
  • close Boost Unit Test, xunit.provideDetails=true, AST-based lookup #368
  • close boosttest integration test #375

@@ -124,7 +125,18 @@ public SourceCode createSourceCode(SourceCode parentSourceCode, AstNode astNode)
sb.append(token.getValue());
}
String functionName = sb.toString();
SourceFunction function = new SourceFunction(functionName + ":" + astNode.getToken().getLine());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is creating the qualified name including the namespaces. Going from current node upwards the tree adding all namespace names.

@wenns
Copy link
Contributor

wenns commented Jan 29, 2015

The tests dont run on my machine (Linux 32 bit). wth? They did pass Travis and they obviously passed on your machine. But I get a bunch of:

19:09:57.386 DEBUG - Performing the 'filename'-based lookup using the value 'tests/unittests/test_component1.cc'
19:09:57.386 WARN  - ... no resource found, the testcase 'my_module:foo_successfull/foo_successfull' has to be skipped

where the lookup is expected to succeed. What can cause this? The stuff I merged in the meanwhile? Replacement of the deprecated ModuleFileSystem? Hmm...

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 30, 2015

:-< rebase to see if last changes are the issue

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 30, 2015

Fails after rebase, so last changes on master are the root cause.

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 30, 2015

Input after transformation:

<?xml version="1.0" encoding="utf-8"?>
<testsuite tests="1" errors="0" failures="0" skipped="0" name="my_module">
  <testcase classname="my_test" name="my_test" filename="tests/unittests/test_simple.cc" />
</testsuite>

Seems to be changed behaviour in DefaultResourceFinder.findInSonar?
No more able to find 'tests/unittests/test_simple.cc'.

problem of 'sonar-project.properties'?

sonar.projectKey=boosttest_project
sonar.projectName=boosttest_project
sonar.projectVersion=1
sonar.language=c++

sonar.sources=src
sonar.tests=tests/unittests
sonar.cxx.includeDirectories=src,tests

sonar.cxx.xunit.xsltURL=boosttest-1.x-to-junit-1.0.xsl
sonar.cxx.xunit.reportPath=build/xunit-report.xml

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 30, 2015

@Typz, @wenns original search in fs.testDirs() is missing now?
Bug or feature?

Old:

 public org.sonar.api.resources.File findInSonar(File file, SensorContext context, ModuleFileSystem fs, Project project) {
    org.sonar.api.resources.File unitTestFile = org.sonar.api.resources.File.fromIOFile(file, project);
    if (unitTestFile == null) {
      unitTestFile = org.sonar.api.resources.File.fromIOFile(file, fs.testDirs());
    }
    if (context.getResource(unitTestFile) == null) {
      unitTestFile = null;
    }
    return unitTestFile;
  }

New:

 public org.sonar.api.resources.File findInSonar(File file, SensorContext context, FileSystem fs, Project project) {
    org.sonar.api.resources.File unitTestFile = org.sonar.api.resources.File.fromIOFile(file, project);
    if (context.getResource(unitTestFile) == null) {
      unitTestFile = null;
    }
    return unitTestFile;
  }

@wenns
Copy link
Contributor

wenns commented Jan 30, 2015

Yep, saw that already. The point is, the older version had two access trials because of < 4.0 compatibility issue of the like... The new one should work too. Will try to investigate further.

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 30, 2015

http://javadocs.sonarsource.org/4.5/apidocs/org/sonar/api/resources/File.html

public static File fromIOFile(File file, Project module)
Deprecated. since 4.5 use FileSystem.inputFile(org.sonar.api.batch.fs.FilePredicate)

@wenns
Copy link
Contributor

wenns commented Jan 30, 2015

We're still using 4.2 API.

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 31, 2015

@wenns are you looking for a solution?

@wenns
Copy link
Contributor

wenns commented Jan 31, 2015

Right now Im cleaning rooms ;)
But I want to invest an hour or two this weekend. Are you?

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 31, 2015

Have a time slot between 4 and 6 o'clock. If you want I can do another try...

@wenns
Copy link
Contributor

wenns commented Jan 31, 2015

Lets make it that way: I'll just merge the stuff and skip failing tests. And we'll address the problem on the master. I mean: the PR is OK, its master thats broken. This PR just exposes a problem.

@wenns
Copy link
Contributor

wenns commented Jan 31, 2015

Pushed to master. Failing tests are marked with @Skip. If you want to run them, remove this annotation.

- adapt boost xsl to support changed xunit feature: support all log_level settings
- extend SourceCodeBuilderVisitor for functions to return qualified names including namespaces
- extend xunit lookup table: supports search for qualified and unqualified classname now
- add a new unit test to search for qualified classname with namespace
- use 'sudo apt-get install libboost-dev libboost-test-dev' for test with real boost
- add boost test examples
- add boost test reports
- add new scenarios to integration tests:
  - add 'Scenario Outline: boosttest reports cannot be found or are empty'
  - add 'Scenario: Importing nested boosttest report in default mode'
  - add 'Scenario: Importing unchanged boosttest reports in default mode'
  - add 'Scenario Outline: Importing unchanged boosttest reports in detailed mode (filename tag)'
  - add 'Scenario Outline: Importing unchanged boosttest reports in detailed mode (AST)'
  - add 'Scenario: Test with real boost test framework'

- close #401
- close #372
- close #368
- close #375
@wenns wenns closed this Feb 2, 2015
@guwirth guwirth deleted the integration/boosttest branch April 14, 2015 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants