2014-02-07 54 views
0

我有一個使用聲納JavaScript插件進行分析的coffeescript編寫的nodejs項目。如何解決此重複資源錯誤?

我將所有源代碼放在名爲「src」的文件夾中,並在名爲「test」的文件夾中進行測試。

測試文件與源文件具有相同的名稱。

當我運行測試

  • 的coffescript被編譯爲JavaScript並複製到「LIB/src目錄」和「LIB /測試」
  • 的JavaScript,然後儀器進行覆蓋,並複製到「lib- COV/LIB/SRC」和‘LIB-COV/LIB /測試’(實際上只在src被儀器,測試只是再次複製到保持相對路徑)

中的器械代碼我運行試驗後獲得2份報告「reports/lcov.info」和「reports/TEST-all.xml」

這工作對我的項目之一,但在另一個我從源文件2得到重複的資源錯誤(我想不出有什麼特別之處他們)

的「sonar-project.properties」看起來是這樣的:

sonar.projectKey=ddm:ddm-server 
sonar.projectName=D4A Dependency Manager Server 
sonar.projectVersion=1.0 

sonar.sources=lib/src 
sonar.exclusions=index.js 
sonar.language=js 

sonar.javascript.jstestdriver.reportsPath=reports 
sonar.javascript.lcov.reportPath=reports/lcov.info 

在 「LIB/src目錄」 目錄中的文件(沒有子目錄):

  • Archive.js
  • 戈t.js
  • index.js
  • Library.js
  • Post.js
  • Registry.js
  • Version.js

只有 「Archive.js」 和「Post.js 「造成問題

,並導致以下錯誤:

ERROR: Caused by: Duplicate source for resource: [email protected][key=Archive.js,dir=<null>,filename=Archive.js,language=JavaScript] 

如果我排除「Archive.js」和「Post.js」,一切正常 - 這些名稱是否有特殊之處?

FYI:從詹金斯聲納亞軍輸出完整的是:

[DDM_SERVER_CONTINUOUS_BUILD_AND_TEST] $ /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner_2.3/sonar-runner-2.3/bin/sonar-runner -Dsonar.jdbc.driver=com.mysql.jdbc.Driver -Dsonar.jdbc.url=jdbc:mysql://sonar.lgcoreapps.com:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8 ******** ******** -Dsonar.host.url=http://sonar.lgcoreapps.com ******** ******** -Dsonar.projectBaseDir=<http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/> -Dsonar.exclusions=index.js 
SonarQube Runner 2.3 
Java 1.7.0_09-icedtea Oracle Corporation (64-bit) 
Linux 2.6.32-358.el6.x86_64 amd64 
INFO: Runner configuration file: /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner_2.3/sonar-runner-2.3/conf/sonar-runner.properties 
INFO: Project configuration file: <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/sonar-project.properties> 
INFO: Default locale: "en_US", source code encoding: "US-ASCII" (analysis is platform dependent) 
INFO: Work directory: <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/.sonar> 
INFO: SonarQube Server 3.5.1 
13:46:58.260 INFO - Load batch settings 
13:46:58.349 INFO - User cache: /home/jenkins/.sonar/cache 
13:46:58.351 INFO - Install plugins 
13:46:59.109 INFO - ------------- Executing Project Scan 
13:46:59.750 INFO - Install JDBC driver 
13:46:59.754 INFO - Apply project exclusions 
13:46:59.758 INFO - Create JDBC datasource for jdbc:mysql://sonar.lgcoreapps.com:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8 
13:47:00.110 INFO - Initializing Hibernate 
13:47:03.520 INFO - ------------- Inspecting D4A Dependency Manager Server 
13:47:03.525 INFO - Load module settings 
13:47:04.145 INFO - Quality profile : [name=Sonar way,language=js] 
13:47:04.171 INFO - Excluded sources: 
13:47:04.172 INFO - index.js 
13:47:04.172 INFO - Excluded tests: 
13:47:04.172 INFO - **/package-info.java 
13:47:04.203 INFO - Configure Maven plugins 
13:47:04.309 INFO - Compare to previous analysis (2014-02-07) 
13:47:04.335 INFO - Compare over 5 days (2014-02-02, analysis of 2014-02-07 12:04:17.0) 
13:47:04.352 INFO - Compare over 30 days (2014-01-08, analysis of 2014-02-07 12:04:17.0) 
13:47:04.654 INFO - Base dir: <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/> 
13:47:04.654 INFO - Working dir: <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/.sonar> 
13:47:04.654 INFO - Source dirs: <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/lib/src> 
13:47:04.654 INFO - Source encoding: US-ASCII, default locale: en_US 
13:47:04.676 INFO - Sensor JavaScriptSourceImporter... 
13:47:04.797 INFO - Sensor JavaScriptSourceImporter done: 121 ms 
13:47:04.797 INFO - Sensor JavaScriptSquidSensor... 
13:47:05.858 INFO - Sensor JavaScriptSquidSensor done: 1061 ms 
13:47:05.858 INFO - Sensor LCOVSensor... 
13:47:05.859 INFO - Analysing <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/reports/lcov.info> 
13:47:05.902 INFO - Sensor LCOVSensor done: 44 ms 
13:47:05.903 INFO - Sensor JsTestDriverSensor... 
INFO: ------------------------------------------------------------------------ 
INFO: EXECUTION FAILURE 
INFO: ------------------------------------------------------------------------ 
Total time: 8.617s 
Final Memory: 9M/28M 
INFO: ------------------------------------------------------------------------ 
ERROR: Error during Sonar runner execution 
ERROR: Unable to execute Sonar 
ERROR: Caused by: Duplicate source for resource: [email protected][key=Archive.js,dir=<null>,filename=Archive.js,language=JavaScript] 
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. 
Build step 'Invoke Standalone Sonar Analysis' marked build as failure 

