var fs = require('fs');
var path = require('path');
var assert = require('assert');

// switch to 'development' for more verbose logging
process.env.NODE_ENV = 'production'
var utils = require('../lib/util.js');
var millstone = require('../lib/millstone');
var tests = module.exports = {};
var rm = require('./support.js').rm;

var existsSync = require('fs').existsSync || require('path').existsSync;

beforeEach(function(){
  rm(path.join(__dirname, '/tmp/millstone-test'));
})

it('correctly handles invalid json', function(done) {
    var mml = JSON.parse(fs.readFileSync(path.join(__dirname, 'invalid-json/project.mml')));

    var options = {
        mml: mml,
        base: path.join(__dirname, 'invalid-json'),
        cache: '/tmp/millstone-test'
    };

    millstone.resolve(options, function(err, resolved) {
        assert.ok(err.message.search("error: 'Unexpected token ]'") != -1);
        done();
    });
});

it('correctly handles missing shapefile at relative path', function(done) {
    var mml = JSON.parse(fs.readFileSync(path.join(__dirname, 'missing-file-relative/project.mml')));

    var options = {
        mml: mml,
        base: path.join(__dirname, 'missing-file-relative'),
        cache: '/tmp/millstone-test'
    };

    millstone.resolve(options, function(err, resolved) {
        var err_expected = err.message.search("File not found:") != -1 || err.message.search("Can't open") != -1;
        assert.ok(err_expected);
        done();
    });
});


it('correctly handles missing shapefile at absolute path', function(done) {
    var mml = JSON.parse(fs.readFileSync(path.join(__dirname, 'missing-file-absolute/project.mml')));

    var options = {
        mml: mml,
        base: path.join(__dirname, 'missing-file-absolute'),
        cache: '/tmp/millstone-test'
    };

    millstone.resolve(options, function(err, resolved) {
        var err_expected = err.message.search("File not found:") != -1 || err.message.search("Can't open") != -1;
        assert.ok(err_expected);
        done();
    });
});
@@ -170,47 +170,8 @@
 on'%0A
-var utils = require('../lib/util.js');%0A
 var 
@@ -219,147 +219,41 @@
 var 
-tests = module.exports = %7B%7D;%0Avar rm = require('./support.js').rm;%0A%0Avar existsSync = require('fs').existsSync %7C%7C require('path').existsSync;
+rm = require('./support.js').rm;%0A
 %0A%0Abe
@@ -690,32 +690,34 @@
 .ok(err.
-message.search(%22
+toString().match(/
 error: '
@@ -738,17 +738,10 @@
 en %5D
-'%22) != -1
+/)
 );%0A 

Check error message with a regex expression