Skip to content

Commit

Permalink
PyInfo() constructor now uses its has_py3_only_sources parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
dws committed May 11, 2024
1 parent bb1fb53 commit 4483290
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/starlark/builtins_bzl/common/python/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _PyInfo_init(
"imports": imports,
"uses_shared_libraries": uses_shared_libraries,
"has_py2_only_sources": has_py2_only_sources,
"has_py3_only_sources": has_py2_only_sources,
"has_py3_only_sources": has_py3_only_sources,
}

PyInfo, _unused_raw_py_info_ctor = provider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,32 @@ public void starlarkConstructorDefaults() throws Exception {
assertThat(info.getHasPy3OnlySources()).isFalse();
}

@Test
public void starlarkConstructorDefaults_has_py2_only_sources() throws Exception {
writeCreatePyInfo(
" transitive_sources = depset(direct=[dummy_file])",
" has_py2_only_sources = True");

PyInfo info = getPyInfo();

// verify that has_py2_only_sources does not affect has_py3_only_sources
assertThat(info.getHasPy2OnlySources()).isTrue();
assertThat(info.getHasPy3OnlySources()).isFalse();
}

@Test
public void starlarkConstructorDefaults_has_py3_only_sources() throws Exception {
writeCreatePyInfo(
" transitive_sources = depset(direct=[dummy_file])",
" has_py3_only_sources = True");

PyInfo info = getPyInfo();

// verify that has_py3_only_sources does not affect has_py2_only_sources
assertThat(info.getHasPy2OnlySources()).isFalse();
assertThat(info.getHasPy3OnlySources()).isTrue();
}

@Test
public void starlarkConstructorErrors_transitiveSources_missing() throws Exception {
writeCreatePyInfo();
Expand Down

0 comments on commit 4483290

Please sign in to comment.