Skip to content

Test perf #2472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ dependencies:
- "docs/node_modules"
override:
- npm i
# - gulp build # npm 5 won't run `prepublish` on `npm i`, we will need to re-enable this once we go to a Node version using npm 5+
- cd docs && npm i
- gulp updateFixtures:test
- gulp installFixtures
post:
- gulp build
- cd test/fixtures && npm i && npm run-script update-webdriver

test:
override:
Expand Down
37 changes: 21 additions & 16 deletions src/test/endpoint.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';
import path from 'path';
import fs from 'fs';
import _ from 'lodash';
import Promise from 'bluebird';
import helpers from 'yeoman-test';
import assert from 'yeoman-assert';
Expand All @@ -10,7 +9,6 @@ import * as getExpectedFiles from './get-expected-files';
import {
copyAsync,
runCmd,
assertOnlyFiles,
readJSON,
runGen
} from './test-helpers';
Expand Down Expand Up @@ -67,27 +65,34 @@ function runEndpointGen(name, opt={}) {
});
}

let eslintCmd = path.join(TEST_DIR, '/fixtures/node_modules/.bin/eslint');
function testFile(command, _path) {
_path = path.normalize(_path);
return fs.accessAsync(_path, fs.R_OK).then(() => {
return runCmd(`${command} ${_path}`);
});
const ESLINT_CMD = path.join(TEST_DIR, '/fixtures/node_modules/.bin/eslint');

/**
* @param {string[]} files
* @param {string} [flags]
*/
function eslintFiles(files, flags = '') {
return runCmd(`${ESLINT_CMD} ${flags} ${files.join(' ')}`);
}

function eslintDir(dir, name, folder) {
if(!folder) folder = name;
let endpointDir = path.join(dir, 'server/api', folder);
let files = fs.readdirAsync(endpointDir);

let regFiles = fs.readdirAsync(endpointDir)
let regFiles = files
.then(files => files.filter(file => minimatch(file, '**/!(*.spec|*.mock|*.integration).js', {dot: true})))
.map(file => testFile(eslintCmd, path.join('./server/api/', folder, file)));
.then(files => files.map(file => path.join('./server/api/', folder, file)));

let specFiles = fs.readdirAsync(endpointDir)
let specFiles = files
.then(files => files.filter(file => minimatch(file, '**/+(*.spec|*.mock|*.integration).js', {dot: true})))
.map(file => testFile(`${eslintCmd} --env node,es6,mocha --global sinon,expect`, path.join('./server/api/', folder, file)));
.then(files => files.map(file => path.join('./server/api/', folder, file)));

let regLint = regFiles.then(files => eslintFiles(files));

let specLint = specFiles.then(files => eslintFiles(files, '--env node,es6,mocha --global sinon,expect'));

return Promise.all([regFiles, specFiles]);
return Promise.all([regLint, specLint]);
}

var config;
Expand All @@ -109,7 +114,7 @@ describe('angular-fullstack:endpoint', function() {
]);
});

describe(`with a generated endpont 'foo'`, function() {
describe(`with a generated endpoint 'foo'`, function() {
var dir;
beforeEach(function() {
return runEndpointGen('foo', {config: config['generator-angular-fullstack']}).then(_dir => {
Expand All @@ -131,7 +136,7 @@ describe('angular-fullstack:endpoint', function() {
});
});

describe('with a generated capitalized endpont', function() {
describe('with a generated capitalized endpoint', function() {
var dir;
beforeEach(function() {
return runEndpointGen('Foo', {config: config['generator-angular-fullstack']}).then(_dir => {
Expand All @@ -153,7 +158,7 @@ describe('angular-fullstack:endpoint', function() {
});
});

describe('with a generated path name endpont', function() {
describe('with a generated path name endpoint', function() {
var dir;
beforeEach(function() {
return runEndpointGen('foo/bar', {config: config['generator-angular-fullstack']}).then(_dir => {
Expand Down
26 changes: 13 additions & 13 deletions src/test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('angular-fullstack:app', function() {
describe('default settings', function() {
var dir;

beforeEach(function() {
before(function() {
return runGen(defaultOptions).then(_dir => {
dir = _dir;
});
Expand All @@ -83,7 +83,7 @@ describe('angular-fullstack:app', function() {
});

describe('with a generated endpoint', function() {
beforeEach(function() {
before(function() {
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
return runEndpointGen('foo', {config: config['generator-angular-fullstack']});
});
Expand All @@ -95,9 +95,9 @@ describe('angular-fullstack:app', function() {
});

describe('with a generated capitalized endpoint', function() {
beforeEach(function() {
before(function() {
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
return runEndpointGen('Foo', {config: config['generator-angular-fullstack']});
return runEndpointGen('Bar', {config: config['generator-angular-fullstack']});
});
});

Expand All @@ -107,9 +107,9 @@ describe('angular-fullstack:app', function() {
});

describe('with a generated path name endpoint', function() {
beforeEach(function() {
before(function() {
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
return runEndpointGen('foo/bar', {config: config['generator-angular-fullstack']});
return runEndpointGen('foo/baz', {config: config['generator-angular-fullstack']});
});
});

Expand All @@ -119,9 +119,9 @@ describe('angular-fullstack:app', function() {
});

describe('with a generated snake-case endpoint', function() {
beforeEach(function() {
before(function() {
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
return runEndpointGen('foo-bar', {config: config['generator-angular-fullstack']});
return runEndpointGen('foo-boo', {config: config['generator-angular-fullstack']});
});
});

Expand Down Expand Up @@ -231,7 +231,7 @@ describe('angular-fullstack:app', function() {
});

describe('with a generated endpoint', function() {
beforeEach(function() {
before(function() {
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
return runEndpointGen('foo', {config: config['generator-angular-fullstack']});
});
Expand Down Expand Up @@ -276,7 +276,7 @@ describe('angular-fullstack:app', function() {
};
this.retries(3); // Sequelize seems to be quite flaky

beforeEach(function() {
before(function() {
return runGen(testOptions).then(_dir => {
dir = _dir;
lintResult = runCmd('gulp lint:scripts');
Expand All @@ -303,7 +303,7 @@ describe('angular-fullstack:app', function() {
});

describe.skip('with a generated endpoint', function() {
beforeEach(function() {
before(function() {
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
return runEndpointGen('foo', {config: config['generator-angular-fullstack']});
});
Expand Down Expand Up @@ -348,7 +348,7 @@ describe('angular-fullstack:app', function() {
uibootstrap: false
};

beforeEach(function() {
before(function() {
return runGen(testOptions, {options: {devPort: '9005'}}).then(_dir => {
dir = _dir;
lintResult = runCmd('gulp lint:scripts');
Expand Down Expand Up @@ -376,7 +376,7 @@ describe('angular-fullstack:app', function() {
});

describe('with a generated endpoint', function() {
beforeEach(function() {
before(function() {
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
return runEndpointGen('foo', {config: config['generator-angular-fullstack']});
});
Expand Down