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

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

Issue 1892393002: 🐜 GN: Make write_runtime_deps take effect only a target is resolved (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test 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/BUILD.gn ('k') | tools/gn/runtime_deps_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/group_target_generator.h"
7 #include "tools/gn/scheduler.h"
8 #include "tools/gn/test_with_scope.h"
9
10 namespace {
11
12 // Returns true on success, false if write_file signaled an error.
13 bool ParseWriteRuntimeDeps(Scope* scope, const std::string& value) {
14 TestParseInput input(
15 "group(\"foo\") { write_runtime_deps = " + value + "}");
16 if (input.has_error())
17 return false;
18
19 Err err;
20 input.parsed()->Execute(scope, &err);
21 return !err.has_error();
22 }
23
24 } // namespace
25
26
27 // Tests that actions can't have output substitutions.
28 TEST(GroupTargetGenerator, WriteRuntimeDeps) {
29 Scheduler scheduler;
30 TestWithScope setup;
31 Scope::ItemVector items_;
32 setup.scope()->set_item_collector(&items_);
33
34 // Should refuse to write files outside of the output dir.
35 EXPECT_FALSE(ParseWriteRuntimeDeps(setup.scope(), "\"//foo.txt\""));
36 EXPECT_EQ(0U, scheduler.GetWriteRuntimeDepsTargets().size());
37
38 // Should fail for garbage inputs.
39 EXPECT_FALSE(ParseWriteRuntimeDeps(setup.scope(), "0"));
40 EXPECT_EQ(0U, scheduler.GetWriteRuntimeDepsTargets().size());
41
42 // Should be able to write inside the out dir.
43 EXPECT_TRUE(ParseWriteRuntimeDeps(setup.scope(), "\"//out/Debug/foo.txt\""));
44 EXPECT_EQ(1U, scheduler.GetWriteRuntimeDepsTargets().size());
45 }
46
OLDNEW
« no previous file with comments | « tools/gn/BUILD.gn ('k') | tools/gn/runtime_deps_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698