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
) {
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(
19 " script = \"//foo.py\"\n"
20 " sources = [ \"//bar.txt\" ]\n"
21 " outputs = [ \"//out/Debug/one.txt\" ]\n"
23 ASSERT_FALSE(input_good
.has_error());
25 // This should run fine.
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(
33 " script = \"//foo.py\"\n"
34 " sources = [ \"//bar.txt\" ]\n"
35 " outputs = [ \"//out/Debug/{{source_name_part}}.txt\" ]\n"
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());