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 file-proxy, when I use JSCover-all.jar to instrument my js file,I got something wrong as the following: #288

Closed Kepler-ZZ closed 4 years ago

Kepler-ZZ commented 4 years ago

JSCover file-proxy, when I use JSCover-all.jar to instrument my js file,I got something wrong as the following:

0200612 15:19:23.314,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 233 lineOffset: 4",jscover.instrument.SourceProcessor, 20200612 15:19:23.315,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 245 lineOffset: 6",jscover.instrument.SourceProcessor, 20200612 15:19:23.315,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 272 lineOffset: 4",jscover.instrument.SourceProcessor, 20200612 15:19:23.316,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 402 lineOffset: 4",jscover.instrument.SourceProcessor, 20200612 15:19:23.316,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 420 lineOffset: 10",jscover.instrument.SourceProcessor, 20200612 15:19:23.316,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 426 lineOffset: 10",jscover.instrument.SourceProcessor, 20200612 15:19:23.317,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 428 lineOffset: 8",jscover.instrument.SourceProcessor, 20200612 15:19:23.317,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 441 lineOffset: 6",jscover.instrument.SourceProcessor, 20200612 15:19:23.317,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 443 lineOffset: 6",jscover.instrument.SourceProcessor, 20200612 15:19:23.318,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 641 lineOffset: 4",jscover.instrument.SourceProcessor, 20200612 15:19:23.318,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 658 lineOffset: 10",jscover.instrument.SourceProcessor, 20200612 15:19:23.400,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 661 lineOffset: 8",jscover.instrument.SourceProcessor, 20200612 15:19:23.401,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 969 lineOffset: 10",jscover.instrument.SourceProcessor, 20200612 15:19:23.401,40,SEVERE,"return must be inside function, sourceName: /packages/vplayer/src/dispatcher/index.js, line: 1,004 lineOffset: 10",jscover.instrument.SourceProcessor, Exception in thread "pool-2-thread-28" java.lang.IllegalStateException: Bad GETPROP: RHS should be STRING at com.google.common.base.Preconditions.checkState(Preconditions.java:507) at com.google.javascript.jscomp.CodeGenerator.add(CodeGenerator.java:794) at com.google.javascript.jscomp.CodeGenerator.addExpr(CodeGenerator.java:1619) at com.google.javascript.jscomp.CodeGenerator.add(CodeGenerator.java:694) at com.google.javascript.jscomp.CodeGenerator.add(CodeGenerator.java:668) at com.google.javascript.jscomp.CodeGenerator.add(CodeGenerator.java:668) at com.google.javascript.jscomp.CodeGenerator.add(CodeGenerator.java:104) at com.google.javascript.jscomp.CodePrinter.toSource(CodePrinter.java:843) at com.google.javascript.jscomp.CodePrinter.access$300(CodePrinter.java:40) at com.google.javascript.jscomp.CodePrinter$Builder.build(CodePrinter.java:778) at jscover.instrument.SourceProcessor.instrumentSource(SourceProcessor.java:476) at jscover.instrument.SourceProcessor.processSourceWithoutHeader(SourceProcessor.java:435) at jscover.instrument.SourceProcessor.processSource(SourceProcessor.java:423) at jscover.instrument.SourceProcessor.processSourceForFileSystem(SourceProcessor.java:415) at jscover.instrument.InstrumenterService.instrumentJSForFileSystem(InstrumenterService.java:381) at jscover.filesystem.FileSystemInstrumenter.lambda$copyFolder$2(FileSystemInstrumenter.java:417) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:830)

tntim96 commented 4 years ago

Hi @Kepler-ZZ , can you provide a sample of the JavaScript?

Kepler-ZZ commented 4 years ago

Hi @Kepler-ZZ , can you provide a sample of the JavaScript?

ok, such as this JS,I can't instrument it.

plugin.js.zip

tntim96 commented 4 years ago

Yep - it looks like TypeScript.

Kepler-ZZ commented 4 years ago

Yep - it looks like TypeScript.

so TypeScript can't be instrumented?

tntim96 commented 4 years ago

Not currently

Kepler-ZZ commented 4 years ago

Not currently

Can the JSCover distinguish JavaScript file and TypeScript file??
for exmaple, if it is TypeScript file,just copy not instrument . If it is JavaScript,will be instrumented. Because my project includes JavaScript and TypeScript. I just want get some of JavaScript coverage. But after I use JSCover's file-mode to instrument ,the directory missed TypeScript file, my project was not complete,So it couldn't be compile and run....

Kepler-ZZ commented 4 years ago

Hi @tntim96 , I also have a try proxy-mode, but it throw an exception :

Exception in thread "main" java.lang.OutOfMemoryError:unable to create new native thread; at java.lang.Thread.start0(Native Method); at java.lang.Thread.start(Thread.java:714); at jscover.server.WebDaemon.start(WebDaemon.java:370); at jscover.Main.runServer(Main.java:491); at jscover.Main.runJSCover(Main.java:447); at jscover.Main.runMain(Main.java:417); at jscover.Main.main(Main.java:406);

It is the same as #166 ,you let us using --threads=50 to solve this problem. but I don't know how to use '--threads=50', I got following exception:

6月 10, 2020 6:20:09 下午 jscover.Main runMain 信息: Args: -ws,--threads=50,--proxy,--port=3128,--report-dir=target/local-storage-proxy,--local-storage JSCover: Unknown option '--threads=50' Usage: java -jar JSCover-all.jar -ws [OPTION]... Run a server for instrumenting JavaScript with code coverage information.

so what should I do? :(

tntim96 commented 4 years ago

Can the JSCover distinguish JavaScript file and TypeScript file?

No.

--threads=50

That's a file-mode only setting.