Code Monkey home page Code Monkey logo

grunt-karma-sonar's People

Contributors

jeinnovate avatar mdasberg avatar mrhus avatar nchase avatar pgokul avatar tnguyen1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

grunt-karma-sonar's Issues

sonar-runner: not found

Hi there

When i try to configure some remote location for the download of sonar-runner, the installation script log shows "sonar-runner: not found".

$ npm install grunt-karma-sonar --sonarrunner_cdnurl=http://200.14.166.249:5680/node_dependencies/

> [email protected] install /home/csanchez/deleteme/node_modules/grunt-karma-sonar
> node install.js

/bin/sh: 1: sonar-runner: not found
/home/csanchez/deleteme
└─┬ [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ └── [email protected] 
  └── [email protected] 

npm WARN ENOENT ENOENT: no such file or directory, open '/home/csanchez/deleteme/package.json'
npm WARN EPACKAGEJSON deleteme No description
npm WARN EPACKAGEJSON deleteme No repository field.
npm WARN EPACKAGEJSON deleteme No README data
npm WARN EPACKAGEJSON deleteme No license field.

But the file (sonar-runner) exists in the folder

~/deleteme/node_modules/grunt-karma-sonar$ tree
.
├── CHANGELOG.md
├── Gruntfile.js
├── install.js
├── lib
│   └── sonar-runner-2.4
│       ├── bin
│       │   ├── sonar-runner
│       │   └── sonar-runner.bat
│       ├── conf
│       │   └── sonar-runner.properties
│       └── lib
│           └── sonar-runner-dist-2.4.jar
├── LICENSE-MIT

It is a normal behaviour?

PS: In my CDN URL I rename "sonar-runner-dist-2.4.zip" to "sonar-runner-dist.zip"

Karma sonar should not write options instance when they are undefined.

The sonar-runner has the option of defining a global configuration. This way you can have multiple projects that can use the same configuration. So you don't have to set the hostname and authentication data of sonar per project, as a bonus you don't have to commit them into git.

See: http://docs.sonarqube.org/display/SONAR/Installing+and+Configuring+SonarQube+Runner

This will only work when you don't add arguments to sonar-runner because adding them overwrites the global configuration. So if you send -Dsonar.host.url= you overwrite the globally configured one.

Currently the grunt-karma-sonar runner does exactly that it always overrides the following with default values:

'-Dsonar.host.url=' + sonarOptions.instance.hostUrl,
'-Dsonar.jdbc.url=' + sonarOptions.instance.jdbcUrl,
'-Dsonar.jdbc.username=' + sonarOptions.instance.jdbcUsername,
'-Dsonar.jdbc.password=' + sonarOptions.instance.jdbcPassword,
'-Dsonar.login=' + sonarOptions.instance.login,
'-Dsonar.password=' + sonarOptions.instance.password

These are there defaults:

instance: {
    hostUrl: 'http://localhost:9000',
    jdbcUrl: 'jdbc:h2:tcp://localhost:9092/sonar',
    jdbcUsername: 'sonar',
    jdbcPassword: 'sonar',
    login: 'admin',
    password: 'admin'
}

A previous version of grunt-karma-sonar had this check:

if (options.instance !== undefined) {
    args.push('-Dsonar.host.url=' + options.instance.hostUrl);
    args.push('-Dsonar.jdbc.url=' + options.instance.jdbcUrl);
    if (options.instance.jdbcUsername !== undefined) {
        args.push('-Dsonar.jdbc.username=' + options.instance.jdbcUsername);
    }
    if (options.instance.jdbcPassword !== undefined) {
        args.push('-Dsonar.jdbc.password=' + options.instance.jdbcPassword);
    }
    if (options.instance.profile !== undefined) {
        args.push('-Dsonar.profile=' + options.instance.profile);
    }
    args.push('-Dsonar.login=' + options.instance.login);
    args.push('-Dsonar.password=' + options.instance.password);
}
return args;

This prevented the writing of the -D options for the runner when the options instance was left empty.
Which is exactly what you want to do when you want to use the global configuration.

I would like to see the options.instance undefined check to return. So that when it is undefined it doesn't send the -D arguments to sonar runner. This way a nice feature (which I depend on ;P) would return.

Can't generate unit test report

Hi

Thanks for your karma-sonar-plugin which I managed to get working perfectly for coverage report. Unfortunately I can't get my unit tests report to get analysed by sonar.

Regarding unit tests my karma.conf.js file defines the following
junitReporter:
{
outputFile: 'target/karma-reports/angular-test-results.xml'
}

my gruntfile.js karma_sonar section is
sources :
[{
path : 'src/main/webapp/js',
coverageReport : 'target/js-code-coverage/lcov-only.txt',
testReport : 'target/karma-reports/angular-test-results.xml'
}],

When karma_sonar runs I can find a .tmp/sonar/TESTS-xunit.xml file which is the exact copy of my karma generated test report. But then, when sonar executes, this file doesn't seem to be taken into account. I only get the coverage report as you can see on the attached screenshot.

Am I doing something wrong or is there a bug?
capture1

Error when running in a directory with a whitespace.

When i'm running grunt karma sonar in a directory with a whitespace in it, I get the following output.

Running "karmaSonar:cmsSonar" (karmaSonar) task

No jUnit report has been specified
No integration jUnit report has been specified
No integration coverage report has been specified
Error: Could not find or load main class test.node_modules.grunt-karma-sonar.lib.sonar-runner-2.4.lib.sonar-runner-dist-2.4.jar
Warning: The following error occured while trying to upload to sonar: Error Use --force to continue.

The problem seems to be on line 200 of sonar.js:

var libDir = path.join(__dirname, '..', 'lib');
if (grunt.file.exists(libDir)) {
  glob.sync('**/bin/sonar-runner', {cwd: libDir, root: '/'}).forEach(function (file) {
   opts.cmd = libDir + path.sep + file;
  });
}

The libDir should be surrounded with '.

what's sonar?

i'm a Karma user, i haven't heard of sonar, can you add a link in the readme, or just tell me if you think most people will know. Thanks!

Issue with sonar.language property

Multi-language is not supporting with this package and web language is not recognizing. Please help us by providing the solution for this.

12:18:44.722 INFO - Language is forced to null
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 12.288s
Final Memory: 18M/543M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must install a plugin that supports the language 'null'
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Warning: The following error occured while trying to upload to sonar: Error Used --force, continuing.

File merge fails if there is disabled jasmine test ('xit()')

Sonar analysis failed with 'Warning: Cannot call method 'replace' of undefined' message when there is disabled test in test code i.e. it('blah-blah') is prefixed with 'x' we have xit('blah-blah').
Such tests are marked as disabled in junit report and caused the failure on remove escaped characters step.

Cannot install behind (corporate) proxy

Hi,
The npm install phase seems to fail when behind a corporate proxy (npm itself is configured properly, and both http_proxy and https_proxy environment variables are set) when trying to fetch sonar-runner:

Using remote location to fetch sonar-runner.
Could not download the latest version of sonar-runner from the remote repository due to the following error [Error: getaddrinfo ENOTFOUND repository.sonatype.org].

Maybe use something like https://www.npmjs.com/package/global-tunnel?
Thanks!

grunt-karma-sonar doesn't work with newer versions of karma-junit-reporter

This is what karma-junit-reporter reports under version 0.2.2:

<?xml version="1.0"?>
<testsuites>
  <testsuite name="PhantomJS 2.1.1 (Mac OS X 0.0.0)" package="" timestamp="2016-07-20T14:50:50" id="0" hostname="hig.local" tests="7" errors="0" failures="0" time="0.067">
    <properties>
      <property name="browser.fullName" value="Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1"/>
    </properties>
    <testcase name="should attach a ENV and APP to the scope" time="0.018" classname="PhantomJS 2.1.1 (Mac OS X 0.0.0).Controller: FooterController"/>
    <testcase name="should fetch the coverage from instanbul, when the environment is development" time="0.012" classname="PhantomJS 2.1.1 (Mac OS X 0.0.0).Controller: FooterController"/>
    <testcase name="should not fetch the coverage from instanbul, when the environment is production" time="0.004" classname="PhantomJS 2.1.1 (Mac OS X 0.0.0).Controller: FooterController"/>
    <testcase name="should attach a list of awesomeThings to the mainController" time="0.003" classname="PhantomJS 2.1.1 (Mac OS X 0.0.0).Controller: MainController"/>
    <testcase name="clicking on the splendid button should change its text" time="0.002" classname="PhantomJS 2.1.1 (Mac OS X 0.0.0).Controller: MainController"/>
    <testcase name="should compile down to an awesome thing with a H4 and a paragraph" time="0.021" classname="PhantomJS 2.1.1 (Mac OS X 0.0.0).Directive: awesomeThing"/>
    <testcase name="should show a window.alert on click" time="0.007" classname="PhantomJS 2.1.1 (Mac OS X 0.0.0).Directive: awesomeThing"/>
    <system-out><![CDATA[
]]></system-out>
    <system-err/>
  </testsuite>
</testsuites>

This is what it reports for 1.1.0:

<?xml version="1.0"?>
<testsuite name="PhantomJS 2.1.1 (Mac OS X 0.0.0)" package="" timestamp="2016-07-20T14:53:42" id="0" hostname="hig.local" tests="7" errors="0" failures="0" time="0.065">
  <properties>
    <property name="browser.fullName" value="Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1"/>
  </properties>
  <testcase name="Controller: FooterController should attach a ENV and APP to the scope" time="0.015" classname="Controller: FooterController"/>
  <testcase name="Controller: FooterController should fetch the coverage from instanbul, when the environment is development" time="0.008" classname="Controller: FooterController"/>
  <testcase name="Controller: FooterController should not fetch the coverage from instanbul, when the environment is production" time="0.003" classname="Controller: FooterController"/>
  <testcase name="Controller: MainController should attach a list of awesomeThings to the mainController" time="0.003" classname="Controller: MainController"/>
  <testcase name="Controller: MainController clicking on the splendid button should change its text" time="0.002" classname="Controller: MainController"/>
  <testcase name="Directive: awesomeThing should compile down to an awesome thing with a H4 and a paragraph" time="0.023" classname="Directive: awesomeThing"/>
  <testcase name="Directive: awesomeThing should show a window.alert on click" time="0.011" classname="Directive: awesomeThing"/>
  <system-out>
    <![CDATA[
]]>
  </system-out>
  <system-err/>
</testsuite>

As you can see the 'name' property of a 'testcase' element now includes the jasmine 'describe' and the 'it' in the name. The 'jasmineJunit.js' file can now no longer perform step 3: 'replace the classname with the spec filename' and throws the warning: "No spec filename found for test".

I added some debugging info:

var matchingSpecs = _.map(_.filter(specs, function (spec) {
                                    return _.find(spec.tests, function (test) {
                                        console.log(test + ' === ' + name);
                                        return test === name || xmlEntities.encode(test) === name;
                                    });
                                }), 'name');

And this is what I see:

should attach a ENV and APP to the scope === Controller: FooterController should attach a ENV and APP to the scope
should fetch the coverage from instanbul, when the environment is development === Controller: FooterController should attach a ENV and APP to the scope
should not fetch the coverage from instanbul, when the environment is production === Controller: FooterController should attach a ENV and APP to the scope
should attach a list of awesomeThings to the mainController === Controller: FooterController should attach a ENV and APP to the scope
clicking on the splendid button should change its text === Controller: FooterController should attach a ENV and APP to the scope
should compile down to an awesome thing with a H4 and a paragraph === Controller: FooterController should attach a ENV and APP to the scope
should show a window.alert on click === Controller: FooterController should attach a ENV and APP to the scope

Fatal:Error while using it with Grunt

I am getting below error while using it with my grunt build. Any suggestions? Any logs through which I can dig further?

Fatal error: spawn D:\Projects\In-House\Eclipse-Workspace\AngularDemo\node_modul
es\grunt-karma-sonar\lib\sonar-runner-2.4\bin\sonar-runner ENOENT

My config is as below,
karmaSonar: {
options: {
instance: {
hostUrl : 'http://localhost:9000',
jdbcUrl : 'jdbc:mysql://localhost:3306/sonar',
login: 'root',
password: 'password'
}
},
sonar_export: {
project: {
key: 'angular-demo',
name: 'Angular Demo',
version: '1.0.0'
},
paths: [
{
cwd: 'src', // the current working directory'
src: [ 'src//*.js', '!src//.spec.js', '!src/assets/__/.js' ], // the source directory within the cwd
test: ['!src//*.js', 'src//.spec.js', '!src/assets/__/.js'], // the test directory within the cwd
reports: {
unit: 'TESTS-Firefox_40.0.0_(Windows_8.1_0.0.0).xml', // the result file within the cwd
coverage: 'build/coverage/Firefox 40.0.0 (Windows 8.1 0.0.0)/lcov.info', // the glob for lcov files'
itCoverage: 'build/coverage/Firefox 40.0.0 (Windows 8.1 0.0.0)/lcov.info' // the glob for integration lcov files'
}
}
]
}
}

karma-junit-reporter output file path changes

since version 0.3.1 of 'karma-junit-reporter' the file name pattern has changed like 'karma-coverage' with browser name:
ex:
PhantomJS_1.9.8_(Linux_0.0.0).xml
PhantomJS_1.9.8_(Linux_0.0.0)/customName.xml

we can make the 'paths.reports.unit' dynamic like 'paths.reports.coverage'?

ty

'karma_sonar' task doesn't stop when errors occur.

Task doesn't stop when errors occur.

For example:

When sonar-runner is not installed you get the following error:

The following error occured while trying to upload to sonar: Error: Error: not found: sonar-runner

However this doesn't stop the task from running, ideally it would stop running after the error code.

Another example is when something goes wrong when uploading to sonar:

The following error occured while trying to upload to sonar: Error

Basically whenever an error occurs the task should stop grunt.

Error executing sonar-runner on windows when it is not in the path

In a case where I run grunt-karma-sonar on a windows machine and due to a misconfiguration sonar-runner was not available on the path, sonar-runner was automatically downloaded to the lib subdirectory of grunt-karma-sonar module.
When then coming to #6 (publish) in sonar.js, spawning the sonar-runner process failed with the following message:
Copying files to working directory [.tmp/sonar/]
�[31mFatal error: spawn E:\workspace\node_modules\grunt-karma-sonar\lib\sonar-runner-2.4\bin\sonar-runner ENOENT��[39m

This is due to the code that joins the libDir with /bin/sonar-runner and trying to execute the unix script on a windows system where the sonar-runner.bat should be used.

karma-junit-reporter 0.3.4 requirement not explicit

hi there,

i think compatibility w/ karma-junit-reporter 0.2.x was broken with v0.2.14. that would be a breaking change, no? if keeping 0.2.x karma-junit-reporter backwards-compatibility is not worth it, maybe a hard dependency in package.json would be sufficient?

cheers,

magnus

Install exited unexpectedly

Hi.

I try to install the lastest version of grunt-karma-sonar and the log show "Install exited unexpectedly", but

$ npm i [email protected] --sonarrunner_cdnurl=http://200.14.166.249:5680/node_dependencies/
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No repository field.

-
> [email protected] install /home/bamboo/deleteme/node_modules/grunt-karma-sonar
> node install.js

Sonar-runner command [sonar-runner] could not be found on the path, checking locally...
Sonar-runner command [sonar-runner] could not be found locally either.
Install exited unexpectedly

npm ERR! [email protected] install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the grunt-karma-sonar package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls grunt-karma-sonar
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.32-279.el6.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "i" "[email protected]" "--sonarrunner_cdnurl=http://200.14.166.249:5680/node_dependencies/"
npm ERR! cwd /home/bamboo/deleteme
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

But in http://200.14.166.249:5680/node_dependencies sonar-runner exist

Index of /node_dependencies

Parent Directory
phantomjs-1.9.8-linux-x86_64.tar.bz2
phantomjs-1.9.8-macosx.zip
phantomjs-1.9.8-windows.zip
sonar-runner-dist.zip

Any idea, mate?

fails if no itUnit, itCoverage path set

My current project doesn't include any integration testing but if I leave either path empty it fails.

Also is there a better sample project detailing gruntfile configuration?

Tests that contain '' in jasmine it break sonar

Having a test like:

 it("should show 'who' is awesome", function () {....}

Result in the following error:

Warning: Cannot read property 'replace' of undefined� Use --force to continue.

Cannot find module 'fs-extra'

Hi,

I'm getting this error when I try to run grunt karma_sonar

Loading "sonar.js" tasks...ERROR
>> Error: Cannot find module 'fs-extra'
Warning: Task "karma_sonar" not found. Use --force to continue.

Aborted due to warnings.

How to use scm plugin?

I like to use the SCM functionality of sonar, but this does not seem to work.

Setting scmDisabled to false results in

No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.

Setting this explicitly:

runnerProperties: {
    'sonar.scm.provider': 'git'
},
scmDisabled: false

results in:

INFO: Missing blame information for the following files:
...

Seems to me this is caused by the fact that sonar analyses takes place in the .tmp directory which, of course, does not contain any version information...

Is there a way to get this to work?

sonar-runner flag

Hello @mdasberg can U add like a property to run or not run sonar, something like this:

    function exec() {
            var child = grunt.util.spawn({
                cmd: 'sonar-runner',
                args: getSonarArguments(data, options),
                opts: {
                    stdio: 'inherit'
                }
            }, function (error, result, code) {
                if (code !== 0) {
                    return grunt.log.error('The following error occured while trying to upload to sonar: ' + error);
                } else {
                    grunt.log.writeln('Uploaded information to sonar.');
                }
                donePromise();
            });
        }
        //Will skip sonar runner if we haven\'t local sonar or we run sonar like post build task on Jenkins
        if (options.runSonar){
            exec();
        }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.