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

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

Issue 1869503004: Convert //tools to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 TestWithScope setup; 467 TestWithScope setup;
468 468
469 // A precompiled header toolchain. 469 // A precompiled header toolchain.
470 Settings pch_settings(setup.build_settings(), "withpch/"); 470 Settings pch_settings(setup.build_settings(), "withpch/");
471 Toolchain pch_toolchain(&pch_settings, 471 Toolchain pch_toolchain(&pch_settings,
472 Label(SourceDir("//toolchain/"), "withpch")); 472 Label(SourceDir("//toolchain/"), "withpch"));
473 pch_settings.set_toolchain_label(pch_toolchain.label()); 473 pch_settings.set_toolchain_label(pch_toolchain.label());
474 pch_settings.set_default_toolchain_label(setup.toolchain()->label()); 474 pch_settings.set_default_toolchain_label(setup.toolchain()->label());
475 475
476 // Declare a C++ compiler that supports PCH. 476 // Declare a C++ compiler that supports PCH.
477 scoped_ptr<Tool> cxx_tool(new Tool); 477 std::unique_ptr<Tool> cxx_tool(new Tool);
478 TestWithScope::SetCommandForTool( 478 TestWithScope::SetCommandForTool(
479 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} " 479 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} "
480 "-o {{output}}", 480 "-o {{output}}",
481 cxx_tool.get()); 481 cxx_tool.get());
482 cxx_tool->set_outputs(SubstitutionList::MakeForTest( 482 cxx_tool->set_outputs(SubstitutionList::MakeForTest(
483 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 483 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
484 cxx_tool->set_precompiled_header_type(Tool::PCH_MSVC); 484 cxx_tool->set_precompiled_header_type(Tool::PCH_MSVC);
485 pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool)); 485 pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool));
486 486
487 // Add a C compiler as well. 487 // Add a C compiler as well.
488 scoped_ptr<Tool> cc_tool(new Tool); 488 std::unique_ptr<Tool> cc_tool(new Tool);
489 TestWithScope::SetCommandForTool( 489 TestWithScope::SetCommandForTool(
490 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " 490 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} "
491 "-o {{output}}", 491 "-o {{output}}",
492 cc_tool.get()); 492 cc_tool.get());
493 cc_tool->set_outputs(SubstitutionList::MakeForTest( 493 cc_tool->set_outputs(SubstitutionList::MakeForTest(
494 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 494 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
495 cc_tool->set_precompiled_header_type(Tool::PCH_MSVC); 495 cc_tool->set_precompiled_header_type(Tool::PCH_MSVC);
496 pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool)); 496 pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool));
497 pch_toolchain.ToolchainSetupComplete(); 497 pch_toolchain.ToolchainSetupComplete();
498 498
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 TestWithScope setup; 595 TestWithScope setup;
596 596
597 // A precompiled header toolchain. 597 // A precompiled header toolchain.
598 Settings pch_settings(setup.build_settings(), "withpch/"); 598 Settings pch_settings(setup.build_settings(), "withpch/");
599 Toolchain pch_toolchain(&pch_settings, 599 Toolchain pch_toolchain(&pch_settings,
600 Label(SourceDir("//toolchain/"), "withpch")); 600 Label(SourceDir("//toolchain/"), "withpch"));
601 pch_settings.set_toolchain_label(pch_toolchain.label()); 601 pch_settings.set_toolchain_label(pch_toolchain.label());
602 pch_settings.set_default_toolchain_label(setup.toolchain()->label()); 602 pch_settings.set_default_toolchain_label(setup.toolchain()->label());
603 603
604 // Declare a C++ compiler that supports PCH. 604 // Declare a C++ compiler that supports PCH.
605 scoped_ptr<Tool> cxx_tool(new Tool); 605 std::unique_ptr<Tool> cxx_tool(new Tool);
606 TestWithScope::SetCommandForTool( 606 TestWithScope::SetCommandForTool(
607 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} " 607 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} "
608 "-o {{output}}", 608 "-o {{output}}",
609 cxx_tool.get()); 609 cxx_tool.get());
610 cxx_tool->set_outputs(SubstitutionList::MakeForTest( 610 cxx_tool->set_outputs(SubstitutionList::MakeForTest(
611 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 611 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
612 cxx_tool->set_precompiled_header_type(Tool::PCH_GCC); 612 cxx_tool->set_precompiled_header_type(Tool::PCH_GCC);
613 pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool)); 613 pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool));
614 pch_toolchain.ToolchainSetupComplete(); 614 pch_toolchain.ToolchainSetupComplete();
615 615
616 // Add a C compiler as well. 616 // Add a C compiler as well.
617 scoped_ptr<Tool> cc_tool(new Tool); 617 std::unique_ptr<Tool> cc_tool(new Tool);
618 TestWithScope::SetCommandForTool( 618 TestWithScope::SetCommandForTool(
619 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " 619 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} "
620 "-o {{output}}", 620 "-o {{output}}",
621 cc_tool.get()); 621 cc_tool.get());
622 cc_tool->set_outputs(SubstitutionList::MakeForTest( 622 cc_tool->set_outputs(SubstitutionList::MakeForTest(
623 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 623 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
624 cc_tool->set_precompiled_header_type(Tool::PCH_GCC); 624 cc_tool->set_precompiled_header_type(Tool::PCH_GCC);
625 pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool)); 625 pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool));
626 pch_toolchain.ToolchainSetupComplete(); 626 pch_toolchain.ToolchainSetupComplete();
627 627
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 725
726 EXPECT_FALSE(scheduler.is_failed()); 726 EXPECT_FALSE(scheduler.is_failed());
727 727
728 std::ostringstream out; 728 std::ostringstream out;
729 NinjaBinaryTargetWriter writer(&target, out); 729 NinjaBinaryTargetWriter writer(&target, out);
730 writer.Run(); 730 writer.Run();
731 731
732 // Should have issued an error. 732 // Should have issued an error.
733 EXPECT_TRUE(scheduler.is_failed()); 733 EXPECT_TRUE(scheduler.is_failed());
734 } 734 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698