Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertSameFiles of perceptualdiff engine fails when file paths contain spaces #43

Open
sterago opened this issue Mar 17, 2015 · 3 comments

Comments

@sterago
Copy link
Contributor

sterago commented Mar 17, 2015

First of all, thanks for the nice tool!

We are using it in a Jenkins CI setup, and the screenshots path happens to have spaces.

This is causing the perceptualdiff command to parse the --output parameter incorrectly, splitting it in correspondence of the space.

We've now worked around the issue by patching this line:
https://github.com/bfirsh/needle/blob/master/needle/engines/perceptualdiff_engine.py#L20

specifically replacing

%s %s %s

with

'%s' '%s' '%s'
@acdha
Copy link
Collaborator

acdha commented Mar 17, 2015

Hmmm, that entire line should really just be a list so subprocess will handle escaping for us.

@jphalip
Copy link
Collaborator

jphalip commented Sep 10, 2015

Thanks for the report. @sterago, could you confirm if this patch below would fix your issue?

diff --git a/needle/engines/perceptualdiff_engine.py b/needle/engines/perceptualdiff_engine.py
index 33ef157..bdf1777 100644
--- a/needle/engines/perceptualdiff_engine.py
+++ b/needle/engines/perceptualdiff_engine.py
@@ -17,8 +17,7 @@ class Engine(EngineBase):
         threshold = int(width * height * threshold)

         diff_ppm = output_file.replace(".png", ".diff.ppm")
-        cmd = "%s -threshold %d -output %s %s %s" % (
-            self.perceptualdiff_path, threshold, diff_ppm, baseline_file, output_file)
+        cmd = [self.perceptualdiff_path, '-threshold', threshold, '-output', diff_ppm, baseline_file, output_file]
         process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         perceptualdiff_stdout, _ = process.communicate()

@sterago
Copy link
Contributor Author

sterago commented Sep 15, 2015

hi @jphalip and thanks for the patch.
This didn't work right away, and I had to change the following:

other than that, it works fine

hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants