tntim96 / JSCover

JSCover is a JavaScript Code Coverage Tool that measures line, branch and function coverage
GNU General Public License v2.0
399 stars 84 forks source link

Jscover staring with fs and hit Unknown resource error #315

Closed angelikaYang closed 2 years ago

angelikaYang commented 2 years ago

I am using JSCover + selenium to generate the coverage report for my project, and I start the JSCover with "java -jar target/dist/JSCover-all.jar -fs --threads=50 TEST_TARGET/resources TEST_TARGET/report" but hit the below error, any idea about this issue? Exception in thread "pool-2-thread-44" java.lang.RuntimeException: Exception parsing "/test/apps/LateralNavigationOPA.js" at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:149) at com.google.javascript.jscomp.JsAst.parse(JsAst.java:155) at com.google.javascript.jscomp.JsAst.getAstRoot(JsAst.java:62) at com.google.javascript.jscomp.Compiler.parse(Compiler.java:1130) at jscover.instrument.SourceProcessor.instrumentSource(SourceProcessor.java:471) at jscover.instrument.SourceProcessor.processSourceWithoutHeader(SourceProcessor.java:438) at jscover.instrument.SourceProcessor.processSource(SourceProcessor.java:426) at jscover.instrument.SourceProcessor.processSourceForFileSystem(SourceProcessor.java:418) at jscover.instrument.InstrumenterService.instrumentJSForFileSystem(InstrumenterService.java:381) at jscover.filesystem.FileSystemInstrumenter.lambda$copyFolder$2(FileSystemInstrumenter.java:417) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.IndexOutOfBoundsException: index (1) must be less than size (1) at com.google.javascript.jscomp.jarjar.com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:1355) at com.google.javascript.jscomp.jarjar.com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:1337) at com.google.javascript.jscomp.jarjar.com.google.common.collect.SingletonImmutableList.get(SingletonImmutableList.java:44) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.getEndOfArgCommentZones(IRFactory.java:1449) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processFunctionCall(IRFactory.java:1356) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2800) at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:734) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processExpressionStatement(IRFactory.java:1292) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2816) at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:734) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processAstRoot(IRFactory.java:1161) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2862) at com.google.javascript.jscomp.parsing.IRFactory.transformTree(IRFactory.java:325) at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:138) ... 12 more

tntim96 commented 2 years ago

What's the code in LateralNavigationOPA.js (if it's not sensitive)? Looks like the closure-compiler can't process that file.

angelikaYang commented 2 years ago

