Skip to content

Bad path generated through getScreenshotName #21

Open

Description

@thinkspill

I was getting the following error:

Sorry, I couldn't compare screenshot "basicorderform","body":
ImagickException: Unable to write the file: /web/ee2/tests/_log/debug/tmp//web/ee2/tests/cart/BasicNewsTrialNewUser.basicorderform.png

Looking closely at the path you'll see /web/ee2/tests/ repeated twice. The first one is from Configuration::logDir() and the second one is being generated in VisualCeption::getScreenshotName.

That method calls $this->test->getFilename() to retrieve the test's filename, which is the source of the second path.

Removing $caseName from the return string fixes my basic test, but I'm not familiar enough with what other features this may affect that are looking for that screenshot name to be including a full path....

Activity

  1. phmLabs commented on Mar 25, 2014

    @phmLabs
    Collaborator

    Hi, I changed some permissions and swiched from mkdir( $dir, 0666) to mkdir( $dir, 0777, true) can you verify the changes took effect?

  2. phmLabs commented on Mar 25, 2014

    @phmLabs
    Collaborator

    Be careful. We changed the methods name to seeVisualChanges and dontSeeVisualChanges.

  3. thinkspill commented on Mar 25, 2014

    @thinkspill
    Author

    I don't think the problem is permissions. The problem is that $this->test->getFilename() is returning the full path to the test file, which you are then appending to the Codeception logDir which already contains the full path:

    $logdir: /web/ee2/tests/_log/debug/tmp/
    $testGetFileName: /web/ee2/tests/cart/BasicNewsTrialNewUserCept

    You strip off the Cept, append a .png, and then concatenate the two strings, resulting in this:

    /web/ee2/tests/_log/debug/tmp//web/ee2/tests/cart/BasicNewsTrialNewUser.basicorderform.png

    My guess is a correct output for this would be:

    /web/ee2/tests/_log/debug/tmp/BasicNewsTrialNewUser.basicorderform.png

  4. phmLabs commented on Mar 25, 2014

    @phmLabs
    Collaborator

    Ok, now I the the problem. We have a flat structure in our test files at the moment, so we do not run into that problem.

    I think we are able to remove the tmp image as it is not needed if you use the facebook webdriver executor directly. But we will run into the same problem when we store the reference or compare image.

    We have to possible solutions:

    • create the folders according to the project structure
    • flatten the images names

    What would be the prefered way?

  5. thinkspill commented on Mar 25, 2014

    @thinkspill
    Author

    If the goal is to generate a system-unique filename, converting all directory separators to underscores in GetScreenShotName might be sufficient.

  6. sebastianneubert commented on Mar 25, 2014

    @sebastianneubert
    Collaborator

    Can I get your codeception.yml file?

  7. phmLabs commented on Mar 25, 2014

    @phmLabs
    Collaborator

    The problem is that the getFileName method returns a relative path in our virtual machine and on travis ci.

  8. thinkspill commented on Mar 25, 2014

    @thinkspill
    Author

    Relevant sections of codeception.yml. Let me know if you're looking for another section.

    paths:
        tests: tests
        log: tests/_log
        data: tests/_data
        helpers: tests/_helpers
    settings:
        bootstrap: _bootstrap.php
        suite_class: \PHPUnit_Framework_TestSuite
        colors: true
        memory_limit: 2048M
        log: true
    modules:
      config:
        VisualCeption:
          referenceImageDir: tests/referenceImages/
          maximumDeviation: 5
    
  9. phmLabs commented on Mar 25, 2014

    @phmLabs
    Collaborator

    I guess I know why we can't reproduce your problem. You are using cests, right? We test cepts. That's why getFileName returns the classname in our case, but does returns the path in your test.

    Tomorrow I will check my assumption.

  10. thinkspill commented on Mar 25, 2014

    @thinkspill
    Author

    No, I usually use Cepts:

    /web/ee2/tests/cart/BasicNewsTrialNewUserCept.php for example.

    Important to note is that I'm using the Codeception 2.0 beta. Maybe this is a change from 1.8.x. that it returns the full path.

  11. phmLabs commented on Mar 25, 2014

    @phmLabs
    Collaborator

    Ok, I always confuse those two. We are using cests :)

  12. thinkspill commented on Mar 25, 2014

    @thinkspill
    Author

    Right, I'm using the single test file Cept format, rather than the class-based Cest format.

  13. thinkspill commented on Mar 25, 2014

    @thinkspill
    Author

    Interestingly, however, it is Cept.php you are removing from the filename inside getScreenshotName:

    $caseName = str_replace('Cept.php', '', $this->test->getFileName());

    If you all use Cest I'm surprised you're removing Cept here.

  14. phmLabs commented on Mar 25, 2014

    @phmLabs
    Collaborator

    Damn. I created a Cept and the travis CI works like a charm.

    https://travis-ci.org/DigitalProducts/codeception-module-visualception/jobs/21534609

    Copying image (from /home/travis/build/DigitalProducts/codeception-module-
    visualception/test/integration/tests/_log/debug/tmp/Simple.block.png to 
    /home/travis/build/DigitalProducts/codeception-module-
    visualception/test/integration/tests/_data/VisualCeption/Simple.block.png
    

    I guess we have to check Codeception 2.0.

  15. phmLabs commented on Mar 26, 2014

    @phmLabs
    Collaborator

    Ok, it's a 2.0 "Bug".

    I created a travis environment for the beta and it fails. The getFileName function has changed its signature.

  16. phmLabs commented on Mar 26, 2014

    @phmLabs
    Collaborator

    The bug should be fixed. The filename is very ugly but we use the same naming convention as codeception 2.0 makeScreenshot(). If there is a fix/beautification in 2.0 we will switch to that one.

  17. thinkspill commented on Mar 26, 2014

    @thinkspill
    Author

    Thanks, I'll give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions