Landing Recent QUIC changes until 8/19/2015 17:00 UTC.
[chromium-blink-merge.git] / tools / gn / action_target_generator_unittest.cc
blob8f3e4d4c3327755c146fa3d1dc54c5877d3f56e8
1 // Copyright 2014 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.
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/scheduler.h"
7 #include "tools/gn/test_with_scope.h"
9 // Tests that actions can't have output substitutions.
10 TEST(ActionTargetGenerator, ActionOutputSubstitutions) {
11 Scheduler scheduler;
12 TestWithScope setup;
13 Scope::ItemVector items_;
14 setup.scope()->set_item_collector(&items_);
16 // First test one with no substitutions, this should be valid.
17 TestParseInput input_good(
18 "action(\"foo\") {\n"
19 " script = \"//foo.py\"\n"
20 " sources = [ \"//bar.txt\" ]\n"
21 " outputs = [ \"//out/Debug/one.txt\" ]\n"
22 "}");
23 ASSERT_FALSE(input_good.has_error());
25 // This should run fine.
26 Err err;
27 input_good.parsed()->Execute(setup.scope(), &err);
28 ASSERT_FALSE(err.has_error()) << err.message();
30 // Same thing with a pattern in the output should fail.
31 TestParseInput input_bad(
32 "action(\"foo\") {\n"
33 " script = \"//foo.py\"\n"
34 " sources = [ \"//bar.txt\" ]\n"
35 " outputs = [ \"//out/Debug/{{source_name_part}}.txt\" ]\n"
36 "}");
37 ASSERT_FALSE(input_bad.has_error());
39 // This should run fine.
40 input_bad.parsed()->Execute(setup.scope(), &err);
41 ASSERT_TRUE(err.has_error());