Merge lp:~marcustomlinson/unity-scopes-api/clean_up_Registry_test into lp:unity-scopes-api/devel

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Michi Henning
Approved revision: 471
Merged at revision: 471
Proposed branch: lp:~marcustomlinson/unity-scopes-api/clean_up_Registry_test
Merge into: lp:unity-scopes-api/devel
Diff against target: 138 lines (+40/-15)
1 file modified
test/gtest/scopes/Registry/Registry_test.cpp (+40/-15)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scopes-api/clean_up_Registry_test
Reviewer Review Type Date Requested Status
Michi Henning (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+232408@code.launchpad.net

Commit message

Clean up any remaining files in case of an interrupted run, and copy / remove files rather than moving them to allow for this.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Looks good to me, thanks for that! It also fixes the issue with the test failing when compiling with coverage enabled. I've linked the relevant bug.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test/gtest/scopes/Registry/Registry_test.cpp'
2--- test/gtest/scopes/Registry/Registry_test.cpp 2014-08-18 06:51:26 +0000
3+++ test/gtest/scopes/Registry/Registry_test.cpp 2014-08-27 13:29:37 +0000
4@@ -270,8 +270,15 @@
5 return success;
6 };
7
8- // Move testscopeC into the scopes folder
9- filesystem::rename(TEST_RUNTIME_PATH "/other_scopes/testscopeC", TEST_RUNTIME_PATH "/scopes/testscopeC");
10+ system::error_code ec;
11+
12+ // Copy testscopeC into the scopes folder
13+ filesystem::create_directory(TEST_RUNTIME_PATH "/scopes/testscopeC", ec);
14+ ASSERT_EQ("Success", ec.message());
15+ filesystem::copy(TEST_RUNTIME_PATH "/other_scopes/testscopeC/testscopeC.ini", TEST_RUNTIME_PATH "/scopes/testscopeC/testscopeC.ini", ec);
16+ ASSERT_EQ("Success", ec.message());
17+ filesystem::copy(TEST_RUNTIME_PATH "/other_scopes/testscopeC/libtestscopeC.so", TEST_RUNTIME_PATH "/scopes/testscopeC/libtestscopeC.so", ec);
18+ ASSERT_EQ("Success", ec.message());
19 std::this_thread::sleep_for(std::chrono::milliseconds(500));
20
21 auto meta = r->get_metadata("testscopeC");
22@@ -297,8 +304,9 @@
23 EXPECT_FALSE(wait_for_state_update());
24 EXPECT_TRUE(r->is_scope_running("testscopeC"));
25
26- // Move testscopeC back into the other_scopes folder
27- filesystem::rename(TEST_RUNTIME_PATH "/scopes/testscopeC", TEST_RUNTIME_PATH "/other_scopes/testscopeC");
28+ // Remove testscopeC from the scopes folder
29+ filesystem::remove_all(TEST_RUNTIME_PATH "/scopes/testscopeC", ec);
30+ ASSERT_EQ("Success", ec.message());
31 std::this_thread::sleep_for(std::chrono::milliseconds(500));
32 }
33
34@@ -328,8 +336,15 @@
35 return success;
36 };
37
38- // Move testscopeC into the scopes folder
39- filesystem::rename(TEST_RUNTIME_PATH "/other_scopes/testscopeC", TEST_RUNTIME_PATH "/scopes/testscopeC");
40+ system::error_code ec;
41+
42+ // Copy testscopeC into the scopes folder
43+ filesystem::create_directory(TEST_RUNTIME_PATH "/scopes/testscopeC", ec);
44+ ASSERT_EQ("Success", ec.message());
45+ filesystem::copy(TEST_RUNTIME_PATH "/other_scopes/testscopeC/testscopeC.ini", TEST_RUNTIME_PATH "/scopes/testscopeC/testscopeC.ini", ec);
46+ ASSERT_EQ("Success", ec.message());
47+ filesystem::copy(TEST_RUNTIME_PATH "/other_scopes/testscopeC/libtestscopeC.so", TEST_RUNTIME_PATH "/scopes/testscopeC/libtestscopeC.so", ec);
48+ ASSERT_EQ("Success", ec.message());
49 std::this_thread::sleep_for(std::chrono::milliseconds(500));
50
51 // testscopeC should not be running at this point
52@@ -361,8 +376,9 @@
53 EXPECT_TRUE(wait_for_state_update());
54 EXPECT_FALSE(r->is_scope_running("testscopeC"));
55
56- // Move testscopeC back into the other_scopes folder
57- filesystem::rename(TEST_RUNTIME_PATH "/scopes/testscopeC", TEST_RUNTIME_PATH "/other_scopes/testscopeC");
58+ // Remove testscopeC from the scopes folder
59+ filesystem::remove_all(TEST_RUNTIME_PATH "/scopes/testscopeC", ec);
60+ ASSERT_EQ("Success", ec.message());
61 std::this_thread::sleep_for(std::chrono::milliseconds(500));
62 }
63
64@@ -407,7 +423,7 @@
65 EXPECT_EQ(list.end(), list.find("testscopeD"));
66
67 std::cout << "Create click folder: " TEST_RUNTIME_PATH "/click" << std::endl;
68- filesystem::create_directory(TEST_RUNTIME_PATH "/click");
69+ filesystem::create_directory(TEST_RUNTIME_PATH "/click", ec);
70 ASSERT_EQ("Success", ec.message());
71
72 std::cout << "Make a symlink to testscopeC in the scopes folder" << std::endl;
73@@ -424,7 +440,8 @@
74 EXPECT_EQ(list.end(), list.find("testscopeD"));
75
76 std::cout << "Remove click folder" << std::endl;
77- filesystem::remove_all(TEST_RUNTIME_PATH "/click");
78+ filesystem::remove_all(TEST_RUNTIME_PATH "/click",ec);
79+ ASSERT_EQ("Success", ec.message());
80 }
81
82 TEST(Registry, list_update_notify)
83@@ -467,9 +484,11 @@
84 EXPECT_EQ(list.end(), list.find("testscopeC"));
85 EXPECT_EQ(list.end(), list.find("testscopeD"));
86
87- // Move testscopeC into the scopes folder
88+ // Copy testscopeC into the scopes folder
89 std::cout << "Move testscopeC into the scopes folder" << std::endl;
90- filesystem::rename(TEST_RUNTIME_PATH "/other_scopes/testscopeC", TEST_RUNTIME_PATH "/scopes/testscopeC", ec);
91+ filesystem::create_directory(TEST_RUNTIME_PATH "/scopes/testscopeC", ec);
92+ ASSERT_EQ("Success", ec.message());
93+ filesystem::copy(TEST_RUNTIME_PATH "/other_scopes/testscopeC/testscopeC.ini", TEST_RUNTIME_PATH "/scopes/testscopeC/testscopeC.ini", ec);
94 ASSERT_EQ("Success", ec.message());
95 EXPECT_TRUE(wait_for_update());
96
97@@ -495,9 +514,9 @@
98 EXPECT_NE(list.end(), list.find("testscopeC"));
99 EXPECT_NE(list.end(), list.find("testscopeD"));
100
101- // Move testscopeC back into the other_scopes folder
102+ // Remove testscopeC from the scopes folder
103 std::cout << "Move testscopeC back into the other_scopes folder" << std::endl;
104- filesystem::rename(TEST_RUNTIME_PATH "/scopes/testscopeC", TEST_RUNTIME_PATH "/other_scopes/testscopeC", ec);
105+ filesystem::remove_all(TEST_RUNTIME_PATH "/scopes/testscopeC", ec);
106 ASSERT_EQ("Success", ec.message());
107 EXPECT_TRUE(wait_for_update());
108
109@@ -576,6 +595,7 @@
110 std::cout << "Make a symlink to testscopeB-settings.ini in scopes/testscopeB" << std::endl;
111 filesystem::create_symlink(TEST_SRC_PATH "/scopes/testscopeB/testscopeB-settings.ini",
112 TEST_RUNTIME_PATH "/scopes/testscopeB/testscopeB-settings.ini", ec);
113+ ASSERT_EQ("Success", ec.message());
114 EXPECT_TRUE(wait_for_update());
115
116 // Must be able to see the new definitions now
117@@ -587,6 +607,7 @@
118 // Remove settings definition
119 std::cout << "Remove symlink to testscopeB-settings.ini in scopes/testscopeB" << std::endl;
120 filesystem::remove(TEST_RUNTIME_PATH "/scopes/testscopeB/testscopeB-settings.ini", ec);
121+ ASSERT_EQ("Success", ec.message());
122 EXPECT_TRUE(wait_for_update());
123
124 // Definition must be gone now
125@@ -599,8 +620,12 @@
126 {
127 ::testing::InitGoogleTest(&argc, argv);
128
129- // Unlink in case we left the link behind from an earlier interrupted run.
130+ // Clean up in case we left something behind from an earlier interrupted run.
131 system::error_code ec;
132+ filesystem::remove_all(TEST_RUNTIME_PATH "/scopes/testscopeC", ec);
133+ filesystem::remove_all(TEST_RUNTIME_PATH "/click",ec);
134+ filesystem::remove(TEST_RUNTIME_PATH "/scopes/testscopeD", ec);
135+ filesystem::remove_all(TEST_RUNTIME_PATH "/scopes/testfolder", ec);
136 filesystem::remove(TEST_RUNTIME_PATH "/scopes/testscopeB/testscopeB-settings.ini", ec);
137
138 auto rpid = fork();

Subscribers

People subscribed via source and target branches

to all changes: