Vectorface / dunit

Test code against multiple versions of PHP with the help of docker
MIT License
248 stars 12 forks source link

Dunit can't find phpunit #13

Closed dgmstuart closed 9 years ago

dgmstuart commented 9 years ago

When I try to run e.g. ./vendor/bin/dunit -i "vectorface/php5.4" or just ./vendor/bin/dunit, I get:

/bin/bash: /opt/source/vendor/bin/phpunit: No such file or directory

Maybe I missed some setup? but I assume that path is referring to the docker image provided by dunit, so I don't understand what's gone wrong. I'm using boot2docker on OSX

ckdarby commented 9 years ago

@dgmstuart Nevermind what I had posted. Originally I read, "can't find dunit".

danbruce commented 9 years ago

Do you have the phpunit in your project as a composer dependency? That is, outside of dunit, can you run ./vendor/bin/phpunit ?

If not, then you will need to add it (or modify the command dunit runs for unit tests). If you do have it, then the likely culprit is that your source code is not getting mounted inside the container (which will take some more looking into why).

dgmstuart commented 9 years ago

Yup - here's my composer.json:

{
  "require-dev": {
    "phpunit/phpunit": "4.7.*",
    "vectorface/dunit": "^2.1"
  }
}

and my lockfile: https://gist.github.com/dgmstuart/e54e5ac418b081264ce1

If I run vendor/bin/phpunit or vendor/phpunit/phpunit/phpunit directly, then the tests get run correctly.

Incidentally the syntax checking doesn't seem to work either: it just fails silently, and doesn't show an error when I put a syntax error in the code.

danbruce commented 9 years ago

Sounds like the code base isn't being mounted inside the container as a volume.

What do you get when you run this:

$> cd [project folder]
$> docker run -v `pwd`:/opt/source -t -i vectorface/php5.4 bash
$> ls /opt/source
dgmstuart commented 9 years ago

Yeah, it's empty - there's nothing there. Anything else I can try?

jdpanderson commented 9 years ago

That does appear to confirm Dan's suspicion that the code isn't being mounted in the docker container. This seems to be more likely an issue with boot2docker or how its set up.

Is your code somewhere within /Users? If not, can you try copying it there and try again?

dgmstuart commented 9 years ago

Yes, it's underneath /Users

Here are the non-sensitive parts of my boot2docker config:

# boot2docker profile filename: /Users/********/.boot2docker/profile
Init = false
Verbose = false
Driver = "virtualbox"
Clobber = true
ForceUpgradeDownload = false
SSH = "ssh"
SSHGen = "ssh-keygen"
SSHKey = "/Users/********/.ssh/id_boot2docker"
VM = "boot2docker-vm"
Dir = "/Users/********/.boot2docker"
ISOURL = "https://api.github.com/repos/boot2docker/boot2docker/releases"
ISO = "/Users/********/.boot2docker/boot2docker.iso"
DiskSize = 20000
Memory = 2048
CPUs = 4
SSHPort = 2022
DockerPort = 0
HostIP = ********
DHCPIP = ********
NetMask = ********
LowerIP = ********
UpperIP = ********
DHCPEnabled = true
Serial = false
SerialFile = "/Users/********/.boot2docker/boot2docker-vm.sock"
Waittime = 300
Retries = 75
rogeriopradoj commented 9 years ago

Hi @dgmstuart, I think they are trying to ask if the PROJECT is under /Users.

When you run pwd in the PROJECT root folder, what is shown?

dgmstuart commented 9 years ago

@rogeriopradoj Wat?

Yes, the project is under /Users - what did you think I was saying was under /Users? Docker? I mentioned my boot2docker config because @jdpanderson thought it might be a problem with that. I've clarified that above now.

The project path is something like /Users/blah/Dev/WordPress/blah/plugins/blah

danbruce commented 9 years ago

@dgmstuart Unfortunately, this is working for me just fine out of the box. I just completed a fresh install of docker 1.7.0, boot2docker 1.7.0, and Virtualbox 4.3.8 (the latest versions of all three pieces of software at the time of this writing) on a Macbook Pro with OS X Yosemite 10.10.3. You can check the version with:

$> docker --version
Docker version 1.7.0, build 0baf609
$>boot2docker version
Boot2Docker-cli version: v1.7.0
Git commit: 7d89508
$>VBoxHeadless --version
Oracle VM VirtualBox Headless Interface 4.3.28
(C) 2008-2015 Oracle Corporation
All rights reserved.

4.3.28r100309

This is not really an issue with dunit as it is with docker in general. dunit of course requires that the source code folder be mounted inside the container to run the unit tests, linting, etc.

From past experiences with boot2docker sometimes weird stuff happens with the virtual machine that boot2docker creates. You can try (at your own risk of course), upgrading your version of boot2docker and docker like this (NOTE that this will delete your vm cleanly so you'll lose any downloaded images, running images, etc):

$> boot2docker stop
$> boot2docker destroy
$> boot2docker upgrade
$> boot2docker init
$> boot2docker start
$> // copy/paste the environment variables if required
$> cd [working project folder root]
$> docker run -v `pwd`:/opt/source -t -i vectorface/php5.4 bash
$> ls /opt/source

and you should see the working directory at /opt/source.

If you're on the latest version and you've created a fresh install of the VM, then I'm at a loss at what you can do. You'll probably need to file an issue with boot2docker directly.

dgmstuart commented 9 years ago

I've upgraded according your very clear instructions, and now everything seems to be working perfectly.

Thank you so much for taking the time to help me with something which wasn't even related to your code! :heart:

dgmstuart commented 9 years ago

I also had this certificate issue after upgrading, but it's easily fixed: https://gist.github.com/garthk/d5a17007c277aa5c76de