OLD | NEW |
| (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 | |
OLD | NEW |