Skip to content

Commit

Permalink
fix(ci): correctly report packages spec failures
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva committed Sep 27, 2016
1 parent a9f9976 commit a57773c
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build": "node ./scripts/publish/build.js",
"build:patch": "node ./scripts/patch.js",
"build:packages": "for PKG in packages/*; do echo Building $PKG...; tsc -p $PKG; done",
"test": "npm run test:packages && npm run test:cli",
"test": "npm-run-all -c test:packages test:cli",
"e2e": "npm run test:e2e",
"e2e:nightly": "node tests/e2e_runner.js --nightly",
"mobile_test": "mocha tests/e2e/e2e_workflow.spec.js",
Expand Down
8 changes: 4 additions & 4 deletions packages/ast-tools/src/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ function _addSymbolToNgModuleMetadata(ngModulePath: string, metadataField: strin
position = node.getEnd();
// Get the indentation of the last element, if any.
const text = node.getFullText(source);
if (text.startsWith('\n')) {
toInsert = `,${text.match(/^\n(\r?)\s+/)[0]}${metadataField}: [${symbolName}]`;
if (text.match('^\r?\r?\n')) {
toInsert = `,${text.match(/^\r?\n\s+/)[0]}${metadataField}: [${symbolName}]`;
} else {
toInsert = `, ${metadataField}: [${symbolName}]`;
}
Expand All @@ -235,8 +235,8 @@ function _addSymbolToNgModuleMetadata(ngModulePath: string, metadataField: strin
} else {
// Get the indentation of the last element, if any.
const text = node.getFullText(source);
if (text.startsWith('\n')) {
toInsert = `,${text.match(/^\n(\r?)\s+/)[0]}${symbolName}`;
if (text.match(/^\r?\n/)) {
toInsert = `,${text.match(/^\r?\n(\r?)\s+/)[0]}${symbolName}`;
} else {
toInsert = `, ${symbolName}`;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ast-tools/src/route-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export default [\n { path: 'new-route', component: NewRouteComponent }\n];`);
`\nexport default [\n` +
` { path: 'home', component: HomeComponent,\n` +
` children: [\n` +
` { path: 'about/:id', component: AboutComponent } ` +
` { path: 'about/:id', component: AboutComponent }` +
`\n ]\n }\n];`);
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/ast-tools/src/route-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,11 @@ function addChildPath (parentObject: ts.Node, pathOptions: any, route: string) {
if (childrenNode.length !== 0) {
// add to beginning of children array
pos = childrenNode[0].getChildAt(2).getChildAt(1).pos; // open bracket
newContent = `\n${spaces}${content}, `;
newContent = `\n${spaces}${content},`;
} else {
// no children array, add one
pos = parentObject.getChildAt(2).pos; // close brace
newContent = `,\n${spaces.substring(2)}children: [\n${spaces}${content} ` +
newContent = `,\n${spaces.substring(2)}children: [\n${spaces}${content}` +
`\n${spaces.substring(2)}]\n${spaces.substring(5)}`;
}
return {newContent: newContent, pos: pos};
Expand Down
2 changes: 2 additions & 0 deletions scripts/run-packages-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const projectBaseDir = path.join(__dirname, '../packages');
const jasmine = new Jasmine({ projectBaseDir: projectBaseDir });
jasmine.loadConfig({});
jasmine.addReporter(new JasmineSpecReporter());
// Manually set exit code (needed with custom reporters)
jasmine.onComplete((success) => process.exitCode = !success);

// Run the tests.
const allTests =
Expand Down
3 changes: 1 addition & 2 deletions tests/acceptance/generate-class.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('Acceptance: ng generate class', function () {
after(conf.restore);

beforeEach(function () {
this.timeout(10000);
return tmp.setup('./tmp').then(function () {
process.chdir('./tmp');
}).then(function () {
Expand All @@ -25,8 +26,6 @@ describe('Acceptance: ng generate class', function () {
});

afterEach(function () {
this.timeout(10000);

return tmp.teardown('./tmp');
});

Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/generate-component.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Acceptance: ng generate component', function () {
.then(content => {
// Expect that the app.module contains a reference to my-comp and its import.
expect(content).matches(/import.*MyCompComponent.*from '.\/my-comp\/my-comp.component';/);
expect(content).matches(/declarations:\s*\[[^\]]+?,\n\s+MyCompComponent\n/m);
expect(content).matches(/declarations:\s*\[[^\]]+?,\r?\n\s+MyCompComponent\r?\n/m);
});
});

Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/generate-directive.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Acceptance: ng generate directive', function () {
.then(() => readFile(appModulePath, 'utf-8'))
.then(content => {
expect(content).matches(/import.*\bMyDirDirective\b.*from '.\/my-dir\/my-dir.directive';/);
expect(content).matches(/declarations:\s*\[[^\]]+?,\n\s+MyDirDirective\n/m);
expect(content).matches(/declarations:\s*\[[^\]]+?,\r?\n\s+MyDirDirective\r?\n/m);
});
});

Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/generate-pipe.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Acceptance: ng generate pipe', function () {
.then(() => readFile(appModulePath, 'utf-8'))
.then(content => {
expect(content).matches(/import.*\bMyPipePipe\b.*from '.\/my-pipe.pipe';/);
expect(content).matches(/declarations:\s*\[[^\]]+?,\n\s+MyPipePipe\n/m);
expect(content).matches(/declarations:\s*\[[^\]]+?,\r?\n\s+MyPipePipe\r?\n/m);
});
});

Expand Down

0 comments on commit a57773c

Please sign in to comment.