Skip to content

Commit

Permalink
Internal change: Fix compliance regression in from unknown commit
Browse files Browse the repository at this point in the history
I'm not totally happy with this change. We probably should add a method for mock license support.  But this will do to get us on the right track.

The underlying problem is that we have tests which mingle mocks with live rule code. This is fragile. Mock it all, or pull in all of the live things. The first is difficult and may not test reality.  The latter forks blaze and bazel tests.

RELNOTES: None
PiperOrigin-RevId: 566922698
Change-Id: I67ffed21240385c73b56133424a01487cdbe9714
  • Loading branch information
aiuto authored and copybara-github committed Sep 20, 2023
1 parent ae99c1f commit 3acab6f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,27 @@ protected void setupRulesCc(MockToolsConfig config) throws IOException {
TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/build_defs/cc/action_names.bzl",
ResourceLoader.readFromResources(
TestConstants.RULES_CC_REPOSITORY_EXECROOT + "cc/action_names.bzl"));
config.create(
TestConstants.RULES_CC_REPOSITORY_EXECROOT + "BUILD",
"genrule(name='license', cmd='exit 0', outs=['dummy_license'])");
config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/build_defs/cc/BUILD");
config.append(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/cpp/BUILD", "");

// These could be a distinct method
config.create(
TestConstants.TOOLS_REPOSITORY_SCRATCH + TestConstants.MOCK_LICENSE_SCRATCH + "BUILD",
"genrule(name='license', cmd='exit 0', outs=['dummy_license'])");
config.create(
TestConstants.TOOLS_REPOSITORY_SCRATCH
+ TestConstants.MOCK_LICENSE_SCRATCH
+ "rules/BUILD");
config.create(
TestConstants.TOOLS_REPOSITORY_SCRATCH
+ TestConstants.MOCK_LICENSE_SCRATCH
+ "rules/license.bzl",
"def license(name, **kwargs):",
" pass",
"");
}

protected static void createParseHeadersAndLayeringCheckWhitelist(MockToolsConfig config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ private TestConstants() {
/** The path in which the mock cc crosstool resides. */
public static final String MOCK_CC_CROSSTOOL_PATH = "tools/cpp";

/** The path in which the mock license rule resides. */
public static final String MOCK_LICENSE_SCRATCH = "third_party/rules_license/";

/** The workspace repository label under which built-in tools reside. */
public static final RepositoryName TOOLS_REPOSITORY = RepositoryName.BAZEL_TOOLS;
/** The file path in which to create files so that they end up under {@link #TOOLS_REPOSITORY}. */
Expand Down

0 comments on commit 3acab6f

Please sign in to comment.