ci: trim appveyor test suite

This commit is contained in:
Filipe Silva 2017-06-02 11:28:27 +01:00
parent 6c6d50eb0d
commit 676cabacce
40 changed files with 236 additions and 9 deletions

View File

@ -12,11 +12,10 @@ install:
test_script:
- node --version
- yarn --version
- yarn test
- node tests\run_e2e.js
- node tests\run_e2e.js --appveyor
build: off
cache:
- node_modules
- "%LOCALAPPDATA%/Yarn"
- "%LOCALAPPDATA%/Yarn"

View File

@ -1,8 +1,14 @@
import {ng} from '../../utils/process';
import {expectFileToMatch} from '../../utils/fs';
import {getGlobalVariable} from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return ng('build', '--base-href', '/myUrl')
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/));
}

View File

@ -4,6 +4,7 @@ import * as fs from 'fs';
import {ng} from '../../utils/process';
import {writeFile} from '../../utils/fs';
import {addImportToModule} from '../../utils/ast';
import {getGlobalVariable} from '../../utils/env';
const OUTPUT_RE = /(main|polyfills|vendor|inline|styles|\d+)\.[a-z0-9]+\.(chunk|bundle)\.(js|css)$/;
@ -44,6 +45,12 @@ function validateHashes(
}
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
let oldHashes: Map<string, string>;
let newHashes: Map<string, string>;
// First, collect the hashes.

View File

@ -7,6 +7,7 @@ import {
writeMultipleFiles
} from '../../utils/fs';
import { expectToFail } from '../../utils/utils';
import { getGlobalVariable } from '../../utils/env';
const imgSvg = `
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
@ -15,6 +16,11 @@ const imgSvg = `
`;
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
// Verify absolute/relative paths in global/component css.
.then(() => writeMultipleFiles({

View File

@ -4,6 +4,11 @@ import {deleteFile, expectFileToExist} from '../../utils/fs';
import {getGlobalVariable} from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
// Skip this in ejected tests.
if (getGlobalVariable('argv').eject) {
return Promise.resolve();

View File

@ -1,10 +1,17 @@
import { ng } from '../../utils/process';
import { expectFileToMatch, writeMultipleFiles } from '../../utils/fs';
import { updateJsonFile } from '../../utils/project';
import { getGlobalVariable } from '../../utils/env';
import { stripIndents } from 'common-tags';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => writeMultipleFiles({
'src/styles.css': 'div { background: url("./assets/more.svg"); }',

View File

@ -2,9 +2,15 @@ import {ng} from '../../utils/process';
import {expectFileToExist} from '../../utils/fs';
import {updateJsonFile} from '../../utils/project';
import {copyFile} from '../../utils/fs';
import {getGlobalVariable} from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => copyFile('src/index.html', 'src/config-index.html'))
.then(() => updateJsonFile('.angular-cli.json', configJson => {

View File

@ -5,6 +5,11 @@ import {getGlobalVariable} from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
// Skip this in ejected tests.
if (getGlobalVariable('argv').eject) {
return Promise.resolve();

View File

@ -1,8 +1,14 @@
import { ng } from '../../utils/process';
import { replaceInFile } from "../../utils/fs";
import { replaceInFile } from '../../utils/fs';
import { getGlobalVariable } from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => replaceInFile('src/app/app.component.ts',
'@Component({',

View File

@ -1,8 +1,14 @@
import {updateTsConfig} from '../../utils/project';
import {ng} from '../../utils/process';
import {getGlobalVariable} from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return updateTsConfig(json => {
json['compilerOptions']['noImplicitAny'] = true;
})

View File

@ -1,6 +1,7 @@
import {stripIndents} from 'common-tags';
import {ng} from '../../utils/process';
import { writeMultipleFiles, expectFileToMatch, expectFileMatchToExist } from '../../utils/fs';
import { getGlobalVariable } from '../../utils/env';
function verifyMedia(css: RegExp, content: RegExp) {
return expectFileMatchToExist('./dist', css)
@ -8,6 +9,11 @@ function verifyMedia(css: RegExp, content: RegExp) {
}
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => writeMultipleFiles({
'src/styles.css': stripIndents`

View File

@ -1,8 +1,14 @@
import { expectFileToMatch } from '../../utils/fs';
import { ng } from '../../utils/process';
import { getGlobalVariable } from '../../utils/env';
import { oneLineTrim } from 'common-tags';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => ng('build'))
// files were created successfully

View File

@ -1,9 +1,15 @@
import {ng} from '../../utils/process';
import {expectFileToExist} from '../../utils/fs';
import {expectToFail} from '../../utils/utils';
import {getGlobalVariable} from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return ng('build')
.then(() => expectFileToExist('dist/main.bundle.js.map'))

View File

