Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: tools/gn/ninja_action_target_writer_unittest.cc

Issue 1431323003: Remove obsolete OS handling in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/gn/ninja_action_target_writer.h" 9 #include "tools/gn/ninja_action_target_writer.h"
10 #include "tools/gn/substitution_list.h" 10 #include "tools/gn/substitution_list.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 target.action_values().set_script(SourceFile("//foo/script.py")); 48 target.action_values().set_script(SourceFile("//foo/script.py"));
49 target.inputs().push_back(SourceFile("//foo/included.txt")); 49 target.inputs().push_back(SourceFile("//foo/included.txt"));
50 50
51 target.action_values().outputs() = 51 target.action_values().outputs() =
52 SubstitutionList::MakeForTest("//out/Debug/foo.out"); 52 SubstitutionList::MakeForTest("//out/Debug/foo.out");
53 53
54 target.SetToolchain(setup.toolchain()); 54 target.SetToolchain(setup.toolchain());
55 ASSERT_TRUE(target.OnResolved(&err)); 55 ASSERT_TRUE(target.OnResolved(&err));
56 56
57 setup.settings()->set_target_os(Settings::LINUX);
58 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL( 57 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL(
59 "/usr/bin/python"))); 58 "/usr/bin/python")));
60 59
61 std::ostringstream out; 60 std::ostringstream out;
62 NinjaActionTargetWriter writer(&target, out); 61 NinjaActionTargetWriter writer(&target, out);
63 writer.Run(); 62 writer.Run();
64 63
65 const char expected[] = 64 const char expected[] =
66 "rule __foo_bar___rule\n" 65 "rule __foo_bar___rule\n"
67 " command = /usr/bin/python ../../foo/script.py\n" 66 " command = /usr/bin/python ../../foo/script.py\n"
(...skipping 21 matching lines...) Expand all
89 target.action_values().set_script(SourceFile("//foo/script.py")); 88 target.action_values().set_script(SourceFile("//foo/script.py"));
90 target.inputs().push_back(SourceFile("//foo/included.txt")); 89 target.inputs().push_back(SourceFile("//foo/included.txt"));
91 90
92 target.action_values().outputs() = 91 target.action_values().outputs() =
93 SubstitutionList::MakeForTest("//out/Debug/foo.out"); 92 SubstitutionList::MakeForTest("//out/Debug/foo.out");
94 target.action_values().set_console(true); 93 target.action_values().set_console(true);
95 94
96 target.SetToolchain(setup.toolchain()); 95 target.SetToolchain(setup.toolchain());
97 ASSERT_TRUE(target.OnResolved(&err)); 96 ASSERT_TRUE(target.OnResolved(&err));
98 97
99 setup.settings()->set_target_os(Settings::LINUX);
100 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL( 98 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL(
101 "/usr/bin/python"))); 99 "/usr/bin/python")));
102 100
103 std::ostringstream out; 101 std::ostringstream out;
104 NinjaActionTargetWriter writer(&target, out); 102 NinjaActionTargetWriter writer(&target, out);
105 writer.Run(); 103 writer.Run();
106 104
107 const char expected[] = 105 const char expected[] =
108 "rule __foo_bar___rule\n" 106 "rule __foo_bar___rule\n"
109 " command = /usr/bin/python ../../foo/script.py\n" 107 " command = /usr/bin/python ../../foo/script.py\n"
(...skipping 23 matching lines...) Expand all
133 131
134 target.sources().push_back(SourceFile("//foo/source.txt")); 132 target.sources().push_back(SourceFile("//foo/source.txt"));
135 target.inputs().push_back(SourceFile("//foo/included.txt")); 133 target.inputs().push_back(SourceFile("//foo/included.txt"));
136 134
137 target.action_values().outputs() = 135 target.action_values().outputs() =
138 SubstitutionList::MakeForTest("//out/Debug/foo.out"); 136 SubstitutionList::MakeForTest("//out/Debug/foo.out");
139 137
140 target.SetToolchain(setup.toolchain()); 138 target.SetToolchain(setup.toolchain());
141 ASSERT_TRUE(target.OnResolved(&err)); 139 ASSERT_TRUE(target.OnResolved(&err));
142 140
143 setup.settings()->set_target_os(Settings::LINUX);
144 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL( 141 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL(
145 "/usr/bin/python"))); 142 "/usr/bin/python")));
146 143
147 std::ostringstream out; 144 std::ostringstream out;
148 NinjaActionTargetWriter writer(&target, out); 145 NinjaActionTargetWriter writer(&target, out);
149 writer.Run(); 146 writer.Run();
150 147
151 const char expected_linux[] = 148 const char expected_linux[] =
152 "rule __foo_bar___rule\n" 149 "rule __foo_bar___rule\n"
153 " command = /usr/bin/python ../../foo/script.py\n" 150 " command = /usr/bin/python ../../foo/script.py\n"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 "{{source}}", 196 "{{source}}",
200 "--out=foo bar{{source_name_part}}.o"); 197 "--out=foo bar{{source_name_part}}.o");
201 target.action_values().outputs() = SubstitutionList::MakeForTest( 198 target.action_values().outputs() = SubstitutionList::MakeForTest(
202 "//out/Debug/{{source_name_part}}.out"); 199 "//out/Debug/{{source_name_part}}.out");
203 200
204 target.inputs().push_back(SourceFile("//foo/included.txt")); 201 target.inputs().push_back(SourceFile("//foo/included.txt"));
205 202
206 target.SetToolchain(setup.toolchain()); 203 target.SetToolchain(setup.toolchain());
207 ASSERT_TRUE(target.OnResolved(&err)); 204 ASSERT_TRUE(target.OnResolved(&err));
208 205
209 setup.settings()->set_target_os(Settings::LINUX);
210 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL( 206 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL(
211 "/usr/bin/python"))); 207 "/usr/bin/python")));
212 208
213 std::ostringstream out; 209 std::ostringstream out;
214 NinjaActionTargetWriter writer(&target, out); 210 NinjaActionTargetWriter writer(&target, out);
215 writer.Run(); 211 writer.Run();
216 212
217 const char expected_linux[] = 213 const char expected_linux[] =
218 "rule __foo_bar___rule\n" 214 "rule __foo_bar___rule\n"
219 " command = /usr/bin/python ../../foo/script.py -i ${in} " 215 " command = /usr/bin/python ../../foo/script.py -i ${in} "
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 264
269 target.action_values().args() = SubstitutionList::MakeForTest( 265 target.action_values().args() = SubstitutionList::MakeForTest(
270 "-i", 266 "-i",
271 "{{source}}", 267 "{{source}}",
272 "--out=foo bar{{source_name_part}}.o"); 268 "--out=foo bar{{source_name_part}}.o");
273 target.action_values().outputs() = SubstitutionList::MakeForTest( 269 target.action_values().outputs() = SubstitutionList::MakeForTest(
274 "//out/Debug/{{source_name_part}}.out"); 270 "//out/Debug/{{source_name_part}}.out");
275 271
276 target.inputs().push_back(SourceFile("//foo/included.txt")); 272 target.inputs().push_back(SourceFile("//foo/included.txt"));
277 273
278 setup.settings()->set_target_os(Settings::LINUX);
279 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL( 274 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL(
280 "/usr/bin/python"))); 275 "/usr/bin/python")));
281 276
282 std::ostringstream out; 277 std::ostringstream out;
283 NinjaActionTargetWriter writer(&target, out); 278 NinjaActionTargetWriter writer(&target, out);
284 writer.Run(); 279 writer.Run();
285 280
286 const char expected_linux[] = 281 const char expected_linux[] =
287 "rule __foo_bar___rule\n" 282 "rule __foo_bar___rule\n"
288 " command = /usr/bin/python ../../foo/script.py -i ${in} " 283 " command = /usr/bin/python ../../foo/script.py -i ${in} "
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 target.action_values().args() = SubstitutionList::MakeForTest( 323 target.action_values().args() = SubstitutionList::MakeForTest(
329 "{{source}}", 324 "{{source}}",
330 "{{source_file_part}}", 325 "{{source_file_part}}",
331 "{{response_file_name}}"); 326 "{{response_file_name}}");
332 target.action_values().rsp_file_contents() = SubstitutionList::MakeForTest( 327 target.action_values().rsp_file_contents() = SubstitutionList::MakeForTest(
333 "-j", 328 "-j",
334 "{{source_name_part}}"); 329 "{{source_name_part}}");
335 target.action_values().outputs() = SubstitutionList::MakeForTest( 330 target.action_values().outputs() = SubstitutionList::MakeForTest(
336 "//out/Debug/{{source_name_part}}.out"); 331 "//out/Debug/{{source_name_part}}.out");
337 332
338 setup.settings()->set_target_os(Settings::LINUX);
339 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL( 333 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL(
340 "/usr/bin/python"))); 334 "/usr/bin/python")));
341 335
342 std::ostringstream out; 336 std::ostringstream out;
343 NinjaActionTargetWriter writer(&target, out); 337 NinjaActionTargetWriter writer(&target, out);
344 writer.Run(); 338 writer.Run();
345 339
346 const char expected_linux[] = 340 const char expected_linux[] =
347 "rule __foo_bar___rule\n" 341 "rule __foo_bar___rule\n"
348 // This name is autogenerated from the target rule name. 342 // This name is autogenerated from the target rule name.
(...skipping 12 matching lines...) Expand all
361 // Necessary for the rspfile defined in the rule. 355 // Necessary for the rspfile defined in the rule.
362 " unique_name = 0\n" 356 " unique_name = 0\n"
363 // Substitution for the args. 357 // Substitution for the args.
364 " source_file_part = input1.txt\n" 358 " source_file_part = input1.txt\n"
365 // Substitution for the rspfile contents. 359 // Substitution for the rspfile contents.
366 " source_name_part = input1\n" 360 " source_name_part = input1\n"
367 "\n" 361 "\n"
368 "build obj/foo/bar.stamp: stamp input1.out\n"; 362 "build obj/foo/bar.stamp: stamp input1.out\n";
369 EXPECT_EQ(expected_linux, out.str()); 363 EXPECT_EQ(expected_linux, out.str());
370 } 364 }
OLDNEW
« no previous file with comments | « tools/gn/function_get_target_outputs_unittest.cc ('k') | tools/gn/ninja_binary_target_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698