Batch running of VS code coverage tools

前端 未结 2 709
忘掉有多难
忘掉有多难 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.

提交回复
热议问题