@ -6,9 +6,15 @@ import {
import { ng } from '../../../utils/process';
import { updateJsonFile } from '../../../utils/project';
import { expectToFail } from '../../../utils/utils';
import { getGlobalVariable } from '../../../utils/env';
import { oneLineTrim } from 'common-tags';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => writeMultipleFiles({
'src/string-style.css': '.string-style { color: red }',

View File

@ -1,9 +1,15 @@
import * as glob from 'glob';
import { writeFile, expectFileToMatch } from '../../../utils/fs';
import { ng } from '../../../utils/process';
import { getGlobalVariable } from '../../../utils/env';
import { stripIndents } from 'common-tags';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return writeFile('src/styles.css', stripIndents`
/* normal-comment */
/*! important-comment */

View File

@ -1,8 +1,14 @@
import {ng} from '../../../utils/process';
import {createProject} from '../../../utils/project';
import { getGlobalVariable } from '../../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => createProject('routing-project', '--routing'))

View File

@ -2,9 +2,15 @@ import {ng} from '../../../utils/process';
import {createProject} from '../../../utils/project';
import {expectToFail} from '../../../utils/utils';
import {expectGitToBeClean} from '../../../utils/git';
import {getGlobalVariable} from '../../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => createProject('new-project', '--skip-commit'))
.then(() => expectToFail(() => expectGitToBeClean()))

View File

@ -1,8 +1,14 @@
import {createProject} from '../../../utils/project';
import {expectFileNotToExist} from '../../../utils/fs';
import {getGlobalVariable} from '../../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => createProject('new-project-skip-tests', '--skip-tests'))
.then(() => expectFileNotToExist('src/app/app.component.spec.ts'));

View File

@ -1,7 +1,13 @@
import { ng } from '../../utils/process';
import { getGlobalVariable } from '../../utils/env';
import { oneLine } from 'common-tags';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => ng('set', 'lint', '[]'))
.then(() => ng('lint'))

View File

@ -1,9 +1,15 @@
import { ng } from '../../utils/process';
import { writeFile } from '../../utils/fs';
import { expectToFail } from '../../utils/utils';
import { getGlobalVariable } from '../../utils/env';
import { oneLine } from 'common-tags';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => ng('set', 'lint.0.project', ''))
.then(() => ng('lint', '--type-check'))

View File

@ -1,8 +1,14 @@
import { ng } from '../../utils/process';
import { writeFile } from '../../utils/fs';
import { getGlobalVariable } from '../../utils/env';
import { oneLine } from 'common-tags';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
const fileName = 'src/app/foo.ts';
return Promise.resolve()

View File

@ -1,8 +1,14 @@
import { ng } from '../../utils/process';
import { writeFile } from '../../utils/fs';
import { getGlobalVariable } from '../../utils/env';
import { oneLine } from 'common-tags';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
const fileName = 'src/app/foo.ts';
return Promise.resolve()

View File

@ -1,8 +1,14 @@
import { ng } from '../../utils/process';
import { writeFile } from '../../utils/fs';
import { getGlobalVariable } from '../../utils/env';
import { oneLine } from 'common-tags';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
const fileName = 'src/app/foo.ts';
return Promise.resolve()

View File

@ -1,8 +1,14 @@
import { createDir, writeFile } from '../../utils/fs';
import { ng } from '../../utils/process';
import { expectToFail } from '../../utils/utils';
import { getGlobalVariable } from '../../utils/env';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
const fileName = 'src/app/foo/foo.ts';
const nestedConfigContent = `
{

View File

@ -1,8 +1,14 @@
import { ng } from '../../utils/process';
import { expectToFail } from '../../utils/utils';
import { writeFile } from '../../utils/fs';
import { getGlobalVariable } from '../../utils/env';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
const fileName = 'src/app/foo.ts';
const fileContents = `
const ANIMATION_CSS_VALUE_REGEX = 'asda';

View File

@ -1,7 +1,13 @@
import { ng } from '../../utils/process';
import { writeFile } from '../../utils/fs';
import { getGlobalVariable } from '../../utils/env';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
const fileName = 'src/app/foo.ts';
const fileContents = `
const ANIMATION_CSS_VALUE_REGEX = 'asda';

View File

@ -2,9 +2,15 @@ import {expectFileToExist, expectFileToMatch} from '../../utils/fs';
import {updateJsonFile} from '../../utils/project';
import {expectToFail} from '../../utils/utils';
import {ng} from '../../utils/process';
import {getGlobalVariable} from '../../utils/env';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return ng('test', '--single-run', '--code-coverage')
.then(() => expectFileToExist('coverage/src/app'))
.then(() => expectFileToExist('coverage/lcov.info'))

View File

@ -2,8 +2,14 @@ import { request } from '../../utils/http';
import { killAllProcesses } from '../../utils/process';
import { ngServe } from '../../utils/project';
import { updateJsonFile } from '../../utils/project';
import { getGlobalVariable } from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => updateJsonFile('.angular-cli.json', configJson => {
const app = configJson.defaults;

View File

@ -1,8 +1,14 @@
import { killAllProcesses } from '../../utils/process';
import { request } from '../../utils/http';
import { ngServe } from '../../utils/project';
import { getGlobalVariable } from '../../utils/env';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
// check when setup through command line arguments
.then(() => ngServe('--deploy-url', '/deployurl/', '--base-href', '/deployurl/'))

View File

@ -1,5 +1,6 @@
import {ng} from '../../utils/process';
import * as fs from '../../utils/fs';
import {getGlobalVariable} from '../../utils/env';
const options = {
@ -8,6 +9,11 @@ const options = {
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => fs.prependToFile('./src/tsconfig.app.json', '\ufeff', options))
.then(() => fs.prependToFile('./.angular-cli.json', '\ufeff', options))

View File

@ -3,9 +3,15 @@ import { killAllProcesses } from '../../utils/process';
import { ngServe } from '../../utils/project';
import { updateJsonFile } from '../../utils/project';
import { moveFile } from '../../utils/fs';
import { getGlobalVariable } from '../../utils/env';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
// should fallback to config.app[0].index (index.html by default)
return Promise.resolve()
.then(() => ngServe())

View File

@ -2,13 +2,19 @@ import { request } from '../../utils/http';
import { killAllProcesses } from '../../utils/process';
import { ngServe } from '../../utils/project';
import { updateJsonFile } from '../../utils/project';
import { getGlobalVariable } from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => updateJsonFile('.angular-cli.json', configJson => {
const app = configJson.defaults;
app.serve = { ssl: true };
}))
}))
.then(() => ngServe())
.then(() => request('https://localhost:4200/'))
.then(body => {

View File

@ -1,9 +1,15 @@
import { request } from '../../utils/http';
import { killAllProcesses } from '../../utils/process';
import { ngServe } from '../../utils/project';
import { getGlobalVariable } from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => ngServe('--ssl', 'true'))
.then(() => request('https://localhost:4200/'))

View File

@ -3,8 +3,14 @@ import { assetDir } from '../../utils/assets';
import { killAllProcesses } from '../../utils/process';
import { ngServe } from '../../utils/project';
import { updateJsonFile } from '../../utils/project';
import { getGlobalVariable } from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => updateJsonFile('.angular-cli.json', configJson => {
const app = configJson.defaults;
@ -13,7 +19,7 @@ export default function() {
sslKey: assetDir('ssl/server.key'),
sslCert: assetDir('ssl/server.crt')
};
}))
}))
.then(() => ngServe())
.then(() => request('https://localhost:4200/'))
.then(body => {

View File

@ -2,9 +2,15 @@ import { request } from '../../utils/http';
import { assetDir } from '../../utils/assets';
import { killAllProcesses } from '../../utils/process';
import { ngServe } from '../../utils/project';
import { getGlobalVariable } from '../../utils/env';
export default function() {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => ngServe(
'--ssl', 'true',

View File

@ -2,8 +2,14 @@ import { ng, killAllProcesses } from '../../utils/process';
import { expectToFail } from '../../utils/utils';
import { ngServe } from '../../utils/project';
import { updateJsonFile } from '../../utils/project';
import { getGlobalVariable } from '../../utils/env';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => expectToFail(() => ng('e2e', '--no-serve')))
.then(() => updateJsonFile('.angular-cli.json', configJson => {

View File

@ -2,10 +2,16 @@ import { writeMultipleFiles } from '../../utils/fs';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
import { getGlobalVariable } from '../../utils/env';
import { stripIndent } from 'common-tags';
// Make sure asset files are served
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => writeMultipleFiles({
'src/assets/file.txt': 'assets-folder-content',

View File

@ -1,7 +1,13 @@
import { ng } from '../../utils/process';
import { replaceInFile } from '../../utils/fs';
import { getGlobalVariable } from '../../utils/env';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
// Old configs (with the cli preprocessor listed) should still supported.
return Promise.resolve()
.then(() => replaceInFile('karma.conf.js',

View File

@ -2,9 +2,15 @@ import { writeMultipleFiles } from '../../utils/fs';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
import { getGlobalVariable } from '../../utils/env';
import { stripIndent } from 'common-tags';
export default function () {
// Skip this in Appveyor tests.
if (getGlobalVariable('argv').appveyor) {
return Promise.resolve();
}
return Promise.resolve()
.then(() => ng('test', '--watch=false'))
// prepare global scripts test files
@ -30,8 +36,8 @@ export default function () {
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AppComponent ]
TestBed.configureTestingModule({
declarations: [ AppComponent ]
}).compileComponents();
}));

View File

@ -39,7 +39,7 @@ Error.stackTraceLimit = Infinity;
* If unnamed flags are passed in, the list of tests will be filtered to include only those passed.
*/
const argv = minimist(process.argv.slice(2), {
'boolean': ['debug', 'nolink', 'nightly', 'noproject', 'verbose', 'eject'],
'boolean': ['debug', 'nolink', 'nightly', 'noproject', 'verbose', 'eject', 'appveyor'],
'string': ['glob', 'ignore', 'reuse', 'ng-sha', ]
});