|
21 | 21 | InvalidVariantValueError, |
22 | 22 | MultipleValuesInExclusiveVariantError, |
23 | 23 | UnknownVariantError, |
24 | | - substitute_abstract_variants, |
25 | 24 | ) |
26 | 25 |
|
27 | 26 |
|
28 | | -def make_spec(spec_like, concrete): |
29 | | - spec = Spec(spec_like) |
30 | | - if concrete: |
31 | | - spec._mark_concrete() |
32 | | - substitute_abstract_variants(spec) |
33 | | - return spec |
34 | | - |
35 | | - |
36 | | -def check_cannot_constrain(target_spec, constraint_spec): |
37 | | - target = make_spec(target_spec, True) |
38 | | - constraint = Spec(constraint_spec) |
39 | | - |
40 | | - with pytest.raises(UnsatisfiableSpecError): |
41 | | - constraint.copy().constrain(target) |
42 | | - |
43 | | - |
44 | 27 | def check_constrain(expected, spec, constraint): |
45 | 28 | exp = Spec(expected) |
46 | 29 | spec = Spec(spec) |
@@ -302,6 +285,41 @@ def test_constraining_abstract_specs_with_empty_intersection(self, lhs, rhs): |
302 | 285 | with pytest.raises(UnsatisfiableSpecError): |
303 | 286 | rhs.constrain(lhs) |
304 | 287 |
|
| 288 | + @pytest.mark.parametrize( |
| 289 | + "lhs,rhs", |
| 290 | + [ |
| 291 | + ("mpich", "mpich +foo"), |
| 292 | + ("mpich", "mpich~foo"), |
| 293 | + ("mpich", "mpich foo=1"), |
| 294 | + ("mpich", "mpich++foo"), |
| 295 | + ("mpich", "mpich~~foo"), |
| 296 | + ("mpich", "mpich foo==1"), |
| 297 | + # Flags semantics is currently different from other variant |
| 298 | + pytest.param("mpich", 'mpich cppflags="-O3"', marks=pytest.mark.xfail), |
| 299 | + pytest.param( |
| 300 | + "multivalue-variant foo=bar", "multivalue-variant +foo", marks=pytest.mark.xfail |
| 301 | + ), |
| 302 | + pytest.param( |
| 303 | + "multivalue-variant foo=bar", "multivalue-variant ~foo", marks=pytest.mark.xfail |
| 304 | + ), |
| 305 | + ], |
| 306 | + ) |
| 307 | + def test_concrete_specs_which_do_not_satisfy_abstract( |
| 308 | + self, lhs, rhs, default_mock_concretization |
| 309 | + ): |
| 310 | + lhs, rhs = default_mock_concretization(lhs), Spec(rhs) |
| 311 | + |
| 312 | + assert lhs.intersects(rhs) |
| 313 | + assert rhs.intersects(lhs) |
| 314 | + assert not lhs.satisfies(rhs) |
| 315 | + assert not rhs.satisfies(lhs) |
| 316 | + |
| 317 | + with pytest.raises(UnsatisfiableSpecError): |
| 318 | + assert lhs.constrain(rhs) |
| 319 | + |
| 320 | + with pytest.raises(UnsatisfiableSpecError): |
| 321 | + assert rhs.constrain(lhs) |
| 322 | + |
305 | 323 | def test_satisfies_single_valued_variant(self): |
306 | 324 | """Tests that the case reported in |
307 | 325 | https://github.com/spack/spack/pull/2386#issuecomment-282147639 |
@@ -401,36 +419,6 @@ def test_unsatisfiable_multi_value_variant(self, default_mock_concretization): |
401 | 419 | with pytest.raises(MultipleValuesInExclusiveVariantError): |
402 | 420 | a.concretize() |
403 | 421 |
|
404 | | - def test_unsatisfiable_variant_types(self): |
405 | | - # These should fail due to incompatible types |
406 | | - |
407 | | - # FIXME: these needs to be checked as the new relaxed |
408 | | - # FIXME: semantic makes them fail (constrain does not raise) |
409 | | - # check_unsatisfiable('multivalue-variant +foo', |
410 | | - # 'multivalue-variant foo="bar"') |
411 | | - # check_unsatisfiable('multivalue-variant ~foo', |
412 | | - # 'multivalue-variant foo="bar"') |
413 | | - |
414 | | - check_cannot_constrain( |
415 | | - target_spec='multivalue-variant foo="bar"', constraint_spec="multivalue-variant +foo" |
416 | | - ) |
417 | | - |
418 | | - check_cannot_constrain( |
419 | | - target_spec='multivalue-variant foo="bar"', constraint_spec="multivalue-variant ~foo" |
420 | | - ) |
421 | | - |
422 | | - def test_unsatisfiable_variants(self): |
423 | | - # 'mpich' is concrete: |
424 | | - check_cannot_constrain("mpich", "mpich+foo") |
425 | | - check_cannot_constrain("mpich", "mpich~foo") |
426 | | - check_cannot_constrain("mpich", "mpich foo=1") |
427 | | - check_cannot_constrain("mpich", "mpich++foo") |
428 | | - check_cannot_constrain("mpich", "mpich~~foo") |
429 | | - check_cannot_constrain("mpich", "mpich foo==1") |
430 | | - |
431 | | - def test_unsatisfiable_compiler_flag(self): |
432 | | - check_cannot_constrain("mpich", 'mpich cppflags="-O3"') |
433 | | - |
434 | 422 | def test_copy_satisfies_transitive(self): |
435 | 423 | spec = Spec("dttop") |
436 | 424 | spec.concretize() |
|
0 commit comments