OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <map> | 5 #include <map> |
6 #include <utility> | 6 #include <utility> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 139 |
140 // The default toolchain needs to be set by the build config file. | 140 // The default toolchain needs to be set by the build config file. |
141 mock_ifm_.AddCannedResponse(build_config, | 141 mock_ifm_.AddCannedResponse(build_config, |
142 "set_default_toolchain(\"//tc:tc\")"); | 142 "set_default_toolchain(\"//tc:tc\")"); |
143 | 143 |
144 loader->set_async_load_file(mock_ifm_.GetCallback()); | 144 loader->set_async_load_file(mock_ifm_.GetCallback()); |
145 | 145 |
146 // Request the root build file be loaded. This should kick off the default | 146 // Request the root build file be loaded. This should kick off the default |
147 // build config loading. | 147 // build config loading. |
148 SourceFile root_build("//BUILD.gn"); | 148 SourceFile root_build("//BUILD.gn"); |
149 loader->Load(root_build, Label()); | 149 loader->Load(root_build, LocationRange(), Label()); |
150 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); | 150 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); |
151 | 151 |
152 // Completing the build config load should kick off the root build file load. | 152 // Completing the build config load should kick off the root build file load. |
153 mock_ifm_.IssueAllPending(); | 153 mock_ifm_.IssueAllPending(); |
154 scheduler_.main_loop()->RunUntilIdle(); | 154 scheduler_.main_loop()->RunUntilIdle(); |
155 EXPECT_TRUE(mock_ifm_.HasOnePending(root_build)); | 155 EXPECT_TRUE(mock_ifm_.HasOnePending(root_build)); |
156 | 156 |
157 // Load the root build file. | 157 // Load the root build file. |
158 mock_ifm_.IssueAllPending(); | 158 mock_ifm_.IssueAllPending(); |
159 scheduler_.main_loop()->RunUntilIdle(); | 159 scheduler_.main_loop()->RunUntilIdle(); |
160 | 160 |
161 // Schedule some other file to load in another toolchain. | 161 // Schedule some other file to load in another toolchain. |
162 Label second_tc(SourceDir("//tc2/"), "tc2"); | 162 Label second_tc(SourceDir("//tc2/"), "tc2"); |
163 SourceFile second_file("//foo/BUILD.gn"); | 163 SourceFile second_file("//foo/BUILD.gn"); |
164 loader->Load(second_file, second_tc); | 164 loader->Load(second_file, LocationRange(), second_tc); |
165 EXPECT_TRUE(mock_ifm_.HasOnePending(SourceFile("//tc2/BUILD.gn"))); | 165 EXPECT_TRUE(mock_ifm_.HasOnePending(SourceFile("//tc2/BUILD.gn"))); |
166 | 166 |
167 // Running the toolchain file should schedule the build config file to load | 167 // Running the toolchain file should schedule the build config file to load |
168 // for that toolchain. | 168 // for that toolchain. |
169 mock_ifm_.IssueAllPending(); | 169 mock_ifm_.IssueAllPending(); |
170 scheduler_.main_loop()->RunUntilIdle(); | 170 scheduler_.main_loop()->RunUntilIdle(); |
171 | 171 |
172 // We have to tell it we have a toolchain definition now (normally the | 172 // We have to tell it we have a toolchain definition now (normally the |
173 // builder would do this). | 173 // builder would do this). |
174 const Settings* default_settings = loader->GetToolchainSettings(Label()); | 174 const Settings* default_settings = loader->GetToolchainSettings(Label()); |
175 Toolchain second_tc_object(default_settings, second_tc); | 175 Toolchain second_tc_object(default_settings, second_tc); |
176 loader->ToolchainLoaded(&second_tc_object); | 176 loader->ToolchainLoaded(&second_tc_object); |
177 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); | 177 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); |
178 | 178 |
179 // Scheduling a second file to load in that toolchain should not make it | 179 // Scheduling a second file to load in that toolchain should not make it |
180 // pending yet (it's waiting for the build config). | 180 // pending yet (it's waiting for the build config). |
181 SourceFile third_file("//bar/BUILD.gn"); | 181 SourceFile third_file("//bar/BUILD.gn"); |
182 loader->Load(third_file, second_tc); | 182 loader->Load(third_file, LocationRange(), second_tc); |
183 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); | 183 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); |
184 | 184 |
185 // Running the build config file should make our third file pending. | 185 // Running the build config file should make our third file pending. |
186 mock_ifm_.IssueAllPending(); | 186 mock_ifm_.IssueAllPending(); |
187 scheduler_.main_loop()->RunUntilIdle(); | 187 scheduler_.main_loop()->RunUntilIdle(); |
188 EXPECT_TRUE(mock_ifm_.HasTwoPending(second_file, third_file)); | 188 EXPECT_TRUE(mock_ifm_.HasTwoPending(second_file, third_file)); |
189 | 189 |
190 EXPECT_FALSE(scheduler_.is_failed()); | 190 EXPECT_FALSE(scheduler_.is_failed()); |
191 } | 191 } |
OLD | NEW |