Skip to content

Commit

Permalink
Create a stub for an OSS version of MockPythonSupport
Browse files Browse the repository at this point in the history
This is needed to open source unit tests for Python rules.

Work towards #1446 and other Python-related items.

RELNOTES: None
PiperOrigin-RevId: 212474035
  • Loading branch information
brandjon authored and Copybara-Service committed Sep 11, 2018
1 parent 5bf57be commit 4673aec
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import com.google.devtools.build.lib.bazel.rules.BazelRuleClassProvider.StrictActionEnvOptions;
import com.google.devtools.build.lib.bazel.rules.python.BazelPythonConfiguration;
import com.google.devtools.build.lib.packages.util.BazelMockCcSupport;
import com.google.devtools.build.lib.packages.util.BazelMockPythonSupport;
import com.google.devtools.build.lib.packages.util.MockCcSupport;
import com.google.devtools.build.lib.packages.util.MockPythonSupport;
import com.google.devtools.build.lib.packages.util.MockToolsConfig;
import com.google.devtools.build.lib.rules.android.AndroidConfiguration;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
Expand Down Expand Up @@ -197,6 +199,7 @@ public void setupMockClient(MockToolsConfig config) throws IOException {
config.create("/bazel_tools_workspace/objcproto/well_known_type.proto");

ccSupport().setup(config);
pySupport().setup(config);
}

/** Contents of {@code //tools/android/emulator/BUILD.tools}. */
Expand Down Expand Up @@ -334,4 +337,9 @@ public boolean isThisBazel() {
public MockCcSupport ccSupport() {
return BazelMockCcSupport.INSTANCE;
}

@Override
public MockPythonSupport pySupport() {
return BazelMockPythonSupport.INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.devtools.build.lib.bazel.rules.android.AndroidSdkRepositoryRule;
import com.google.devtools.build.lib.packages.util.LoadingMock;
import com.google.devtools.build.lib.packages.util.MockCcSupport;
import com.google.devtools.build.lib.packages.util.MockPythonSupport;
import com.google.devtools.build.lib.packages.util.MockToolsConfig;
import com.google.devtools.build.lib.rules.cpp.CcSkyframeSupportValue;
import com.google.devtools.build.lib.rules.cpp.CcSupportFunction;
Expand Down Expand Up @@ -114,6 +115,8 @@ public String getDefaultsPackageContent() {

public abstract MockCcSupport ccSupport();

public abstract MockPythonSupport pySupport();

public void setupCcSupport(MockToolsConfig config) throws IOException {
get().ccSupport().setup(config);
}
Expand Down Expand Up @@ -183,6 +186,11 @@ public MockCcSupport ccSupport() {
return delegate.ccSupport();
}

@Override
public MockPythonSupport pySupport() {
return delegate.pySupport();
}

@Override
public Collection<String> getOptionOverrides() {
return delegate.getOptionOverrides();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2018 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.devtools.build.lib.packages.util;

import java.io.IOException;

/** Mock python support in Bazel. */
public class BazelMockPythonSupport extends MockPythonSupport {

public static final BazelMockPythonSupport INSTANCE = new BazelMockPythonSupport();

@Override
public void setup(MockToolsConfig config) throws IOException {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2018 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.devtools.build.lib.packages.util;

import java.io.IOException;

/**
* Creates mock BUILD files required for the python rules.
*/
public abstract class MockPythonSupport {

/** Setup the support for building Python. */
public abstract void setup(MockToolsConfig config) throws IOException;
}

0 comments on commit 4673aec

Please sign in to comment.