summaryrefslogtreecommitdiffstats
path: root/tools/gn/action_target_generator_unittest.cc
blob: 8f3e4d4c3327755c146fa3d1dc54c5877d3f56e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/scheduler.h"
#include "tools/gn/test_with_scope.h"

// Tests that actions can't have output substitutions.
TEST(ActionTargetGenerator, ActionOutputSubstitutions) {
  Scheduler scheduler;
  TestWithScope setup;
  Scope::ItemVector items_;
  setup.scope()->set_item_collector(&items_);

  // First test one with no substitutions, this should be valid.
  TestParseInput input_good(
      "action(\"foo\") {\n"
      "  script = \"//foo.py\"\n"
      "  sources = [ \"//bar.txt\" ]\n"
      "  outputs = [ \"//out/Debug/one.txt\" ]\n"
      "}");
  ASSERT_FALSE(input_good.has_error());

  // This should run fine.
  Err err;
  input_good.parsed()->Execute(setup.scope(), &err);
  ASSERT_FALSE(err.has_error()) << err.message();

  // Same thing with a pattern in the output should fail.
  TestParseInput input_bad(
      "action(\"foo\") {\n"
      "  script = \"//foo.py\"\n"
      "  sources = [ \"//bar.txt\" ]\n"
      "  outputs = [ \"//out/Debug/{{source_name_part}}.txt\" ]\n"
      "}");
  ASSERT_FALSE(input_bad.has_error());

  // This should run fine.
  input_bad.parsed()->Execute(setup.scope(), &err);
  ASSERT_TRUE(err.has_error());
}