-
Notifications
You must be signed in to change notification settings - Fork 17
test: add package installation integration tests #1052
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
|
||
| timeout: 120000, | ||
| } | ||
| ); | ||
|
|
||
| expect(result).toSucceed(); | ||
| expect(result.stdout).toContain('cargo_build_ok'); | ||
| }, 180000); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test creates /tmp/npm-test and leaves it behind. That can make later runs faster/flakier (install may not hit the network) and can grow disk usage over time. Prefer a unique mktemp directory (and ensure it’s removed even if npm/node fails).
This issue also appears in the following locations of the same file: