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

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

Issue 440333002: Support more configurability in GN toolchains (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unsigned check Created 6 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/ninja_copy_target_writer.cc ('k') | tools/gn/ninja_group_target_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_copy_target_writer.h" 9 #include "tools/gn/ninja_copy_target_writer.h"
10 #include "tools/gn/target.h"
10 #include "tools/gn/test_with_scope.h" 11 #include "tools/gn/test_with_scope.h"
11 12
12 // Tests mutliple files with an output pattern and no toolchain dependency. 13 // Tests mutliple files with an output pattern and no toolchain dependency.
13 TEST(NinjaCopyTargetWriter, Run) { 14 TEST(NinjaCopyTargetWriter, Run) {
14 TestWithScope setup; 15 TestWithScope setup;
16
15 setup.settings()->set_target_os(Settings::LINUX); 17 setup.settings()->set_target_os(Settings::LINUX);
16 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); 18 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
17 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); 19 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
18 target.set_output_type(Target::COPY_FILES); 20 target.set_output_type(Target::COPY_FILES);
19 21
20 target.sources().push_back(SourceFile("//foo/input1.txt")); 22 target.sources().push_back(SourceFile("//foo/input1.txt"));
21 target.sources().push_back(SourceFile("//foo/input2.txt")); 23 target.sources().push_back(SourceFile("//foo/input2.txt"));
22 24
23 target.action_values().outputs() = 25 target.action_values().outputs() =
24 SubstitutionList::MakeForTest("//out/Debug/{{source_name_part}}.out"); 26 SubstitutionList::MakeForTest("//out/Debug/{{source_name_part}}.out");
25 27
28 target.SetToolchain(setup.toolchain());
29 target.OnResolved();
30
26 std::ostringstream out; 31 std::ostringstream out;
27 NinjaCopyTargetWriter writer(&target, setup.toolchain(), out); 32 NinjaCopyTargetWriter writer(&target, out);
28 writer.Run(); 33 writer.Run();
29 34
30 const char expected_linux[] = 35 const char expected_linux[] =
31 "build input1.out: copy ../../foo/input1.txt\n" 36 "build input1.out: copy ../../foo/input1.txt\n"
32 "build input2.out: copy ../../foo/input2.txt\n" 37 "build input2.out: copy ../../foo/input2.txt\n"
33 "\n" 38 "\n"
34 "build obj/foo/bar.stamp: stamp input1.out input2.out\n"; 39 "build obj/foo/bar.stamp: stamp input1.out input2.out\n";
35 std::string out_str = out.str(); 40 std::string out_str = out.str();
36 EXPECT_EQ(expected_linux, out_str); 41 EXPECT_EQ(expected_linux, out_str);
37 } 42 }
38 43
39 // Tests a single file with no output pattern. 44 // Tests a single file with no output pattern.
40 TEST(NinjaCopyTargetWriter, ToolchainDeps) { 45 TEST(NinjaCopyTargetWriter, ToolchainDeps) {
41 TestWithScope setup; 46 TestWithScope setup;
47
42 setup.settings()->set_target_os(Settings::LINUX); 48 setup.settings()->set_target_os(Settings::LINUX);
43 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); 49 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
44 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); 50 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
45 target.set_output_type(Target::COPY_FILES); 51 target.set_output_type(Target::COPY_FILES);
46 52
47 target.sources().push_back(SourceFile("//foo/input1.txt")); 53 target.sources().push_back(SourceFile("//foo/input1.txt"));
48 54
49 target.action_values().outputs() = 55 target.action_values().outputs() =
50 SubstitutionList::MakeForTest("//out/Debug/output.out"); 56 SubstitutionList::MakeForTest("//out/Debug/output.out");
51 57
58 target.SetToolchain(setup.toolchain());
59 target.OnResolved();
60
52 std::ostringstream out; 61 std::ostringstream out;
53 NinjaCopyTargetWriter writer(&target, setup.toolchain(), out); 62 NinjaCopyTargetWriter writer(&target, out);
54 writer.Run(); 63 writer.Run();
55 64
56 const char expected_linux[] = 65 const char expected_linux[] =
57 "build output.out: copy ../../foo/input1.txt\n" 66 "build output.out: copy ../../foo/input1.txt\n"
58 "\n" 67 "\n"
59 "build obj/foo/bar.stamp: stamp output.out\n"; 68 "build obj/foo/bar.stamp: stamp output.out\n";
60 std::string out_str = out.str(); 69 std::string out_str = out.str();
61 EXPECT_EQ(expected_linux, out_str); 70 EXPECT_EQ(expected_linux, out_str);
62 } 71 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_copy_target_writer.cc ('k') | tools/gn/ninja_group_target_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698