summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-06-05 14:54:33 -0600
committermo khan <mo.khan@gmail.com>2020-06-05 14:54:33 -0600
commit5d7201bf7830f16174adda1cd145e6804d7056b4 (patch)
treef97dcdbec762ac2d9c4db1c9c1fb3a18513b5778 /spec
parent8371eb864228b281a9b52b3a41bd5d5bdc8c0049 (diff)
Allow configuring Python version using environment variables
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/java/maven_spec.rb2
-rw-r--r--spec/integration/python/pip_spec.rb42
2 files changed, 43 insertions, 1 deletions
diff --git a/spec/integration/java/maven_spec.rb b/spec/integration/java/maven_spec.rb
index 1e0e4e4..9230a9f 100644
--- a/spec/integration/java/maven_spec.rb
+++ b/spec/integration/java/maven_spec.rb
@@ -109,7 +109,7 @@ RSpec.describe "maven" do
<<~SCRIPT
#!/bin/bash -l
- java -version 2> '#{output_file}'
+ java -version &> '#{output_file}'
SCRIPT
end
end
diff --git a/spec/integration/python/pip_spec.rb b/spec/integration/python/pip_spec.rb
index 0ba3d0e..e808188 100644
--- a/spec/integration/python/pip_spec.rb
+++ b/spec/integration/python/pip_spec.rb
@@ -157,4 +157,46 @@ setup(
expect(report.licenses_for('requests')).to match_array(['Apache-2.0'])
end
end
+
+ context "when specifying the version of Python using environment variables" do
+ let(:output_file) { Pathname.new(runner.project_path.join('output.txt')) }
+
+ before do
+ runner.add_file('custom.sh') do
+ <<~SCRIPT
+ #!/bin/bash -l
+
+ python --version &> '#{output_file}'
+ SCRIPT
+ end
+ end
+
+ it 'prioritizes `LM_PYTHON_VERSION` over the `ASDF_PYTHON_VERSION`' do
+ runner.scan(env: {
+ 'ASDF_PYTHON_VERSION' => '3.8.2',
+ 'LM_PYTHON_VERSION' => '2.7.18',
+ 'SETUP_CMD' => 'bash custom.sh'
+ })
+
+ expect(output_file).to exist
+ expect(output_file.read).to include('2.7.18')
+ end
+
+ it 'reads the ASDF_PYTHON_VERSION' do
+ runner.scan(env: {
+ 'ASDF_PYTHON_VERSION' => '3.8.2',
+ 'SETUP_CMD' => 'bash custom.sh'
+ })
+
+ expect(output_file).to exist
+ expect(output_file.read).to include('3.8.2')
+ end
+
+ it 'defaults to Python 3' do
+ runner.scan(env: { 'SETUP_CMD' => 'bash custom.sh' })
+
+ expect(output_file).to exist
+ expect(output_file.read).to include('3.8.2')
+ end
+ end
end