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

Unified Diff: tools/gn/group_target_generator_unittest.cc

Issue 1804303004: 🚙 GN: Add write_runtime_deps variable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove {}s Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/BUILD.gn ('k') | tools/gn/runtime_deps.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/group_target_generator_unittest.cc
diff --git a/tools/gn/group_target_generator_unittest.cc b/tools/gn/group_target_generator_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3b0c82443680e7a6136a3089767791bcce67ffed
--- /dev/null
+++ b/tools/gn/group_target_generator_unittest.cc
@@ -0,0 +1,46 @@
+// Copyright 2016 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/group_target_generator.h"
+#include "tools/gn/scheduler.h"
+#include "tools/gn/test_with_scope.h"
+
+namespace {
+
+// Returns true on success, false if write_file signaled an error.
+bool ParseWriteRuntimeDeps(Scope* scope, const std::string& value) {
+ TestParseInput input(
+ "group(\"foo\") { write_runtime_deps = " + value + "}");
+ if (input.has_error())
+ return false;
+
+ Err err;
+ input.parsed()->Execute(scope, &err);
+ return !err.has_error();
+}
+
+} // namespace
+
+
+// Tests that actions can't have output substitutions.
+TEST(GroupTargetGenerator, WriteRuntimeDeps) {
+ Scheduler scheduler;
+ TestWithScope setup;
+ Scope::ItemVector items_;
+ setup.scope()->set_item_collector(&items_);
+
+ // Should refuse to write files outside of the output dir.
+ EXPECT_FALSE(ParseWriteRuntimeDeps(setup.scope(), "\"//foo.txt\""));
+ EXPECT_EQ(0U, scheduler.GetWriteRuntimeDepsTargets().size());
+
+ // Should fail for garbage inputs.
+ EXPECT_FALSE(ParseWriteRuntimeDeps(setup.scope(), "0"));
+ EXPECT_EQ(0U, scheduler.GetWriteRuntimeDepsTargets().size());
+
+ // Should be able to write inside the out dir.
+ EXPECT_TRUE(ParseWriteRuntimeDeps(setup.scope(), "\"//out/Debug/foo.txt\""));
+ EXPECT_EQ(1U, scheduler.GetWriteRuntimeDepsTargets().size());
+}
+
« no previous file with comments | « tools/gn/BUILD.gn ('k') | tools/gn/runtime_deps.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698