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

Side by Side Diff: tools/gn/ninja_binary_target_writer_unittest.cc

Issue 2071573003: GN: Use implicit dependency for binary input deps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review changes Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « tools/gn/ninja_binary_target_writer.cc ('k') | tools/gn/ninja_target_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/ninja_binary_target_writer.h" 5 #include "tools/gn/ninja_binary_target_writer.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <utility> 8 #include <utility>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 847
848 EXPECT_FALSE(scheduler.is_failed()); 848 EXPECT_FALSE(scheduler.is_failed());
849 849
850 std::ostringstream out; 850 std::ostringstream out;
851 NinjaBinaryTargetWriter writer(&target, out); 851 NinjaBinaryTargetWriter writer(&target, out);
852 writer.Run(); 852 writer.Run();
853 853
854 // Should have issued an error. 854 // Should have issued an error.
855 EXPECT_TRUE(scheduler.is_failed()); 855 EXPECT_TRUE(scheduler.is_failed());
856 } 856 }
857
858 // This tests that output extension and output dir overrides apply, and input
859 // dependencies are applied.
860 TEST(NinjaBinaryTargetWriter, InputFiles) {
861 TestWithScope setup;
862 Err err;
863
864 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
865
866 // This target has one input.
867 {
868 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
869 target.set_output_type(Target::SOURCE_SET);
870 target.visibility().SetPublic();
871 target.sources().push_back(SourceFile("//foo/input1.cc"));
872 target.sources().push_back(SourceFile("//foo/input2.cc"));
873 target.inputs().push_back(SourceFile("//foo/input.data"));
874 target.SetToolchain(setup.toolchain());
875 ASSERT_TRUE(target.OnResolved(&err));
876
877 std::ostringstream out;
878 NinjaBinaryTargetWriter writer(&target, out);
879 writer.Run();
880
881 const char expected[] =
882 "defines =\n"
883 "include_dirs =\n"
884 "cflags =\n"
885 "cflags_cc =\n"
886 "root_out_dir = .\n"
887 "target_out_dir = obj/foo\n"
888 "target_output_name = bar\n"
889 "\n"
890 "build obj/foo/bar.input1.o: cxx ../../foo/input1.cc"
891 " | ../../foo/input.data\n"
892 "build obj/foo/bar.input2.o: cxx ../../foo/input2.cc"
893 " | ../../foo/input.data\n"
894 "\n"
895 "build obj/foo/bar.stamp: stamp obj/foo/bar.input1.o "
896 "obj/foo/bar.input2.o\n";
897
898 EXPECT_EQ(expected, out.str());
899 }
900
901 // This target has multiple inputs.
902 {
903 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
904 target.set_output_type(Target::SOURCE_SET);
905 target.visibility().SetPublic();
906 target.sources().push_back(SourceFile("//foo/input1.cc"));
907 target.sources().push_back(SourceFile("//foo/input2.cc"));
908 target.inputs().push_back(SourceFile("//foo/input1.data"));
909 target.inputs().push_back(SourceFile("//foo/input2.data"));
910 target.SetToolchain(setup.toolchain());
911 ASSERT_TRUE(target.OnResolved(&err));
912
913 std::ostringstream out;
914 NinjaBinaryTargetWriter writer(&target, out);
915 writer.Run();
916
917 const char expected[] =
918 "defines =\n"
919 "include_dirs =\n"
920 "cflags =\n"
921 "cflags_cc =\n"
922 "root_out_dir = .\n"
923 "target_out_dir = obj/foo\n"
924 "target_output_name = bar\n"
925 "\n"
926 "build obj/foo/bar.inputs.stamp: stamp"
927 " ../../foo/input1.data ../../foo/input2.data\n"
928 "build obj/foo/bar.input1.o: cxx ../../foo/input1.cc"
929 " | obj/foo/bar.inputs.stamp\n"
930 "build obj/foo/bar.input2.o: cxx ../../foo/input2.cc"
931 " | obj/foo/bar.inputs.stamp\n"
932 "\n"
933 "build obj/foo/bar.stamp: stamp obj/foo/bar.input1.o "
934 "obj/foo/bar.input2.o\n";
935
936 EXPECT_EQ(expected, out.str());
937 }
938 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_binary_target_writer.cc ('k') | tools/gn/ninja_target_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698