Skip to content

Commit

Permalink
Merge pull request #43 from AndyOGo/enhancement/run-tests-on-various-os
Browse files Browse the repository at this point in the history
Enhancement/run tests on various os
  • Loading branch information
AndyOGo authored Apr 5, 2017
2 parents f324e17 + 80db41b commit 585eeaa
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .jestrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"testEnvironment": "node",
"cacheDirectory": "/tmp/jest/foo/<path>"
"cacheDirectory": "/tmp/jest/"
}
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
git:
depth: 3

language: node_js

os:
- linux
- osx

node_js:
- "node"

install:
- npm install

before_script:
- npm run lint
- npm run test

script:
- npm run build
- npm run build
39 changes: 39 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# set clone depth
clone_depth: 3

# Test against the latest version of this Node.js version
environment:
matrix:
# node.js
- nodejs_version: "5"
- nodejs_version: "6"

platform:
- x86
- x64

# Maximum number of concurrent jobs for the project
max_jobs: 4

# fix newlines
init:
- git config --global core.autocrlf true

# 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 modules
- npm install

# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
# run tests
- npm run lint
- npm run test

# Don't actually build.
build: off
23 changes: 20 additions & 3 deletions test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import fs from 'fs-extra'
import fsExtra from 'fs-extra'
import path from 'path'
import dirCompare from 'dir-compare'

export const noop = () => {}

export const fs = {
removeSync: source => fsExtra.removeSync(path.normalize(source)),
copySync: (source, target) => fsExtra.copySync(path.normalize(source), path.normalize(target)),
appendFileSync: (source, ...args) => fsExtra.appendFileSync(path.normalize(source), ...args),
existsSync: source => fsExtra.existsSync(path.normalize(source)),
readFileSync: source => fsExtra.readFileSync(path.normalize(source)),
}

export const beforeEachSpec = () => {
fs.removeSync('tmp')
fs.copySync('test/mock', 'tmp/mock')
Expand Down Expand Up @@ -105,7 +114,11 @@ export const compare = (done, source, target, options) => (event, data) => {
[source, target] = data
}

const res = dirCompare.compareSync(source, target, { ...options, compareSize: true, compareContent: true })
const res = dirCompare.compareSync(path.normalize(source), path.normalize(target), {
...options,
compareSize: true,
compareContent: true,
})

expect(res.differences).toBe(0)
expect(res.differencesFiles).toBe(0)
Expand All @@ -121,7 +134,11 @@ export const compare = (done, source, target, options) => (event, data) => {

export const compareDir = (done, source, target, options = {}) => (event) => {
if (event) {
const res = dirCompare.compareSync(source, target, { ...options, compareSize: true, compareContent: true })
const res = dirCompare.compareSync(path.normalize(source), path.normalize(target), {
...options,
compareSize: true,
compareContent: true,
})

expect(res.differences).toBe(0)
expect(res.differencesFiles).toBe(0)
Expand Down
22 changes: 12 additions & 10 deletions test/lib/resolve-target.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from 'path'

import resolveTarget from '../../src/lib/resolve-target'

describe('lib/resolve-target', () => {
Expand All @@ -12,15 +14,15 @@ describe('lib/resolve-target', () => {
const resolveTargetFromBases = resolveTarget(bases)
const target = 'dist'

expect(resolveTargetFromBases('test/a.txt', target)).toEqual('dist/a.txt')
expect(resolveTargetFromBases('test/lib/a.txt', target)).toEqual('dist/lib/a.txt')
expect(resolveTargetFromBases('test/mock/a.txt', target)).toEqual('dist/a.txt')
expect(resolveTargetFromBases('test/mock/lib/a.txt', target)).toEqual('dist/lib/a.txt')
expect(resolveTargetFromBases('test/mock/foo/a.txt', target)).toEqual('dist/a.txt')
expect(resolveTargetFromBases('test/mock/foo/lib/a.txt', target)).toEqual('dist/lib/a.txt')
expect(resolveTargetFromBases('test/mock/bar/a.txt', target)).toEqual('dist/a.txt')
expect(resolveTargetFromBases('test/mock/bar/lib/a.txt', target)).toEqual('dist/lib/a.txt')
expect(resolveTargetFromBases('test/mock/@org/a.txt', target)).toEqual('dist/a.txt')
expect(resolveTargetFromBases('test/mock/@org/lib/a.txt', target)).toEqual('dist/lib/a.txt')
expect(resolveTargetFromBases('test/a.txt', target)).toEqual(path.normalize('dist/a.txt'))
expect(resolveTargetFromBases('test/lib/a.txt', target)).toEqual(path.normalize('dist/lib/a.txt'))
expect(resolveTargetFromBases('test/mock/a.txt', target)).toEqual(path.normalize('dist/a.txt'))
expect(resolveTargetFromBases('test/mock/lib/a.txt', target)).toEqual(path.normalize('dist/lib/a.txt'))
expect(resolveTargetFromBases('test/mock/foo/a.txt', target)).toEqual(path.normalize('dist/a.txt'))
expect(resolveTargetFromBases('test/mock/foo/lib/a.txt', target)).toEqual(path.normalize('dist/lib/a.txt'))
expect(resolveTargetFromBases('test/mock/bar/a.txt', target)).toEqual(path.normalize('dist/a.txt'))
expect(resolveTargetFromBases('test/mock/bar/lib/a.txt', target)).toEqual(path.normalize('dist/lib/a.txt'))
expect(resolveTargetFromBases('test/mock/@org/a.txt', target)).toEqual(path.normalize('dist/a.txt'))
expect(resolveTargetFromBases('test/mock/@org/lib/a.txt', target)).toEqual(path.normalize('dist/lib/a.txt'))
})
})
4 changes: 1 addition & 3 deletions test/sync.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import fs from 'fs-extra'

import syncGlob from '../src/index'
import { beforeEachSpec, afterAllSpecs, awaitMatch, compare, compareDir } from './helpers'
import { beforeEachSpec, afterAllSpecs, awaitMatch, compare, compareDir, fs } from './helpers'

const watch = true

Expand Down
4 changes: 1 addition & 3 deletions test/transform.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import fs from 'fs-extra'

import syncGlob from '../src/index'
import { beforeEachSpec, afterAllSpecs, awaitMatch } from './helpers'
import { beforeEachSpec, afterAllSpecs, awaitMatch, fs } from './helpers'

describe('node-sync-glob transform', () => {
beforeEach(beforeEachSpec)
Expand Down

0 comments on commit 585eeaa

Please sign in to comment.