編輯:確認時不能提交測試報告的分析完成後確定,這裏是TEST-all.xml從報告目錄中的情況下,它也提供了一個線索

<testsuite name="Mocha Tests" tests="36" failures="0" errors="0" skipped="0" timestamp="Fri, 07 Feb 2014 10:23:12 GMT" time="1.073"> 
<testcase classname="Archive" name="should respond with 404 Not Found if pathInfo is not &quot;/&quot; or &quot;&quot;" time="0.005"/> 
<testcase classname="Archive when the archive does not exist" name="should respond with 404 not Found" time="0.002"/> 
<testcase classname="Archive when the archive exists" name="should respond with the archive" time="0.004"/> 
<testcase classname="Get with an empty repository" name="should respond with an empty list of libraries" time="0.003"/> 
<testcase classname="Get with a single library in the repository" name="should respond with a single entry list of libraries" time="0.002"/> 
<testcase classname="Get with a multiple libraries in the repository" name="should respond with a list of libraries" time="0.004"/> 
<testcase classname="Get with a multiple libraries in the repository" name="should prepend the root path to library paths correctly" time="0.001"/> 
<testcase classname="Get with a multiple libraries in the repository" name="should pass requests with pathInfo not equal to &quot;/&quot; or &quot;&quot; to a Library instance" time="0.001"/> 
<testcase classname="Library with an empty repository" name="should respond with 404 not Found" time="0.003"/> 
<testcase classname="Library with an empty library (no versions)" name="should respond with an empty list of versions" time="0.003"/> 
<testcase classname="Library with a single version" name="should respond with a single entry list of versions" time="0.002"/> 
<testcase classname="Library with multiple versions" name="should respond with a list of versions" time="0.002"/> 
<testcase classname="Library with multiple versions" name="should prepend the root path to library paths correctly" time="0.002"/> 
<testcase classname="Library with multiple versions" name="should pass requests with pathInfo not equal to &quot;/&quot; or &quot;&quot; to a Version instance" time="0.001"/> 
<testcase classname="Post" name="should respond with 400 Bad Request if the name is not specified" time="0.001"/> 
<testcase classname="Post" name="should respond with 400 Bad Request if the version is not specified" time="0.001"/> 
<testcase classname="Post" name="should respond with 415 Unsupported Media Type if the content-type is not application/octet-stream" time="0.001"/> 
<testcase classname="Post" name="should respond with a new resource on success and write the archive and dependencies to the file system" time="0.015"/> 
<testcase classname="Post" name="should respond with 400 Bad Request if dependencies are specified in an invalid format" time="0.005"/> 
<testcase classname="Post" name="should add the dependencies to the new resource if present in the headers" time="0.015"/> 
<testcase classname="Post" name="should prepend the root path to library paths correctly" time="0.011"/> 
<testcase classname="Post" name="should respond with 405 Method Not Allowed if pathInfo is not &quot;/&quot; or &quot;&quot;" time="0.001"/> 
<testcase classname="Registry GET" name="should be handled by an instance of Get" time="0.001"/> 
<testcase classname="Registry POST" name="should be handled by an instance of Post" time="0"/> 
<testcase classname="Registry UNKNOWN" name="should respond with 405 Method Not Allowed" time="0"/> 
<testcase classname="Version when the version does not exist" name="should respond with 404 not Found" time="0.003"/> 
<testcase classname="Version when the version exists" name="should respond with the version details and an empty list of dependencies" time="0.002"/> 
<testcase classname="Version when the version exists" name="should pass requests with pathInfo equal to &quot;/archive&quot; to an Archive instance" time="0.001"/> 
<testcase classname="Version when the version exists" name="should respond with 404 Not Found if pathInfo is not &quot;/&quot; or &quot;&quot; or &quot;/archive&quot;" time="0"/> 
<testcase classname="Version when the version exists with a dependencies.json file" name="should respond with the list of dependencies" time="0.005"/> 
<testcase classname="Version when the version exists with a dependencies.json file" name="should prepend the root path to library paths correctly" time="0.004"/> 
<testcase classname="index with an empty repository GET &quot;/&quot;" name="should return an empty list of libraries" time="0.022"/> 
<testcase classname="index with an empty repository after posting a library to &quot;/&quot; GET &quot;/&quot;" name="should respond with a single entry list of libraries" time="0.005"/> 
<testcase classname="index with an empty repository after posting a library to &quot;/&quot; GET &quot;/library&quot;" name="should respond with a single entry list of versions" time="0.005"/> 
<testcase classname="index with an empty repository after posting a library to &quot;/&quot; GET &quot;/library/0.0.0&quot;" name="should respond with the library resource" time="0.009"/> 
<testcase classname="index with an empty repository after posting a library to &quot;/&quot; GET &quot;/library/0.0.0/archive&quot;" name="should respond with the library archive" time="0.006"/> 
</testsuite> 
+0

能否請您提供完整的日誌? –

+0

確定已添加到問題 – pghalliday

+0

您能否確認如果從sonar-project.properties文件中刪除「sonar.javascript.jstestdriver.reportsPath = reports」,分析是否成功? –

回答

0

所以在確認該問題是由具有包含鏡像源文件名的類名的測試報告而引起的。我面臨重組我的測試或使用不同的摩卡記者的選擇。就我所知,默認的mocha xunit記者濫用了classname字段(至少在BDD測試中),並且對我的測試結構進行的更改會使其工作不被我接受。

該解決方案已經實施和使用"mocha-sonar-reporter"現在可從故宮註冊表