Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pip package manager tests #256

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/fixtures/pip_basic/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This package has been picked since it has no dependencies and is small/fast to install.
typing-extensions==4.7.1
typing-extensions==4.12.2
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
# The URL to the package is specified via env var, to test that user-provided env vars
# are propagated to pip for use by its env var interpolation feature.

-e git+${WHEEL_PACKAGE_URL}@0.40.0#egg=extension.dist&subdirectory=tests/testdata/extension.dist
-e git+${WHEEL_PACKAGE_URL}@0.44.0#egg=extension.dist&subdirectory=tests/testdata/extension.dist
24 changes: 24 additions & 0 deletions tests/fixtures/testing_buildpack/bin/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# Check that:
# - The correct env vars are set for later buildpacks.
# - Python's sys.path is correct.
# - The correct version of pip was installed.
# - Both the package manager and Python can find the typing-extensions package.
# - The system site-packages directory is protected against running 'pip install'
# without having passed '--user'.
# - The typing-extensions package was installed into a separate dependencies layer.

set -euo pipefail

echo
echo "## Testing buildpack ##"

printenv | sort | grep -vE '^(_|CNB_.+|HOME|HOSTNAME|OLDPWD|PWD|SHLVL)='
echo
python -c 'import pprint, sys; pprint.pp(sys.path)'
echo
pip --version
pip list
pip install --dry-run typing-extensions
python -c 'import typing_extensions; print(typing_extensions)'
3 changes: 3 additions & 0 deletions tests/fixtures/testing_buildpack/bin/detect
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

exit 0
6 changes: 6 additions & 0 deletions tests/fixtures/testing_buildpack/buildpack.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
api = "0.11"

[buildpack]
id = "testing-buildpack"
version = "0.0.0"
clear-env = true
8 changes: 4 additions & 4 deletions tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
//! These tests are not run via automatic integration test discovery, but instead are
//! imported in main.rs so that they have access to private APIs (see comment in main.rs).
use libcnb_test::BuildConfig;
use std::env;
use std::path::Path;

mod detect_test;
mod django_test;
mod package_manager_test;
mod pip_test;
mod python_version_test;

use libcnb_test::BuildConfig;
use std::env;
use std::path::Path;

const LATEST_PYTHON_3_7: &str = "3.7.17";
const LATEST_PYTHON_3_8: &str = "3.8.19";
const LATEST_PYTHON_3_9: &str = "3.9.19";
Expand Down
300 changes: 159 additions & 141 deletions tests/pip_test.rs

Large diffs are not rendered by default.