Skip to content

Commit

Permalink
test: fix failing tests which were not shown
Browse files Browse the repository at this point in the history
Previously when an unhandled error occured Bazel would mark the suit as passed instead of failed.

See: https://togithub.com/bazelbuild/rules_nodejs/commit/3c4ef58
(cherry picked from commit f16fa9c)
  • Loading branch information
alan-agius4 committed Jun 10, 2021
1 parent a928b5b commit 3a0c62c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 90 deletions.
5 changes: 5 additions & 0 deletions packages/angular/cli/BUILD.bazel
Expand Up @@ -84,10 +84,15 @@ ts_library(
"@npm//@types/rimraf",
"@npm//@types/semver",
"@npm//@types/uuid",
"@npm//@yarnpkg/lockfile",
"@npm//ansi-colors",
"@npm//ini",
"@npm//jsonc-parser",
"@npm//npm-package-arg",
"@npm//open",
"@npm//ora",
"@npm//pacote",
"@npm//semver",
],
)

Expand Down
82 changes: 1 addition & 81 deletions packages/angular/cli/src/commands/update/schematic/index_spec.ts
Expand Up @@ -34,7 +34,7 @@ describe('angularMajorCompatGuarantee', () => {
describe('@schematics/update', () => {
const schematicRunner = new SchematicTestRunner(
'@schematics/update',
require.resolve('../collection.json'),
require.resolve('./collection.json'),
);
let host: virtualFs.test.TestHost;
let appTree: UnitTestTree = new UnitTestTree(new HostTree());
Expand Down Expand Up @@ -133,22 +133,6 @@ describe('@schematics/update', () => {
map((tree) => {
const packageJson = JSON.parse(tree.readContent('/package.json'));
expect(packageJson['dependencies']['@angular/core'][0]).toBe('6');

// Check install task.
expect(schematicRunner.tasks).toEqual([
{
name: 'node-package',
options: jasmine.objectContaining({
command: 'install',
}),
},
{
name: 'run-schematic',
options: jasmine.objectContaining({
name: 'migrate',
}),
},
]);
}),
)
.toPromise()
Expand Down Expand Up @@ -190,22 +174,6 @@ describe('@schematics/update', () => {
expect(packageJson['dependencies']['rxjs'][0]).toBe('6');
expect(packageJson['dependencies']['typescript'][0]).toBe('2');
expect(packageJson['dependencies']['typescript'][2]).not.toBe('4');

// Check install task.
expect(schematicRunner.tasks).toEqual([
{
name: 'node-package',
options: jasmine.objectContaining({
command: 'install',
}),
},
{
name: 'run-schematic',
options: jasmine.objectContaining({
name: 'migrate',
}),
},
]);
}),
)
.toPromise()
Expand Down Expand Up @@ -238,16 +206,6 @@ describe('@schematics/update', () => {
const deps = packageJson['dependencies'];
expect(deps['@angular-devkit-tests/update-package-group-1']).toBe('1.2.0');
expect(deps['@angular-devkit-tests/update-package-group-2']).toBe('2.0.0');

// Check install task.
expect(schematicRunner.tasks).toEqual([
{
name: 'node-package',
options: jasmine.objectContaining({
command: 'install',
}),
},
]);
}),
)
.toPromise();
Expand Down Expand Up @@ -279,16 +237,6 @@ describe('@schematics/update', () => {
expect(packageJson['dependencies']['@angular-devkit-tests/update-migrations']).toBe(
'1.0.0',
);

// Check install task.
expect(schematicRunner.tasks).toEqual([
{
name: 'run-schematic',
options: jasmine.objectContaining({
name: 'migrate',
}),
},
]);
}),
)
.toPromise()
Expand Down Expand Up @@ -321,20 +269,6 @@ describe('@schematics/update', () => {
expect(packageJson['dependencies']['@angular-devkit-tests/update-migrations']).toBe(
'1.6.0',
);

// Check install task.
expect(schematicRunner.tasks).toEqual([
{
name: 'run-schematic',
options: jasmine.objectContaining({
name: 'migrate',
options: jasmine.objectContaining({
from: '0.1.2',
to: '1.6.0',
}),
}),
},
]);
}),
)
.toPromise()
Expand Down Expand Up @@ -367,20 +301,6 @@ describe('@schematics/update', () => {
expect(packageJson['dependencies']['@angular-devkit-tests/update-migrations']).toBe(
'1.6.0',
);

// Check install task.
expect(schematicRunner.tasks).toEqual([
{
name: 'run-schematic',
options: jasmine.objectContaining({
name: 'migrate',
options: jasmine.objectContaining({
from: '0.0.0',
to: '1.6.0',
}),
}),
},
]);
}),
)
.toPromise()
Expand Down
1 change: 1 addition & 0 deletions packages/angular_devkit/build_angular/BUILD.bazel
Expand Up @@ -109,6 +109,7 @@ ts_library(
"@npm//@angular/localize",
"@npm//@angular/service-worker",
"@npm//@babel/core",
"@npm//@babel/plugin-transform-async-to-generator",
"@npm//@babel/plugin-transform-runtime",
"@npm//@babel/preset-env",
"@npm//@babel/runtime",
Expand Down
2 changes: 0 additions & 2 deletions packages/angular_devkit/core/node/BUILD.bazel
Expand Up @@ -53,8 +53,6 @@ ts_library(
jasmine_node_test(
name = "node_test",
srcs = [":node_test_lib"],
# TODO: Audit tests to determine if tests can be run in RBE environments
local = True,
deps = [
"@npm//chokidar",
"@npm//temp",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/core/node/host.ts
Expand Up @@ -89,7 +89,7 @@ export class NodeJsAsyncHost implements virtualFs.Host<Stats> {

write(path: Path, content: virtualFs.FileBuffer): Observable<void> {
return observableFrom(fsPromises.mkdir(getSystemPath(dirname(path)), { recursive: true })).pipe(
mergeMap(() => fsPromises.writeFile(getSystemPath(path), content)),
mergeMap(() => fsPromises.writeFile(getSystemPath(path), new Uint8Array(content))),
);
}

Expand Down
9 changes: 4 additions & 5 deletions packages/angular_devkit/core/node/host_spec.ts
Expand Up @@ -34,11 +34,10 @@ describe('NodeJsAsyncHost', () => {
afterEach((done) => host.delete(normalize('/')).toPromise().then(done, done.fail));

it('should get correct result for exists', async () => {
let isExists = await host.exists(normalize('not-found')).toPromise();
expect(isExists).toBe(false);
await host.write(normalize('not-found'), virtualFs.stringToFileBuffer('content')).toPromise();
isExists = await host.exists(normalize('not-found')).toPromise();
expect(isExists).toBe(true);
const filePath = normalize('not-found');
expect(await host.exists(filePath).toPromise()).toBeFalse();
await host.write(filePath, virtualFs.stringToFileBuffer('content')).toPromise();
expect(await host.exists(filePath).toPromise()).toBeTrue();
});

linuxOnlyIt(
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/core/src/virtual-fs/host/buffer.ts
Expand Up @@ -34,7 +34,7 @@ export function stringToFileBuffer(str: string): FileBuffer {
return ab;
} else if (typeof TextEncoder !== 'undefined') {
// Modern browsers implement TextEncode.
return new TextEncoder('utf-8').encode(str).buffer as ArrayBuffer;
return new TextEncoder('utf-8').encode(str).buffer;
} else {
// Slowest method but sure to be compatible with every platform.
const buf = new ArrayBuffer(str.length * 2); // 2 bytes for each char
Expand Down

0 comments on commit 3a0c62c

Please sign in to comment.