Skip to content

Commit 71b0b4e

Browse files
isurufcopybara-github
authored andcommitted
Fix getting env variables on windows (#15518)
Fixes #15436 Closes #15518 COPYBARA_INTEGRATE_REVIEW=#15518 from isuruf:win_env 1b1f2cc PiperOrigin-RevId: 600469988
1 parent 0f4cf16 commit 71b0b4e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/google/protobuf/compiler/mock_code_generator.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ static constexpr absl::string_view kSecondInsertionPoint =
7272
" # @@protoc_insertion_point(second_mock_insertion_point) is here\n";
7373

7474
MockCodeGenerator::MockCodeGenerator(absl::string_view name) : name_(name) {
75-
absl::string_view key = getenv("TEST_CASE");
75+
const char* c_key = getenv("TEST_CASE");
76+
if (c_key == NULL) {
77+
// In Windows, setting 'TEST_CASE=' is equivalent to unsetting
78+
// and therefore c_key can be NULL
79+
c_key = "";
80+
}
81+
absl::string_view key(c_key);
7682
if (key == "no_editions") {
7783
suppressed_features_ |= CodeGenerator::FEATURE_SUPPORTS_EDITIONS;
7884
} else if (key == "invalid_features") {

0 commit comments

Comments
 (0)