Fix FiberManager.RequestContext unit test
authorMirek Klimos <miro@fb.com>
Wed, 29 Jun 2016 22:42:34 +0000 (15:42 -0700)
committerFacebook Github Bot 3 <facebook-github-bot-3-bot@fb.com>
Wed, 29 Jun 2016 22:53:36 +0000 (15:53 -0700)
Summary: with the added blocks, pointer to RequestContext needs to be captured by value, not reference

Differential Revision: D3499921

fbshipit-source-id: 76ff22869228fbdd7ef1651cd2814550f6abc301

folly/fibers/test/FibersTest.cpp

index a149c44b8a6e1da2a2589fa28c6e8ac39d0ae961..e962145aeaa5d24970ce4db72510257aba0693bf 100644 (file)
@@ -1270,7 +1270,7 @@ TEST(FiberManager, RequestContext) {
   {
     folly::RequestContextScopeGuard rctx;
     auto rcontext1 = folly::RequestContext::get();
-    fm.addTask([&]() {
+    fm.addTask([&, rcontext1]() {
       EXPECT_EQ(rcontext1, folly::RequestContext::get());
       baton1.wait(
           [&]() { EXPECT_EQ(rcontext1, folly::RequestContext::get()); });
@@ -1283,7 +1283,7 @@ TEST(FiberManager, RequestContext) {
   {
     folly::RequestContextScopeGuard rctx;
     auto rcontext2 = folly::RequestContext::get();
-    fm.addTaskRemote([&]() {
+    fm.addTaskRemote([&, rcontext2]() {
       EXPECT_EQ(rcontext2, folly::RequestContext::get());
       baton2.wait();
       EXPECT_EQ(rcontext2, folly::RequestContext::get());
@@ -1294,14 +1294,14 @@ TEST(FiberManager, RequestContext) {
     folly::RequestContextScopeGuard rctx;
     auto rcontext3 = folly::RequestContext::get();
     fm.addTaskFinally(
-        [&]() {
+        [&, rcontext3]() {
           EXPECT_EQ(rcontext3, folly::RequestContext::get());
           baton3.wait();
           EXPECT_EQ(rcontext3, folly::RequestContext::get());
 
           return folly::Unit();
         },
-        [&](Try<folly::Unit>&& /* t */) {
+        [&, rcontext3](Try<folly::Unit>&& /* t */) {
           EXPECT_EQ(rcontext3, folly::RequestContext::get());
           checkRun3 = true;
         });