vscode extensions: debug auto tests: debugger suddenly stops on "step over" - debugging

I wrote test code for an extension I'm writing in and for vscode. When I debug my tests step-by-step the debugger sometimes suddenly stops.
I cannot pin it down to specific commands being run, so I'm really tapping in the dar.

I stumbled across this on accident: It looks like the debugger is being stopped, because of mocha's timeout constraint (mocha is the test framework vscode uses by default for its extension).
For me it helped increasing that timeout:
In index.ts a Mocha object is being created. You can change time timeout like this:
const mocha = new Mocha({
ui: 'tdd',
color: true
});
mocha.timeout (5000000); // increased timeout

Related

breakpoints are greyed out vs code react-native-tools debug

No matter if I choose "Attach to packager" configuration running packager with
react-native start
first or "Debug Android", breakpoints that I set in vs code are greyed out and are not get hit.
Here is information I am getting from Debug Console:
OS: win32 ia32 Adapter node: v7.9.0 ia32 vscode-chrome-debug-core:
3.23.0 Starting debugger app worker. Established a connection with the Proxy (Packager) to the React Native application Debugger worker
loaded runtime on port 10029 Running application "EugeneKrApp" with
appParams: {"rootTag":71}. DEV === true, development-level warning
are ON, performance optimizations are OFF index.bundle:19019 Warning:
componentWillMount is deprecated and will be removed in the next major
version. Use componentDidMount instead. As a temporary workaround, you
can rename to UNSAFE_componentWill
There is a bunch of warnings down the line like the last one about componentDidMount which I didn't include, they hardly influence debugging.
I had the same problem. It was due to the fact that 'Debug JS Remotely' was not enabled on the device/emulator.
Please check Tunvir Rahman Tusher answer and comments on this question.
Enter 'adb shell input keyevent 82' in the cmd/bash on your dev machine while the app is open on the device/emulator. A dialog box opens on the device/emulator like
Select 'Debug JS Remotely' and it will work out. You might need to restart the debugger.

Xcode wait for OS X app to launch error: Lost connection to My Mac

I'm trying to debug a Terminal app upon launch, so I've created a new scheme and selected:
I build my app, then I go to Terminal and run the app. Immediately, instead of hitting a breakpoint, I get:
And in my terminal the app is run and exited normally, without debugger attached:
My breakpoint is valid as I hit it when I launch automatically from Xcode.
Cleaned build folder, restarted Xcode etc, no avail. My code is simple as I've just created a default project:
int main(int argc, const char * argv[]) {
#autoreleasepool {
// insert code here...
}
printf("aha");
return 0;
}
In my project settings, I've set a custom location for my executable for debugging to be deterministic (I don't want Xcode to append random strings into the build data in derived data folder):
Why am I getting this error? How can I debug my executable upon launching from terminal?
Are you showing the app code just as an example or is that what you are really trying to attach to? The attach wait works by sampling the process list till it sees a process of that name, then attaches to it. So depending on how far the process has run before lldb manages to attach to it, it may very well have executed the code you set the breakpoint on before it attached. Especially if not much goes on before the breakpoint.
The best way to arrange to attach to something that you need to run in terminal is to put a spin in the program, like:
int keep_spinning = 1
while (keep_spinning)
{
sleep(1);
}
the when you attach, you can set keep_spinning to 0 and continue.
I had this problem with a (command line) unit test implemented with Google gtest, using Xcode 10. My session used "attach automatically", but I had the same problem, consistently. I had a breakpoint set near the beginning of a test case (the only one), and it never stopped, and I got the same message. Even stranger, I got it when I removed all breakpoints and simply tried to run through the program using the debugger. I was however able to get the breakpoint I wanted by setting another breakpoint early in the test's main() function. That can be tricky with gtest, because it's possible to use a generic main that simply launches all tests. Fortunately for me, we roll our own shared main. I put a breakpoint before the call that runs all the tests linked with our main, and it stopped politely as ordered. Then when hit the "continue" button, it stopped at the original break that I wanted. I have no idea why this would work when other things did not, but if anyone else is having a problem like the above, I recommend putting a breakpoint as early in the program as possible and check to see if it gets you out of this particular bind. If you happen to be in EXACTLY the same situation I encountered (that is, you are using a gtest unit test), note that no matter how early in the test instance itself I tried to break, I got the same failure mode. For me, it had to be in main. Best of luck.

stepping in Intern functional tests

My question is how can one put breakpoints in functional tests? Is it possible in Intern? I'm running the testcases locally on WebDriver, and having 'debugger;' breakpoints will ease my testcase development.
execute(function () { debugger; }) should run in browser and act on 'debugger;' in it, but it doesn't stop the execution...
I have this working. I start up a few terminals, start my selenium server jar in one, do node-inspector in another, and then fire up that url in chrome. I refresh the chrome window, then put node --debug-brk , and you will see the debugger catch, hit play - and it will go through to your debugger point. I also use the leaveRemoteOpen flag at the end of the command, which will leave the browser window open. my command looks like this:
node --debug-brk node_modules/intern/bin/intern-runner config=public/js/dojo/tt/tests/intern-config.js leaveRemoteOpen
also, in your config youll need this: excludeInstrumentation: /.*/
otherwise it munges your code.

How to debug firefox extension after cfx run?

I want to debug my firefox extension. I set
javascript.options.showInConsole = true
devtools.chrome.enabled: true
devtools.debugger.remote-enabled: true
run in sdk console cfx run, after that i go to Web Developer -> Browser Toolbox get incoming connection and i see my extension main.js. But after that, the code in main.js already been executed. How to debug it after cfx run?
also, two other things might be messing with your approach:
1) when you use cfx run, that by default creates a new profile on every run, so any settings that you have changed will not persist. to avoid this, you need to specify a profile directory with --profiledir=DIR (warning: don't use your main profile).
2) if the addon main.js code has already run by the time you open the debugger, you should start firefox manually, setup the debugger, and then drag the addon xpi into a tab.
Bug 899054 - [Meta] Implement an Add-on Debugger
this is really close to landing (the UI bits in bug 911098 are in m-c), so if you grab a Nightly tomorrow, or the day after, it should be in there, and might just work (for some undefined value of "work").

How do prevent "Debug Error!" window from appearing?

I have a series of Google Unit Tests that are launched via a bat file. Some of these tests are broken and a window appears when they run:
Microsoft Visual C++ Debug Library
Debug Error!
... Info about error
This window waits for a user to press Abort, Retry, Ignore. Of course, this halts my test. Currently, I delete the broken tests before I run the batch. I want a way to force this window to abort or ignore - so I don't need to skip the broken tests.
This problem is similar to; however, I cannot write to reg keys
How do I disable the 'Debug / Close Application' dialog on Windows Vista?
Update: My manager says this window might not appear if this project was in release. Trying to do that now. However, if there is a solution besides changing my project to release, I would appreciate it! :D
That's what you get from a failed assert() in the source code. Useful to debug the test. But actually running unit tests against code that was compiled in the Debug configuration is not useful. Your customer isn't going to run the Debug build either.
Only test the Release build, that disables those assert() calls as well.

Resources