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

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

Issue 1911873002: Store BundleData paths as SourceDirs rather than strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-phony-bundle-target
Patch Set: Created 4 years, 8 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
« no previous file with comments | « tools/gn/create_bundle_target_generator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "tools/gn/ninja_create_bundle_target_writer.h" 5 #include "tools/gn/ninja_create_bundle_target_writer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "tools/gn/target.h" 11 #include "tools/gn/target.h"
12 #include "tools/gn/test_with_scope.h" 12 #include "tools/gn/test_with_scope.h"
13 13
14 namespace { 14 namespace {
15 15
16 void SetupBundleDataDir(BundleData* bundle_data, const std::string& root_dir) { 16 void SetupBundleDataDir(BundleData* bundle_data, const std::string& root_dir) {
17 bundle_data->root_dir().assign(root_dir + "/bar.bundle"); 17 std::string bundle_root_dir = root_dir + "/bar.bundle";
18 bundle_data->resources_dir().assign(bundle_data->root_dir() + "/Resources"); 18 bundle_data->root_dir() = SourceDir(bundle_root_dir);
19 bundle_data->executable_dir().assign(bundle_data->root_dir() + "/Executable"); 19 bundle_data->resources_dir() = SourceDir(bundle_root_dir + "/Resources");
20 bundle_data->plugins_dir().assign(bundle_data->root_dir() + "/PlugIns"); 20 bundle_data->executable_dir() = SourceDir(bundle_root_dir + "/Executable");
21 bundle_data->plugins_dir() = SourceDir(bundle_root_dir + "/PlugIns");
21 } 22 }
22 23
23 } // namespace 24 } // namespace
24 25
25 // Tests multiple files with an output pattern. 26 // Tests multiple files with an output pattern.
26 TEST(NinjaCreateBundleTargetWriter, Run) { 27 TEST(NinjaCreateBundleTargetWriter, Run) {
27 TestWithScope setup; 28 TestWithScope setup;
28 Err err; 29 Err err;
29 30
30 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); 31 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // correctly. 109 // correctly.
109 TEST(NinjaCreateBundleTargetWriter, BundleRootDirOutput) { 110 TEST(NinjaCreateBundleTargetWriter, BundleRootDirOutput) {
110 TestWithScope setup; 111 TestWithScope setup;
111 Err err; 112 Err err;
112 113
113 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); 114 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
114 Target target(setup.settings(), Label(SourceDir("//baz/"), "bar")); 115 Target target(setup.settings(), Label(SourceDir("//baz/"), "bar"));
115 target.set_output_type(Target::CREATE_BUNDLE); 116 target.set_output_type(Target::CREATE_BUNDLE);
116 117
117 const std::string bundle_root_dir("//out/Debug/bar.bundle/Contents"); 118 const std::string bundle_root_dir("//out/Debug/bar.bundle/Contents");
118 target.bundle_data().root_dir().assign(bundle_root_dir); 119 target.bundle_data().root_dir() = SourceDir(bundle_root_dir);
119 target.bundle_data().resources_dir().assign(bundle_root_dir + "/Resources"); 120 target.bundle_data().resources_dir() =
120 target.bundle_data().executable_dir().assign(bundle_root_dir + "/MacOS"); 121 SourceDir(bundle_root_dir + "/Resources");
121 target.bundle_data().plugins_dir().assign(bundle_root_dir + "/Plug Ins"); 122 target.bundle_data().executable_dir() = SourceDir(bundle_root_dir + "/MacOS");
123 target.bundle_data().plugins_dir() = SourceDir(bundle_root_dir + "/Plug Ins");
122 124
123 std::vector<SourceFile> sources; 125 std::vector<SourceFile> sources;
124 sources.push_back(SourceFile("//foo/input1.txt")); 126 sources.push_back(SourceFile("//foo/input1.txt"));
125 sources.push_back(SourceFile("//foo/input2.txt")); 127 sources.push_back(SourceFile("//foo/input2.txt"));
126 target.bundle_data().file_rules().push_back(BundleFileRule( 128 target.bundle_data().file_rules().push_back(BundleFileRule(
127 sources, SubstitutionPattern::MakeForTest( 129 sources, SubstitutionPattern::MakeForTest(
128 "{{bundle_resources_dir}}/{{source_file_part}}"))); 130 "{{bundle_resources_dir}}/{{source_file_part}}")));
129 131
130 target.SetToolchain(setup.toolchain()); 132 target.SetToolchain(setup.toolchain());
131 ASSERT_TRUE(target.OnResolved(&err)); 133 ASSERT_TRUE(target.OnResolved(&err));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 "\n" 213 "\n"
212 "build obj/baz/bar.stamp: stamp " 214 "build obj/baz/bar.stamp: stamp "
213 "bar.bundle/Resources/input1.txt " 215 "bar.bundle/Resources/input1.txt "
214 "bar.bundle/Resources/input2.txt " 216 "bar.bundle/Resources/input2.txt "
215 "bar.bundle/Info.plist " 217 "bar.bundle/Info.plist "
216 "bar.bundle/Resources/Assets.car\n" 218 "bar.bundle/Resources/Assets.car\n"
217 "build bar.bundle: phony obj/baz/bar.stamp\n"; 219 "build bar.bundle: phony obj/baz/bar.stamp\n";
218 std::string out_str = out.str(); 220 std::string out_str = out.str();
219 EXPECT_EQ(expected, out_str); 221 EXPECT_EQ(expected, out_str);
220 } 222 }
OLDNEW
« no previous file with comments | « tools/gn/create_bundle_target_generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698