|
Issue #4826 - Use latch to replace thread-sleeping in tests
Add class `Latch` patterned after the Concurrency TS. It is not a complete
version, but it's adequate for what we need for the unit tests. Add
`JsTestingLatch` to expose a latch inside the v8 interpreter. This allows
arriving at a latch in JS code and waiting on it in the C++ unit test code.
Add some basic unit tests for the latch classes.
Use the latch classes to replace `sleep_for` in unit tests where callbacks are
available. The principle is to (1) instantiate a latch in the test (2) arrive
at it in a callback, whether in C++ or JS, and (3) wait for it. This pattern
eliminates all but one the race conditions in the tests that arise from the
asynchronous behavior of file system I/O and web requests.
Total comments: 3
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+489 lines, -75 lines) |
Patch |
|
M |
libadblockplus.gyp
|
View
|
|
2 chunks |
+5 lines, -0 lines |
0 comments
|
Download
|
|
A |
src/Latch.h
|
View
|
|
1 chunk |
+96 lines, -0 lines |
0 comments
|
Download
|
|
A |
src/Latch.cpp
|
View
|
|
1 chunk |
+48 lines, -0 lines |
0 comments
|
Download
|
|
M |
test/BaseJsTest.h
|
View
|
|
2 chunks |
+2 lines, -0 lines |
0 comments
|
Download
|
|
M |
test/BaseJsTest.cpp
|
View
|
|
1 chunk |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
test/FileSystemJsObject.cpp
|
View
|
|
8 chunks |
+30 lines, -18 lines |
0 comments
|
Download
|
|
M |
test/FilterEngine.cpp
|
View
|
|
3 chunks |
+7 lines, -7 lines |
0 comments
|
Download
|
|
M |
test/GlobalJsObject.cpp
|
View
|
|
3 chunks |
+13 lines, -9 lines |
0 comments
|
Download
|
|
A |
test/JsLatch.h
|
View
|
|
1 chunk |
+93 lines, -0 lines |
0 comments
|
Download
|
|
A |
test/JsLatch.cpp
|
View
|
1
|
1 chunk |
+74 lines, -0 lines |
0 comments
|
Download
|
|
A |
test/LatchTest.cpp
|
View
|
|
1 chunk |
+91 lines, -0 lines |
0 comments
|
Download
|
|
M |
test/Prefs.cpp
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
test/UpdateCheck.cpp
|
View
|
|
8 chunks |
+15 lines, -21 lines |
0 comments
|
Download
|
|
M |
test/WebRequest.cpp
|
View
|
|
6 chunks |
+11 lines, -17 lines |
0 comments
|
Download
|
Total messages: 1
|