diff --git a/lib/spack/spack/test/relocate.py b/lib/spack/spack/test/relocate.py
index 551f1596f7be5dd2a4243c5197e31c05ba6b05fa..a1a8952c974c76594e17cdba5b5e39c28c54a662 100644
--- a/lib/spack/spack/test/relocate.py
+++ b/lib/spack/spack/test/relocate.py
@@ -337,7 +337,8 @@ def test_make_elf_binaries_relative(hello_world, copy_binary, tmpdir):
         [str(new_binary)], [str(orig_binary)], str(orig_binary.dirpath())
     )
 
-    assert rpaths_for(new_binary) == '$ORIGIN/lib:$ORIGIN/lib64:/opt/local/lib'
+    # Some compilers add rpaths so ensure changes included in final result
+    assert '$ORIGIN/lib:$ORIGIN/lib64:/opt/local/lib' in rpaths_for(new_binary)
 
 
 def test_raise_if_not_relocatable(monkeypatch):