Skip to content

Commit

Permalink
Automated rollback of commit 86a8217.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Revert the temporary parsing of tools/blaze.rc.
Fixes #6319.

*** Original change description ***

Temporarily restore processing of workspace-wide tools/bazel.rc file.

PiperOrigin-RevId: 216417037
  • Loading branch information
dslomov authored and Copybara-Service committed Oct 9, 2018
1 parent b02348a commit a6c7758
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 57 deletions.
31 changes: 5 additions & 26 deletions src/main/cpp/option_processor.cc
Expand Up @@ -23,7 +23,6 @@
#include <set>
#include <sstream>
#include <utility>
#include <vector>

#include "src/main/cpp/blaze_util.h"
#include "src/main/cpp/blaze_util_platform.h"
Expand Down Expand Up @@ -323,9 +322,6 @@ blaze_exit_code::ExitCode OptionProcessor::GetRcFiles(
SearchNullaryOption(cmd_line->startup_args, "workspace_rc", true)) {
const std::string workspaceRcFile =
blaze_util::JoinPath(workspace, kRcBasename);
// Legacy behavior.
rc_files.push_back(workspace_layout->GetWorkspaceRcPath(
workspace, cmd_line->startup_args));
rc_files.push_back(workspaceRcFile);
}

Expand Down Expand Up @@ -401,22 +397,16 @@ blaze_exit_code::ExitCode OptionProcessor::GetRcFiles(
workspace_layout, workspace, cwd, cmd_line->path_to_binary,
cmd_line->startup_args, internal::FindSystemWideRc(system_bazelrc_path_));

std::vector<std::string> lost_files;
for (auto it = old_files.begin(); it != old_files.end(); it++) {
// we record canonical file names in read_files, so we need to
// canonicalize old file name, but we still report uncanonicalized
// names in error messages.
std::string canonical_old_file = blaze_util::MakeCanonical(it->c_str());
if (read_files.find(canonical_old_file) == read_files.end()) {
lost_files.push_back(*it);
}
}

// std::vector<std::string> old_files = internal::GetOldRcPathsInOrder(
// workspace_layout, workspace, cwd, cmd_line->path_to_binary,
// cmd_line->startup_args);
//
// std::sort(old_files.begin(), old_files.end());
std::vector<std::string> lost_files(old_files.size());
std::vector<std::string>::iterator end_iter = std::set_difference(
old_files.begin(), old_files.end(), read_files.begin(), read_files.end(),
lost_files.begin());
lost_files.resize(end_iter - lost_files.begin());
if (!lost_files.empty()) {
std::string joined_lost_rcs;
blaze_util::JoinStrings(lost_files, '\n', &joined_lost_rcs);
Expand All @@ -427,17 +417,6 @@ blaze_exit_code::ExitCode OptionProcessor::GetRcFiles(
<< joined_lost_rcs;
}

std::string legacy_workspace_file =
workspace_layout->GetWorkspaceRcPath(workspace, cmd_line->startup_args);
if (old_files.find(legacy_workspace_file) != old_files.end()) {
BAZEL_LOG(WARNING)
<< "Processed legacy workspace file "
<< legacy_workspace_file
<< ". This file will not be processed in the next release of Bazel."
<< " Please read https://github.com/bazelbuild/bazel/issues/6319"
<< " for further information, including how to upgrade.";
}

return blaze_exit_code::SUCCESS;
}

Expand Down
32 changes: 1 addition & 31 deletions src/test/cpp/rc_file_test.cc
Expand Up @@ -261,38 +261,8 @@ TEST_F(GetRcFileTest, GetRcFilesWarnsAboutIgnoredMasterRcFiles) {
// read as expected.
EXPECT_THAT(output,
HasSubstr("The following rc files are no longer being read"));
EXPECT_THAT(output, HasSubstr(binary_rc));

EXPECT_THAT(output, HasSubstr("Processed legacy workspace file"));
EXPECT_THAT(output, HasSubstr(workspace_rc));
}

TEST_F(GetRcFileTest, GetRcFilesWarnsAboutLegacyWorkspaceFile) {
std::string workspace_rc;
ASSERT_TRUE(SetUpLegacyMasterRcFileInWorkspace("", &workspace_rc));

const CommandLine cmd_line = CommandLine(binary_path_, {}, "build", {});
std::string error = "check that this string is not modified";
std::vector<std::unique_ptr<RcFile>> parsed_rcs;

testing::internal::CaptureStderr();
const blaze_exit_code::ExitCode exit_code =
option_processor_->GetRcFiles(workspace_layout_.get(), workspace_, cwd_,
&cmd_line, &parsed_rcs, &error);
const std::string output = testing::internal::GetCapturedStderr();

EXPECT_EQ(blaze_exit_code::SUCCESS, exit_code);
EXPECT_EQ("check that this string is not modified", error);

// tools/blaze.rc should be read...
EXPECT_THAT(
output,
Not(HasSubstr("The following rc files are no longer being read")));

// ... but reported specially.
// (cf https://github.com/bazelbuild/bazel/issues/6321).
EXPECT_THAT(output, HasSubstr("Processed legacy workspace file"));
EXPECT_THAT(output, HasSubstr(workspace_rc));
EXPECT_THAT(output, HasSubstr(binary_rc));
}

TEST_F(
Expand Down

0 comments on commit a6c7758

Please sign in to comment.