Skip to content

Commit

Permalink
Set up windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Loring committed May 6, 2016
1 parent e331cdd commit 544e807
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 14 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:

before_install:
- mysql -e "create database IF NOT EXISTS test;" -uroot
- echo "USE mysql;\nUPDATE user SET password=PASSWORD('Password12!') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root

env:
- GCLOUD_PROJECT=0 CXX=g++-4.8
Expand Down
40 changes: 40 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Test against this version of Node.js
environment:
matrix:
# node.js
# Testing against LTS/Current, 0.12 intentionally omitted to reduce maintenance burden
- nodejs_version: "4"
- nodejs_version: "6"

services:
- mongodb
- mysql

# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version
# Install the Redis
- nuget install redis-64 -excludeversion
- redis-64\tools\redis-server.exe --service-install
- redis-64\tools\redis-server.exe --service-start
# install modules
- npm install
# Skip grpc due to https://github.com/nodejs/node/issues/4932
- ps: ForEach ($fix in Get-ChildItem -Directory test/hooks/fixtures/*) { if ($fix -notmatch 'grpc*') { cd $fix; npm install --silent } }
- ps: cd ..\..\..\..
# set GCLOUD_PROJECT
- SET GCLOUD_PROJECT=0

before_test:
- SET PATH=C:\Program Files\MySql\MySQL Server 5.7\bin;%PATH%
- mysqladmin --host=localhost --user=root --password=Password12! create test

# Post-install test scripts.
test_script:
# run tests
- ps: node_modules/.bin/mocha test test\hooks --timeout 4000 --R
- ps: ForEach ($test in Get-ChildItem test/standalone/test-*.js) { if ($test -notmatch 'grpc*') { node_modules/.bin/mocha $test --timeout 4000 --R; if ($lastexitcode -ne 0) { exit 1 } } }

# Don't actually build using MSBuild
build: off
4 changes: 3 additions & 1 deletion lib/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ function findModuleVersion(modulePath, load) {

function checkLoadedModules(logger) {
for (var moduleName in toInstrument) {
var regex = new RegExp('node_modules' + path.sep + moduleName + path.sep);
// \\ is benign on unix and escapes \\ on windows
var regex = new RegExp('node_modules\\' + path.sep + moduleName +
'\\' + path.sep);
for (var file in require.cache) {
if (file.match(regex)) {
logger.error(moduleName + ' tracing might not work as ' + file +
Expand Down
14 changes: 14 additions & 0 deletions test/hooks/test-trace-express.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,22 @@ var common = require('./common.js');
var express = require('./fixtures/express4');

var server;
var write;

describe('test-trace-express', function() {
before(function() {
// Mute stderr to satiate appveyor
write = process.stderr.write;
process.stderr.write = function(c, e, cb) {
assert.equal(c, 1729);
if (cb) {
cb();
}
};
});
after(function() {
process.stderr.write = write;
});
afterEach(function() {
common.cleanTraces();
server.close();
Expand Down
4 changes: 2 additions & 2 deletions test/hooks/test-trace-mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ var mysql = require('./fixtures/mysql2');

var pool = mysql.createPool({
host : 'localhost',
user : 'travis',
password : '',
user : 'root',
password : 'Password12!',
database : 'test'
});
var connection;
Expand Down
14 changes: 14 additions & 0 deletions test/hooks/test-trace-restify.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,25 @@ var versions = {
};

var server;
var write;

Object.keys(versions).forEach(function(version) {
var restify = versions[version];

describe(version, function() {
before(function() {
// Mute stderr to satiate appveyor
write = process.stderr.write;
process.stderr.write = function(c, e, cb) {
assert(c.indexOf('DeprecationWarning') !== -1);
if (cb) {
cb();
}
};
});
after(function() {
process.stderr.write = write;
});
afterEach(function() {
common.cleanTraces();
server.close();
Expand Down
18 changes: 16 additions & 2 deletions test/standalone/test-hooks-no-project-num.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,22 @@
delete process.env.GCLOUD_PROJECT;

var assert = require('assert');
var write;

describe('should not break without project num', function() {
before(function() {
// Mute stderr to satiate appveyor
write = process.stderr.write;
process.stderr.write = function(c, e, cb) {
assert(c.indexOf('DeprecationWarning') !== -1);
if (cb) {
cb();
}
};
});
after(function() {
process.stderr.write = write;
});
it('mongo', function(done) {
var agent = require('../..').start();
var mongoose = require('../hooks/fixtures/mongoose4');
Expand Down Expand Up @@ -123,8 +137,8 @@ describe('should not break without project num', function() {
var mysql = require('../hooks/fixtures/mysql2');
var pool = mysql.createPool({
host : 'localhost',
user : 'travis',
password : '',
user : 'root',
password : 'Password12!',
database : 'test'
});
pool.getConnection(function(err, conn) {
Expand Down
4 changes: 2 additions & 2 deletions test/standalone/test-hooks-sample-warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ describe('express + dbs', function() {
app.get('/', function (req, res) {
var pool = mysql.createPool({
host : 'localhost',
user : 'travis',
password : '',
user : 'root',
password : 'Password12!',
database : 'test'
});
http.get('http://www.google.com/', function() {
Expand Down
4 changes: 2 additions & 2 deletions test/standalone/test-mysql-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ if (semver.satisfies(process.version, '>=4')) {
register: require('../hooks/fixtures/hapi-plugin-mysql3'),
options: {
host : 'localhost',
user : 'travis',
password : '',
user : 'root',
password : 'Password12!',
database : 'test'
}
}, function (err) {
Expand Down
20 changes: 15 additions & 5 deletions test/test-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

var assert = require('assert');
var util = require('../lib/util.js');
var path = require('path');

var o = {
a: 5,
Expand Down Expand Up @@ -46,14 +47,23 @@ describe('util.stringifyPrefix', function() {

describe('util.packageNameFromPath', function() {
it('should work for standard packages', function() {
var path = './appengine-sails/node_modules/testmodule/index.js';
assert.equal(util.packageNameFromPath(path),
var p = path.join('.',
'appengine-sails',
'node_modules',
'testmodule',
'index.js');
assert.equal(util.packageNameFromPath(p),
'testmodule');
});

it('should work for namespaced packages', function() {
var path = './appengine-sails/node_modules/@google/cloud-trace/index.js';
assert.equal(util.packageNameFromPath(path),
'@google/cloud-trace');
var p = path.join('.',
'appengine-sails',
'node_modules',
'@google',
'cloud-trace',
'index.js');
assert.equal(util.packageNameFromPath(p),
path.join('@google','cloud-trace'));
});
});

0 comments on commit 544e807

Please sign in to comment.