How to use update_packages method in lisa

Best Python code snippet using lisa_python

concretize_preferences.py

Source:concretize_preferences.py Github

copy

Full Screen

...42 spack.config.set('packages', conf, scope='concretize')43 yield44def concretize(abstract_spec):45 return Spec(abstract_spec).concretized()46def update_packages(pkgname, section, value):47 """Update config and reread package list"""48 conf = {pkgname: {section: value}}49 spack.config.set('packages', conf, scope='concretize')50 spack.package_prefs.PackagePrefs.clear_caches()51def assert_variant_values(spec, **variants):52 concrete = concretize(spec)53 for variant, value in variants.items():54 assert concrete.variants[variant].value == value55@pytest.mark.usefixtures('concretize_scope', 'mock_packages')56class TestConcretizePreferences(object):57 def test_preferred_variants(self):58 """Test preferred variants are applied correctly59 """60 update_packages('mpileaks', 'variants', '~debug~opt+shared+static')61 assert_variant_values(62 'mpileaks', debug=False, opt=False, shared=True, static=True63 )64 update_packages(65 'mpileaks', 'variants', ['+debug', '+opt', '~shared', '-static']66 )67 assert_variant_values(68 'mpileaks', debug=True, opt=True, shared=False, static=False69 )70 def test_preferred_compilers(self, mutable_mock_packages):71 """Test preferred compilers are applied correctly72 """73 update_packages('mpileaks', 'compiler', ['clang@3.3'])74 spec = concretize('mpileaks')75 assert spec.compiler == spack.spec.CompilerSpec('clang@3.3')76 update_packages('mpileaks', 'compiler', ['gcc@4.5.0'])77 spec = concretize('mpileaks')78 assert spec.compiler == spack.spec.CompilerSpec('gcc@4.5.0')79 def test_preferred_target(self, mutable_mock_packages):80 """Test preferred compilers are applied correctly81 """82 spec = concretize('mpich')83 default = str(spec.target)84 preferred = str(spec.target.family)85 update_packages('mpich', 'target', [preferred])86 spec = concretize('mpich')87 assert str(spec.target) == preferred88 spec = concretize('mpileaks')89 assert str(spec['mpileaks'].target) == default90 assert str(spec['mpich'].target) == preferred91 update_packages('mpileaks', 'target', [preferred])92 spec = concretize('mpileaks')93 assert str(spec['mpich'].target) == preferred94 assert str(spec['mpich'].target) == preferred95 def test_preferred_versions(self):96 """Test preferred package versions are applied correctly97 """98 update_packages('mpileaks', 'version', ['2.3'])99 spec = concretize('mpileaks')100 assert spec.version == spack.spec.Version('2.3')101 update_packages('mpileaks', 'version', ['2.2'])102 spec = concretize('mpileaks')103 assert spec.version == spack.spec.Version('2.2')104 def test_preferred_versions_mixed_version_types(self):105 update_packages('mixedversions', 'version', ['2.0'])106 spec = concretize('mixedversions')107 assert spec.version == spack.spec.Version('2.0')108 def test_preferred_providers(self):109 """Test preferred providers of virtual packages are110 applied correctly111 """112 update_packages('all', 'providers', {'mpi': ['mpich']})113 spec = concretize('mpileaks')114 assert 'mpich' in spec115 update_packages('all', 'providers', {'mpi': ['zmpi']})116 spec = concretize('mpileaks')117 assert 'zmpi' in spec118 def test_preferred(self):119 """"Test packages with some version marked as preferred=True"""120 spec = Spec('preferred-test')121 spec.concretize()122 assert spec.version == spack.spec.Version('0.2.15')123 # now add packages.yaml with versions other than preferred124 # ensure that once config is in place, non-preferred version is used125 update_packages('preferred-test', 'version', ['0.2.16'])126 spec = Spec('preferred-test')127 spec.concretize()128 assert spec.version == spack.spec.Version('0.2.16')129 def test_develop(self):130 """Test concretization with develop-like versions"""131 spec = Spec('develop-test')132 spec.concretize()133 assert spec.version == spack.spec.Version('0.2.15')134 spec = Spec('develop-test2')135 spec.concretize()136 assert spec.version == spack.spec.Version('0.2.15')137 # now add packages.yaml with develop-like versions138 # ensure that once config is in place, develop-like version is used139 update_packages('develop-test', 'version', ['develop'])140 spec = Spec('develop-test')141 spec.concretize()142 assert spec.version == spack.spec.Version('develop')143 update_packages('develop-test2', 'version', ['0.2.15.develop'])144 spec = Spec('develop-test2')145 spec.concretize()146 assert spec.version == spack.spec.Version('0.2.15.develop')147 def test_no_virtuals_in_packages_yaml(self):148 """Verify that virtuals are not allowed in packages.yaml."""149 # set up a packages.yaml file with a vdep as a key. We use150 # syaml.load_config here to make sure source lines in the config are151 # attached to parsed strings, as the error message uses them.152 conf = syaml.load_config("""\153mpi:154 paths:155 mpi-with-lapack@2.1: /path/to/lapack156""")157 spack.config.set('packages', conf, scope='concretize')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful