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

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

Issue 1544333002: Convert Pass()→std::move() in //tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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/loader_unittest.cc ('k') | tools/gn/operators_unittest.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"
6
5 #include <sstream> 7 #include <sstream>
8 #include <utility>
6 9
7 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
8 #include "tools/gn/ninja_binary_target_writer.h"
9 #include "tools/gn/scheduler.h" 11 #include "tools/gn/scheduler.h"
10 #include "tools/gn/target.h" 12 #include "tools/gn/target.h"
11 #include "tools/gn/test_with_scope.h" 13 #include "tools/gn/test_with_scope.h"
12 14
13 TEST(NinjaBinaryTargetWriter, SourceSet) { 15 TEST(NinjaBinaryTargetWriter, SourceSet) {
14 TestWithScope setup; 16 TestWithScope setup;
15 Err err; 17 Err err;
16 18
17 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); 19 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
18 20
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 480
479 // Declare a C++ compiler that supports PCH. 481 // Declare a C++ compiler that supports PCH.
480 scoped_ptr<Tool> cxx_tool(new Tool); 482 scoped_ptr<Tool> cxx_tool(new Tool);
481 TestWithScope::SetCommandForTool( 483 TestWithScope::SetCommandForTool(
482 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} " 484 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} "
483 "-o {{output}}", 485 "-o {{output}}",
484 cxx_tool.get()); 486 cxx_tool.get());
485 cxx_tool->set_outputs(SubstitutionList::MakeForTest( 487 cxx_tool->set_outputs(SubstitutionList::MakeForTest(
486 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 488 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
487 cxx_tool->set_precompiled_header_type(Tool::PCH_MSVC); 489 cxx_tool->set_precompiled_header_type(Tool::PCH_MSVC);
488 pch_toolchain.SetTool(Toolchain::TYPE_CXX, cxx_tool.Pass()); 490 pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool));
489 491
490 // Add a C compiler as well. 492 // Add a C compiler as well.
491 scoped_ptr<Tool> cc_tool(new Tool); 493 scoped_ptr<Tool> cc_tool(new Tool);
492 TestWithScope::SetCommandForTool( 494 TestWithScope::SetCommandForTool(
493 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " 495 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} "
494 "-o {{output}}", 496 "-o {{output}}",
495 cc_tool.get()); 497 cc_tool.get());
496 cc_tool->set_outputs(SubstitutionList::MakeForTest( 498 cc_tool->set_outputs(SubstitutionList::MakeForTest(
497 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 499 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
498 cc_tool->set_precompiled_header_type(Tool::PCH_MSVC); 500 cc_tool->set_precompiled_header_type(Tool::PCH_MSVC);
499 pch_toolchain.SetTool(Toolchain::TYPE_CC, cc_tool.Pass()); 501 pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool));
500 pch_toolchain.ToolchainSetupComplete(); 502 pch_toolchain.ToolchainSetupComplete();
501 503
502 // This target doesn't specify precompiled headers. 504 // This target doesn't specify precompiled headers.
503 { 505 {
504 Target no_pch_target(&pch_settings, 506 Target no_pch_target(&pch_settings,
505 Label(SourceDir("//foo/"), "no_pch_target")); 507 Label(SourceDir("//foo/"), "no_pch_target"));
506 no_pch_target.set_output_type(Target::SOURCE_SET); 508 no_pch_target.set_output_type(Target::SOURCE_SET);
507 no_pch_target.visibility().SetPublic(); 509 no_pch_target.visibility().SetPublic();
508 no_pch_target.sources().push_back(SourceFile("//foo/input1.cc")); 510 no_pch_target.sources().push_back(SourceFile("//foo/input1.cc"));
509 no_pch_target.sources().push_back(SourceFile("//foo/input2.c")); 511 no_pch_target.sources().push_back(SourceFile("//foo/input2.c"));
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 608
607 // Declare a C++ compiler that supports PCH. 609 // Declare a C++ compiler that supports PCH.
608 scoped_ptr<Tool> cxx_tool(new Tool); 610 scoped_ptr<Tool> cxx_tool(new Tool);
609 TestWithScope::SetCommandForTool( 611 TestWithScope::SetCommandForTool(
610 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} " 612 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} "
611 "-o {{output}}", 613 "-o {{output}}",
612 cxx_tool.get()); 614 cxx_tool.get());
613 cxx_tool->set_outputs(SubstitutionList::MakeForTest( 615 cxx_tool->set_outputs(SubstitutionList::MakeForTest(
614 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 616 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
615 cxx_tool->set_precompiled_header_type(Tool::PCH_GCC); 617 cxx_tool->set_precompiled_header_type(Tool::PCH_GCC);
616 pch_toolchain.SetTool(Toolchain::TYPE_CXX, cxx_tool.Pass()); 618 pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool));
617 pch_toolchain.ToolchainSetupComplete(); 619 pch_toolchain.ToolchainSetupComplete();
618 620
619 // Add a C compiler as well. 621 // Add a C compiler as well.
620 scoped_ptr<Tool> cc_tool(new Tool); 622 scoped_ptr<Tool> cc_tool(new Tool);
621 TestWithScope::SetCommandForTool( 623 TestWithScope::SetCommandForTool(
622 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " 624 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} "
623 "-o {{output}}", 625 "-o {{output}}",
624 cc_tool.get()); 626 cc_tool.get());
625 cc_tool->set_outputs(SubstitutionList::MakeForTest( 627 cc_tool->set_outputs(SubstitutionList::MakeForTest(
626 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 628 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
627 cc_tool->set_precompiled_header_type(Tool::PCH_GCC); 629 cc_tool->set_precompiled_header_type(Tool::PCH_GCC);
628 pch_toolchain.SetTool(Toolchain::TYPE_CC, cc_tool.Pass()); 630 pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool));
629 pch_toolchain.ToolchainSetupComplete(); 631 pch_toolchain.ToolchainSetupComplete();
630 632
631 // This target doesn't specify precompiled headers. 633 // This target doesn't specify precompiled headers.
632 { 634 {
633 Target no_pch_target(&pch_settings, 635 Target no_pch_target(&pch_settings,
634 Label(SourceDir("//foo/"), "no_pch_target")); 636 Label(SourceDir("//foo/"), "no_pch_target"));
635 no_pch_target.set_output_type(Target::SOURCE_SET); 637 no_pch_target.set_output_type(Target::SOURCE_SET);
636 no_pch_target.visibility().SetPublic(); 638 no_pch_target.visibility().SetPublic();
637 no_pch_target.sources().push_back(SourceFile("//foo/input1.cc")); 639 no_pch_target.sources().push_back(SourceFile("//foo/input1.cc"));
638 no_pch_target.sources().push_back(SourceFile("//foo/input2.c")); 640 no_pch_target.sources().push_back(SourceFile("//foo/input2.c"));
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 730
729 EXPECT_FALSE(scheduler.is_failed()); 731 EXPECT_FALSE(scheduler.is_failed());
730 732
731 std::ostringstream out; 733 std::ostringstream out;
732 NinjaBinaryTargetWriter writer(&target, out); 734 NinjaBinaryTargetWriter writer(&target, out);
733 writer.Run(); 735 writer.Run();
734 736
735 // Should have issued an error. 737 // Should have issued an error.
736 EXPECT_TRUE(scheduler.is_failed()); 738 EXPECT_TRUE(scheduler.is_failed());
737 } 739 }
OLDNEW
« no previous file with comments | « tools/gn/loader_unittest.cc ('k') | tools/gn/operators_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698