language: node_js
matrix:
    fast_finish: true
    allow_failures:
        - node_js: "5"
node_js:
    - 0.10
    - 0.12
    - 4
    - 5
services:
    - couchdb
env:
    global:
        - NODE_ENV=test
        - CXX=g++-4.8
addons:
    apt:
        sources:
            - ubuntu-toolchain-r-test
        packages:
            - gcc-4.8
            - g++-4.8

before_install:
    - git clone git://github.com/cozy/cozy-data-system.git
    - cd cozy-data-system
    - npm install forever coffee-script -g
    - npm install # data-system
    - NAME=data-system TOKEN=token forever start -o forever-ds.log -e forever-ds-err.log build/server.js
    - ps aux | grep server.js
    - sleep 15
    - coffee commands.coffee test-install test ../tests/server/allpermissions.json
    - cd ..
    - export NAME=test
    - export TOKEN=apptoken

script:
    - echo "DATA SYSTEM"
    - npm run test
    - echo "STANDALONE"
    - npm install pouchdb
    - npm run test:pouch

after_failure:
    - pwd
    - ps aux | grep server.js
    - netstat -lntp
    - cat ~/cozy-data-system/forever-ds.log
    - cat ~/cozy-data-system/forever-ds-err.log
    - curl -v http://localhost:9101/