There are some more info: C:\Test\Hana\JSCover\JSCOVER>java -jar target/dist/JSCover-all.jar -fs C:\Test\Hana\JSCover\JSCOVER\TEST_TARGET\resources TEST_TARGET/report Apr 20, 2022 3:20:06 AM jscover.Main runMain INFO: Args: -fs,C:\Test\Hana\JSCover\JSCOVER\TEST_TARGET\resources,TEST_TARGET/report Exception in thread "pool-2-thread-3" java.lang.RuntimeException: Exception parsing "/sap/hana/cockpit/hdb/admin/admissioncontrol/ActiveQueue.controller.js" at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:149) at com.google.javascript.jscomp.JsAst.parse(JsAst.java:155) at com.google.javascript.jscomp.JsAst.getAstRoot(JsAst.java:62) at com.google.javascript.jscomp.Compiler.parse(Compiler.java:1130) at jscover.instrument.SourceProcessor.instrumentSource(SourceProcessor.java:471) at jscover.instrument.SourceProcessor.processSourceWithoutHeader(SourceProcessor.java:438) at jscover.instrument.SourceProcessor.processSource(SourceProcessor.java:426) at jscover.instrument.SourceProcessor.processSourceForFileSystem(SourceProcessor.java:418) at jscover.instrument.InstrumenterService.instrumentJSForFileSystem(InstrumenterService.java:381) at jscover.filesystem.FileSystemInstrumenter.lambda$copyFolder$2(FileSystemInstrumenter.java:417) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ArrayIndexOutOfBoundsException: 4 at com.google.javascript.jscomp.jarjar.com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:77) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.getEndOfArgCommentZones(IRFactory.java:1449) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processFunctionCall(IRFactory.java:1356) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2800) at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:734) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processExpressionStatement(IRFactory.java:1292) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2816) at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:734) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processAstRoot(IRFactory.java:1161) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2862) at com.google.javascript.jscomp.parsing.IRFactory.transformTree(IRFactory.java:325) at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:138) ... 12 more Exception in thread "pool-2-thread-8" Exception in thread "pool-2-thread-4" java.lang.RuntimeException: Exception parsing "/sap/hana/cockpit/hdb/admin/ambari/ClusterEdit.controller.js" at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:149) at com.google.javascript.jscomp.JsAst.parse(JsAst.java:155) at com.google.javascript.jscomp.JsAst.getAstRoot(JsAst.java:62) at com.google.javascript.jscomp.Compiler.parse(Compiler.java:1130) at jscover.instrument.SourceProcessor.instrumentSource(SourceProcessor.java:471) at jscover.instrument.SourceProcessor.processSourceWithoutHeader(SourceProcessor.java:438) at jscover.instrument.SourceProcessor.processSource(SourceProcessor.java:426) at jscover.instrument.SourceProcessor.processSourceForFileSystem(SourceProcessor.java:418) at jscover.instrument.InstrumenterService.instrumentJSForFileSystem(InstrumenterService.java:381) at jscover.filesystem.FileSystemInstrumenter.lambda$copyFolder$2(FileSystemInstrumenter.java:417) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ArrayIndexOutOfBoundsException: 4 at com.google.javascript.jscomp.jarjar.com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:77) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.getEndOfArgCommentZones(IRFactory.java:1449) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processFunctionCall(IRFactory.java:1356) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2800) at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:734) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processExpressionStatement(IRFactory.java:1292) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2816) at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:734) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processAstRoot(IRFactory.java:1161) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2862) at com.google.javascript.jscomp.parsing.IRFactory.transformTree(IRFactory.java:325) at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:138) ... 12 more Exception in thread "pool-2-thread-5" java.lang.RuntimeException: Exception parsing "/sap/hana/cockpit/hdb/admin/admissioncontrol/Statistics.controller.js" at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:149) at com.google.javascript.jscomp.JsAst.parse(JsAst.java:155) at com.google.javascript.jscomp.JsAst.getAstRoot(JsAst.java:62) at com.google.javascript.jscomp.Compiler.parse(Compiler.java:1130) at jscover.instrument.SourceProcessor.instrumentSource(SourceProcessor.java:471) at jscover.instrument.SourceProcessor.processSourceWithoutHeader(SourceProcessor.java:438) at jscover.instrument.SourceProcessor.processSource(SourceProcessor.java:426) at jscover.instrument.SourceProcessor.processSourceForFileSystem(SourceProcessor.java:418) at jscover.instrument.InstrumenterService.instrumentJSForFileSystem(InstrumenterService.java:381) at jscover.filesystem.FileSystemInstrumenter.lambda$copyFolder$2(FileSystemInstrumenter.java:417) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ArrayIndexOutOfBoundsException: 12 at com.google.javascript.jscomp.jarjar.com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:77) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.getEndOfArgCommentZones(IRFactory.java:1449) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processFunctionCall(IRFactory.java:1356) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2800) at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:734) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processExpressionStatement(IRFactory.java:1292) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2816) at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:734) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processAstRoot(IRFactory.java:1161) at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2862) at com.google.javascript.jscomp.parsing.IRFactory.transformTree(IRFactory.java:325) at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:138) ... 12 more

angelikaYang commented 2 years ago

I wanna generate the coverage report of my selenium test for my project, I had "git clone" the code to C:\Test\Hana\JSCover\JSCOVER\TEST_TARGET\resources, and using the ChromeDriver.get("http:mon***") to open the project and run the selenium test. My steps are: First using the fs to instrument my local code and then I will start a proxy server, but first i hit the error as upside. and further issue i have is "selenium.common.exceptions.JavascriptException: Message: javascript error: jscoverage_serializeCoverageToJSON is not defined"

I can not apply it on my projects, I have the site ("http:mon") that is being run on https, I am not sure how to provide a http site, when I enter the url in the url input box and i get the below error: The webpage at https://mon3:51043/ might be temporarily down or it may have moved permanently to a new web address, but i click open in new window it can be opened but hit the error "javascript error: jscoverage_serializeCoverageToJSON is not defined" when I perform ChromeDriver.execute_script("return jscoverage_serializeCoverageToJSON();").

That will be great if u can give insights on how to proceed this

tntim96 commented 2 years ago

My steps are: First using the fs to instrument my local code and then I will start a proxy server

You don't need the JSCover proxy server if you've already done file-system instrumentation

but first i hit the error as upside

You would need to isolate the relevant JS code and give me the JS code snippet that causes the issue so I can investigate.

That will be great if u can give insights on how to proceed this

Please look at the samples in https://github.com/tntim96/JSCover/tree/master/examples. It looks like the one that will work best for you is https://github.com/tntim96/JSCover/tree/master/examples/localStorage-file-system