Skip to content
Merged
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
59 changes: 59 additions & 0 deletions tests/integration/chroot-package-managers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,63 @@ describe('Chroot Package Manager Support', () => {
expect(result.stdout).toContain('module test');
}, 120000);
});

// ---------- Package Installation ----------
describe('Package Installation', () => {
test('should install a Python package via pip and verify import', async () => {
const result = await runner.runWithSudo(
'PIPDIR=$(mktemp -d) && ' +
'pip3 install --no-cache-dir --target $PIPDIR requests 2>&1 && ' +
'PYTHONPATH=$PIPDIR python3 -c "import requests; print(requests.__version__)" && ' +
'rm -rf $PIPDIR',
{
allowDomains: ['pypi.org', 'files.pythonhosted.org'],
logLevel: 'debug',
timeout: 120000,
}
);

expect(result).toSucceed();
const lines = result.stdout.split('\n').map(l => l.trim()).filter(l => l.length > 0);
const lastLine = lines[lines.length - 1] || '';
expect(lastLine).toMatch(/^\d+\.\d+\.\d+$/);
}, 180000);

test('should install an npm package and verify require', async () => {
const result = await runner.runWithSudo(
'NPMDIR=$(mktemp -d) && cd $NPMDIR && npm init -y 2>&1 && ' +
'npm install chalk@4 2>&1 && ' +
'NODE_PATH=$NPMDIR/node_modules node -e "require(\'chalk\')" && echo "npm_install_ok" && ' +
'rm -rf $NPMDIR',
{
allowDomains: ['registry.npmjs.org'],
logLevel: 'debug',
timeout: 120000,
}
);

expect(result).toSucceed();
expect(result.stdout).toContain('npm_install_ok');
}, 180000);

test('should build a Rust project with a dependency via cargo', async () => {
const result = await runner.runWithSudo(
'TESTDIR=$(mktemp -d) && cd $TESTDIR && ' +
'CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse ' +
'cargo init --name awftest 2>&1 && ' +
'echo \'cfg-if = "1"\' >> Cargo.toml && ' +
'CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse ' +
'cargo build 2>&1 && echo "cargo_build_ok"; ' +
'EC=$?; rm -rf $TESTDIR; exit $EC',
{
allowDomains: ['crates.io', 'static.crates.io', 'index.crates.io'],
logLevel: 'debug',
Comment on lines +400 to +402
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relies on Cargo using the sparse index (index.crates.io). On environments where Cargo still uses the git index, it will attempt to reach GitHub and this test will fail under the current allowDomains. To make the test deterministic, explicitly force sparse protocol (e.g., via CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse) or expand the domain allowlist to cover the git index host your Cargo version uses.

Copilot uses AI. Check for mistakes.
timeout: 120000,
}
);

expect(result).toSucceed();
expect(result.stdout).toContain('cargo_build_ok');
}, 180000);
});
});
Loading