This repository was archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 751
Re-enable tests #4564
Merged
Merged
Re-enable tests #4564
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,26 +19,34 @@ function caughtException() { | |
| add_task(async function() { | ||
| const dbg = await initDebugger("doc-exceptions.html"); | ||
|
|
||
| // test skipping an uncaught exception | ||
| log("1. test skipping an uncaught exception"); | ||
| await uncaughtException(); | ||
| ok(!isPaused(dbg)); | ||
|
|
||
| // Test pausing on an uncaught exception | ||
| log("2. Test pausing on an uncaught exception"); | ||
| await togglePauseOnExceptions(dbg, true, false); | ||
| uncaughtException(); | ||
| await waitForPaused(dbg); | ||
| assertPausedLocation(dbg); | ||
| await resume(dbg); | ||
| await waitForActive(dbg); | ||
|
|
||
| // Test pausing on a caught Error | ||
| log("3. Test pausing on a caught Error"); | ||
| caughtException(); | ||
| await waitForPaused(dbg); | ||
| assertPausedLocation(dbg); | ||
|
|
||
| log("3.b Test pausing in the catch statement"); | ||
| await resume(dbg); | ||
| await waitForPaused(dbg); | ||
| assertPausedLocation(dbg); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we had previously been sloppy w/ this test and had allowed |
||
| await resume(dbg); | ||
|
|
||
| // Test skipping a caught error | ||
| log("4. Test skipping a caught error"); | ||
| await togglePauseOnExceptions(dbg, true, true); | ||
| caughtException(); | ||
|
|
||
| log("4.b Test pausing in the catch statement"); | ||
| await waitForPaused(dbg); | ||
| assertPausedLocation(dbg); | ||
| await resume(dbg); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,7 +53,15 @@ registerCleanupFunction(() => { | |
| }); | ||
|
|
||
| function log(msg, data) { | ||
| info(`${msg} ${JSON.stringify(data)}`); | ||
| info(`${msg} ${!data ? "" : JSON.stringify(data)}`); | ||
| } | ||
|
|
||
| function logThreadEvents(dbg, event) { | ||
| const thread = dbg.toolbox.threadClient; | ||
|
|
||
| thread.addListener(event, function onEvent(eventName, ...args) { | ||
| info(`Thread event '${eventName}' fired.`); | ||
| }); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a new log that is helpful for debugging |
||
| } | ||
|
|
||
| // Wait until an action of `type` is dispatched. This is different | ||
|
|
@@ -113,11 +121,11 @@ function waitForDispatch(dbg, type, eventRepeat = 1) { | |
| let count = 0; | ||
|
|
||
| return Task.spawn(function*() { | ||
| info("Waiting for " + type + " to dispatch " + eventRepeat + " time(s)"); | ||
| info(`Waiting for ${type} to dispatch ${eventRepeat} time(s)`); | ||
| while (count < eventRepeat) { | ||
| yield _afterDispatchDone(dbg.store, type); | ||
| count++; | ||
| info(type + " dispatched " + count + " time(s)"); | ||
| info(`${type} dispatched ${count} time(s)`); | ||
| } | ||
| }); | ||
| } | ||
|
|
@@ -132,12 +140,12 @@ function waitForDispatch(dbg, type, eventRepeat = 1) { | |
| * @static | ||
| */ | ||
| function waitForThreadEvents(dbg, eventName) { | ||
| info("Waiting for thread event '" + eventName + "' to fire."); | ||
| info(`Waiting for thread event '${eventName}' to fire.`); | ||
| const thread = dbg.toolbox.threadClient; | ||
|
|
||
| return new Promise(function(resolve, reject) { | ||
| thread.addListener(eventName, function onEvent(eventName, ...args) { | ||
| info("Thread event '" + eventName + "' fired."); | ||
| info(`Thread event '${eventName}' fired.`); | ||
| thread.removeListener(eventName, onEvent); | ||
| resolve.apply(resolve, args); | ||
| }); | ||
|
|
@@ -184,7 +192,7 @@ function waitForSources(dbg, ...sources) { | |
| return Promise.resolve(); | ||
| } | ||
|
|
||
| info("Waiting on sources: " + sources.join(", ")); | ||
| info(`Waiting on sources: ${sources.join(", ")}`); | ||
| const { selectors: { getSources }, store } = dbg; | ||
| return Promise.all( | ||
| sources.map(url => { | ||
|
|
@@ -339,6 +347,14 @@ function isPaused(dbg) { | |
| return !!getPause(getState()); | ||
| } | ||
|
|
||
| async function waitForLoadedObjects(dbg) { | ||
| const { hasLoadingObjects } = dbg.selectors; | ||
| return waitForState( | ||
| dbg, | ||
| state => !hasLoadingObjects(state), | ||
| "loaded objects" | ||
| ); | ||
| } | ||
| /** | ||
| * Waits for the debugger to be fully paused. | ||
| * | ||
|
|
@@ -355,9 +371,7 @@ async function waitForPaused(dbg) { | |
| const paused = isPaused(dbg); | ||
| const scope = !!getSelectedScope(state); | ||
| const loaded = !hasLoadingObjects(state); | ||
| return ( | ||
| isPaused(dbg) && getSelectedScope(state) && !hasLoadingObjects(state) | ||
| ); | ||
| return paused && scope && loaded; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :) |
||
| }, | ||
| "paused" | ||
| ); | ||
|
|
@@ -486,7 +500,7 @@ function findSource(dbg, url) { | |
| const source = sources.find(s => (s.get("url") || "").includes(url)); | ||
|
|
||
| if (!source) { | ||
| throw new Error("Unable to find source: " + url); | ||
| throw new Error(`Unable to find source: ${url}`); | ||
| } | ||
|
|
||
| return source.toJS(); | ||
|
|
@@ -496,7 +510,7 @@ function waitForLoadedSource(dbg, url) { | |
| return waitForState( | ||
| dbg, | ||
| state => findSource(dbg, url).loadedState == "loaded", | ||
| `loaded source` | ||
| "loaded source" | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -511,13 +525,13 @@ function waitForLoadedSource(dbg, url) { | |
| * @static | ||
| */ | ||
| function selectSource(dbg, url, line) { | ||
| info("Selecting source: " + url); | ||
| info(`Selecting source: ${url}`); | ||
| const source = findSource(dbg, url); | ||
| return dbg.actions.selectSource(source.id, { location: { line } }); | ||
| } | ||
|
|
||
| function closeTab(dbg, url) { | ||
| info("Closing tab: " + url); | ||
| info(`Closing tab: ${url}`); | ||
| const source = findSource(dbg, url); | ||
| return dbg.actions.closeTab(source.url); | ||
| } | ||
|
|
@@ -662,7 +676,7 @@ function removeBreakpoint(dbg, sourceId, line, col) { | |
| * @return {Promise} | ||
| * @static | ||
| */ | ||
| function togglePauseOnExceptions( | ||
| async function togglePauseOnExceptions( | ||
| dbg, | ||
| pauseOnExceptions, | ||
| ignoreCaughtExceptions | ||
|
|
@@ -673,12 +687,17 @@ function togglePauseOnExceptions( | |
| ); | ||
|
|
||
| if (!isPaused(dbg)) { | ||
| return waitForThreadEvents(dbg, "resumed"); | ||
| await waitForThreadEvents(dbg, "resumed"); | ||
| await waitForLoadedObjects(dbg); | ||
| } | ||
|
|
||
| return command; | ||
| } | ||
|
|
||
| function waitForActive(dbg) { | ||
| return waitForState(dbg, state => !dbg.selectors.isPaused(state), "active"); | ||
| } | ||
|
|
||
| // Helpers | ||
|
|
||
| /** | ||
|
|
@@ -795,7 +814,7 @@ const selectors = { | |
| highlightLine: ".CodeMirror-code > .highlight-line", | ||
| codeMirror: ".CodeMirror", | ||
| resume: ".resume.active", | ||
| sourceTabs: `.source-tabs`, | ||
| sourceTabs: ".source-tabs", | ||
| stepOver: ".stepOver.active", | ||
| stepOut: ".stepOut.active", | ||
| stepIn: ".stepIn.active", | ||
|
|
@@ -806,8 +825,8 @@ const selectors = { | |
| sourceNode: i => `.sources-list .tree-node:nth-child(${i})`, | ||
| sourceNodes: ".sources-list .tree-node", | ||
| sourceArrow: i => `.sources-list .tree-node:nth-child(${i}) .arrow`, | ||
| resultItems: `.result-list .result-item`, | ||
| fileMatch: `.managed-tree .result` | ||
| resultItems: ".result-list .result-item", | ||
| fileMatch: ".managed-tree .result" | ||
| }; | ||
|
|
||
| function getSelector(elementName, ...args) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was recently added and not well tested before