Chromium Code Reviews| 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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "tools/gn/build_settings.h" | 13 #include "tools/gn/build_settings.h" |
| 13 #include "tools/gn/err.h" | 14 #include "tools/gn/err.h" |
| 14 #include "tools/gn/loader.h" | 15 #include "tools/gn/loader.h" |
| 15 #include "tools/gn/parse_tree.h" | 16 #include "tools/gn/parse_tree.h" |
| 16 #include "tools/gn/parser.h" | 17 #include "tools/gn/parser.h" |
| 17 #include "tools/gn/scheduler.h" | 18 #include "tools/gn/scheduler.h" |
| 18 #include "tools/gn/tokenizer.h" | 19 #include "tools/gn/tokenizer.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 loader->set_async_load_file(mock_ifm_.GetCallback()); | 140 loader->set_async_load_file(mock_ifm_.GetCallback()); |
| 140 | 141 |
| 141 // Request the root build file be loaded. This should kick off the default | 142 // Request the root build file be loaded. This should kick off the default |
| 142 // build config loading. | 143 // build config loading. |
| 143 SourceFile root_build("//BUILD.gn"); | 144 SourceFile root_build("//BUILD.gn"); |
| 144 loader->Load(root_build, LocationRange(), Label()); | 145 loader->Load(root_build, LocationRange(), Label()); |
| 145 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); | 146 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); |
| 146 | 147 |
| 147 // Completing the build config load should kick off the root build file load. | 148 // Completing the build config load should kick off the root build file load. |
| 148 mock_ifm_.IssueAllPending(); | 149 mock_ifm_.IssueAllPending(); |
| 149 scheduler_.main_loop()->RunUntilIdle(); | 150 base::RunLoop().RunUntilIdle(); |
|
Nico
2016/06/22 18:22:28
(this replacement looks like it makes things more
fdoray
2016/06/22 18:41:50
Ironically, a goal of base::RunLoop is to make thi
| |
| 150 EXPECT_TRUE(mock_ifm_.HasOnePending(root_build)); | 151 EXPECT_TRUE(mock_ifm_.HasOnePending(root_build)); |
| 151 | 152 |
| 152 // Load the root build file. | 153 // Load the root build file. |
| 153 mock_ifm_.IssueAllPending(); | 154 mock_ifm_.IssueAllPending(); |
| 154 scheduler_.main_loop()->RunUntilIdle(); | 155 base::RunLoop().RunUntilIdle(); |
| 155 | 156 |
| 156 // Schedule some other file to load in another toolchain. | 157 // Schedule some other file to load in another toolchain. |
| 157 Label second_tc(SourceDir("//tc2/"), "tc2"); | 158 Label second_tc(SourceDir("//tc2/"), "tc2"); |
| 158 SourceFile second_file("//foo/BUILD.gn"); | 159 SourceFile second_file("//foo/BUILD.gn"); |
| 159 loader->Load(second_file, LocationRange(), second_tc); | 160 loader->Load(second_file, LocationRange(), second_tc); |
| 160 EXPECT_TRUE(mock_ifm_.HasOnePending(SourceFile("//tc2/BUILD.gn"))); | 161 EXPECT_TRUE(mock_ifm_.HasOnePending(SourceFile("//tc2/BUILD.gn"))); |
| 161 | 162 |
| 162 // Running the toolchain file should schedule the build config file to load | 163 // Running the toolchain file should schedule the build config file to load |
| 163 // for that toolchain. | 164 // for that toolchain. |
| 164 mock_ifm_.IssueAllPending(); | 165 mock_ifm_.IssueAllPending(); |
| 165 scheduler_.main_loop()->RunUntilIdle(); | 166 base::RunLoop().RunUntilIdle(); |
| 166 | 167 |
| 167 // We have to tell it we have a toolchain definition now (normally the | 168 // We have to tell it we have a toolchain definition now (normally the |
| 168 // builder would do this). | 169 // builder would do this). |
| 169 const Settings* default_settings = loader->GetToolchainSettings(Label()); | 170 const Settings* default_settings = loader->GetToolchainSettings(Label()); |
| 170 Toolchain second_tc_object(default_settings, second_tc); | 171 Toolchain second_tc_object(default_settings, second_tc); |
| 171 loader->ToolchainLoaded(&second_tc_object); | 172 loader->ToolchainLoaded(&second_tc_object); |
| 172 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); | 173 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); |
| 173 | 174 |
| 174 // Scheduling a second file to load in that toolchain should not make it | 175 // Scheduling a second file to load in that toolchain should not make it |
| 175 // pending yet (it's waiting for the build config). | 176 // pending yet (it's waiting for the build config). |
| 176 SourceFile third_file("//bar/BUILD.gn"); | 177 SourceFile third_file("//bar/BUILD.gn"); |
| 177 loader->Load(third_file, LocationRange(), second_tc); | 178 loader->Load(third_file, LocationRange(), second_tc); |
| 178 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); | 179 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); |
| 179 | 180 |
| 180 // Running the build config file should make our third file pending. | 181 // Running the build config file should make our third file pending. |
| 181 mock_ifm_.IssueAllPending(); | 182 mock_ifm_.IssueAllPending(); |
| 182 scheduler_.main_loop()->RunUntilIdle(); | 183 base::RunLoop().RunUntilIdle(); |
| 183 EXPECT_TRUE(mock_ifm_.HasTwoPending(second_file, third_file)); | 184 EXPECT_TRUE(mock_ifm_.HasTwoPending(second_file, third_file)); |
| 184 | 185 |
| 185 EXPECT_FALSE(scheduler_.is_failed()); | 186 EXPECT_FALSE(scheduler_.is_failed()); |
| 186 } | 187 } |
| OLD | NEW |