Batch running of VS code coverage tools

前端 未结 2 707
忘掉有多难
忘掉有多难 2020-12-18 04:45

I came up a batch file to generate code coverage file as is written in this post.

cl /Zi hello.cpp -link /Profile
vsinstr -coverage hello.exe
start vsperfmon         


        
相关标签:
2条回答
  • 2020-12-18 04:58

    This is just a timing issue.

    The start vsperfmon /coverage /output:run.coverage command starts up vsperfmon.exe in a separate process.

    Concurrently, your script goes on to run hello. If hello is a really simple program, it is possible that it executes and completes before vsperfmon.exe is running and fully initialized. If your script hits vsperfcmd /shutdown before the monitor is up and running, you will get the error you're showing.

    vsperfcmd is just a controller/launcher for vsperfmon, so you can use that exclusively in your batch file:

    cl /Zi hello.cpp -link /Profile
    vsinstr -coverage hello.exe
    vsperfcmd /start:coverage /output:run.coverage
    hello
    vsperfcmd /shutdown
    

    In this case, the first call to vsperfcmd will block until the monitor is up and fully running.

    0 讨论(0)
  • 2020-12-18 05:10

    To do this for already instrumented files with an IIS Express application: Get the name of the site from C:\Users\<your user>\Documents\IISExpress\config\applicationhost.config

    vsperfcmd /start:coverage /output:run.coverage
    "c:\Program Files (x86)\IIS Express\iisexpress.exe" /site:"<that thing you got from applicationhost.config>"
    

    a browser will likely auto launch. click around in your code, do your manual tests.

    then to finish

    vsperfcmd /shutdown
    
    0 讨论(0)
提交回复
热议问题