Fix autoload of direct dependencies for python (#9630)
fixes #9624 merge_config_rules was using `strict=False` to check if a spec satisfies a constraint, which loosely translates to "this spec has no conflict with the constraint, so I can potentially add it to the spec". We want instead `strict=True` which means "the spec satisfies the constraint right now".
This commit is contained in:
		 Massimiliano Culpo
					Massimiliano Culpo
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							534b71bdf1
						
					
				
				
					commit
					da537d2211
				
			| @@ -173,7 +173,7 @@ def merge_config_rules(configuration, spec): | |||||||
|         if constraint.endswith(':'): |         if constraint.endswith(':'): | ||||||
|             constraint = constraint.strip(':') |             constraint = constraint.strip(':') | ||||||
|             override = True |             override = True | ||||||
|         if spec.satisfies(constraint): |         if spec.satisfies(constraint, strict=True): | ||||||
|             if override: |             if override: | ||||||
|                 spec_configuration = {} |                 spec_configuration = {} | ||||||
|             update_dictionary_extending_lists(spec_configuration, action) |             update_dictionary_extending_lists(spec_configuration, action) | ||||||
|   | |||||||
| @@ -0,0 +1,8 @@ | |||||||
|  | enable: | ||||||
|  |   - tcl | ||||||
|  | tcl: | ||||||
|  |   ^mpich2: | ||||||
|  |     autoload: 'direct' | ||||||
|  |  | ||||||
|  |   ^python: | ||||||
|  |     autoload: 'direct' | ||||||
| @@ -276,3 +276,20 @@ def test_blacklist_implicits( | |||||||
|         for item in callpath_specs: |         for item in callpath_specs: | ||||||
|             writer = writer_cls(item) |             writer = writer_cls(item) | ||||||
|             assert writer.conf.blacklisted |             assert writer.conf.blacklisted | ||||||
|  |  | ||||||
|  |     @pytest.mark.regression('9624') | ||||||
|  |     @pytest.mark.db | ||||||
|  |     def test_autoload_with_constraints( | ||||||
|  |             self, modulefile_content, module_configuration, database | ||||||
|  |     ): | ||||||
|  |         """Tests the automatic loading of direct dependencies.""" | ||||||
|  |  | ||||||
|  |         module_configuration('autoload_with_constraints') | ||||||
|  |  | ||||||
|  |         # Test the mpileaks that should have the autoloaded dependencies | ||||||
|  |         content = modulefile_content('mpileaks ^mpich2') | ||||||
|  |         assert len([x for x in content if 'is-loaded' in x]) == 2 | ||||||
|  |  | ||||||
|  |         # Test the mpileaks that should NOT have the autoloaded dependencies | ||||||
|  |         content = modulefile_content('mpileaks ^mpich') | ||||||
|  |         assert len([x for x in content if 'is-loaded' in x]) == 0 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user