recover fixtures

Revert "build: update build files"

This reverts commit a35fad015d.
This commit is contained in:
Kelvin Jin 2018-03-01 11:34:17 -08:00
parent b88260045a
commit d3d91e1c36
11 changed files with 113 additions and 6 deletions

View File

@ -55,15 +55,16 @@ function loadGulpTasksWithPrefix(path: string, prefix: string) {
['./packages/grpc-native-core/gulpfile', 'native.core'],
['./packages/grpc-surface/gulpfile', 'surface'],
['./packages/grpc-protobufjs/gulpfile', 'protobuf'],
['./test/gulpfile', 'internal.test'],
].forEach((args) => loadGulpTasksWithPrefix(args[0], args[1]));
const root = __dirname;
gulp.task('install.all', 'Install dependencies for all subdirectory packages',
['js.install', 'js.core.install', 'native.core.install', 'surface.install', 'health-check.install', 'protobuf.install']);
['js.install', 'js.core.install', 'native.core.install', 'surface.install', 'health-check.install', 'protobuf.install', 'internal.test.install']);
gulp.task('install.all.windows', 'Install dependencies for all subdirectory packages for MS Windows',
['js.core.install', 'native.core.install.windows', 'surface.install', 'health-check.install', 'protobuf.install']);
['js.core.install', 'native.core.install.windows', 'surface.install', 'health-check.install', 'protobuf.install', 'internal.test.install']);
gulp.task('lint', 'Emit linting errors in source and test files',
['js.core.lint', 'native.core.lint']);
@ -95,10 +96,10 @@ gulp.task('clean', 'Delete generated files', ['js.core.clean', 'native.core.clea
gulp.task('clean.all', 'Delete all files created by tasks',
['js.core.clean.all', 'native.core.clean.all', 'health-check.clean.all',
'js.clean.all', 'native.clean.all', 'protobuf.clean.all']);
'internal.test.clean.all', 'js.clean.all', 'native.clean.all', 'protobuf.clean.all']);
gulp.task('native.test.only', 'Run tests of native code without rebuilding anything',
['native.core.test', 'health-check.test']);
['native.core.test', 'internal.test.test', 'health-check.test']);
gulp.task('native.test', 'Run tests of native code', (callback) => {
runSequence('build', 'native.test.only', callback);

View File

@ -18,6 +18,7 @@
'use strict';
require('../../../test/fixtures/native_native.js');
var interop_server = require('../../../test/interop/interop_server.js');
var interop_client = require('../../../test/interop/interop_client.js');

39
test/any_grpc.js Normal file
View File

@ -0,0 +1,39 @@
// TODO: Instead of attempting to expose both implementations of gRPC in
// a single object, the tests should be re-written in a way that makes it clear
// that two separate implementations are being tested against one another.
const _ = require('lodash');
function getImplementation(globalField) {
if (global[globalField] !== 'js' && global[globalField] !== 'native') {
throw new Error([
`Invalid value for global.${globalField}: ${global.globalField}.`,
'If running from the command line, please --require a fixture first.'
].join(' '));
}
const impl = global[globalField];
return {
surface: require(`../packages/grpc-${impl}`),
pjson: require(`../packages/grpc-${impl}/package.json`),
core: require(`../packages/grpc-${impl}-core`),
corePjson: require(`../packages/grpc-${impl}-core/package.json`)
};
}
const clientImpl = getImplementation('_client_implementation');
const serverImpl = getImplementation('_server_implementation');
// We export a "merged" gRPC API by merging client and server specified
// APIs together. Any function that is unspecific to client/server defaults
// to client-side implementation.
// This object also has a test-only field from which details about the
// modules may be read.
module.exports = Object.assign({
'$implementationInfo': {
client: clientImpl,
server: serverImpl
}
}, clientImpl.surface, _.pick(serverImpl.surface, [
'Server',
'ServerCredentials'
]));

2
test/fixtures/js_js.js vendored Normal file
View File

@ -0,0 +1,2 @@
global._server_implementation = 'native';
global._client_implementation = 'js';

2
test/fixtures/js_native.js vendored Normal file
View File

@ -0,0 +1,2 @@
global._server_implementation = 'js';
global._client_implementation = 'native';

2
test/fixtures/native_js.js vendored Normal file
View File

@ -0,0 +1,2 @@
global._server_implementation = 'js';
global._client_implementation = 'native';

2
test/fixtures/native_native.js vendored Normal file
View File

@ -0,0 +1,2 @@
global._server_implementation = 'native';
global._client_implementation = 'native';

38
test/gulpfile.js Normal file
View File

@ -0,0 +1,38 @@
/*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
const _gulp = require('gulp');
const help = require('gulp-help');
const mocha = require('gulp-mocha');
const execa = require('execa');
const path = require('path');
const del = require('del');
const linkSync = require('../util').linkSync;
// gulp-help monkeypatches tasks to have an additional description parameter
const gulp = help(_gulp);
const testDir = __dirname;
const apiTestDir = path.resolve(testDir, 'api');
gulp.task('install', 'Install test dependencies', () => {
return execa('npm', ['install'], {cwd: testDir, stdio: 'inherit'});
});
gulp.task('clean.all', 'Delete all files created by tasks', () => {});
gulp.task('test', 'Run API-level tests', () => {});

View File

@ -20,7 +20,7 @@
var fs = require('fs');
var path = require('path');
var grpc = require('../../packages/grpc-native-core');
var grpc = require('../any_grpc')['$implementationInfo'].client.surface;
var testProto = grpc.load({
root: __dirname + '/../../packages/grpc-native-core/deps/grpc',
file: 'src/proto/grpc/testing/test.proto'}).grpc.testing;

View File

@ -22,7 +22,7 @@ var fs = require('fs');
var path = require('path');
var _ = require('lodash');
var AsyncDelayQueue = require('./async_delay_queue');
var grpc = require('../../packages/grpc-native-core');
var grpc = require('../any_grpc')['$implementationInfo'].server.surface;
var testProto = grpc.load({
root: __dirname + '/../../packages/grpc-native-core/deps/grpc',
file: 'src/proto/grpc/testing/test.proto'}).grpc.testing;

20
test/package.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "grpc-node-test",
"version": "0.1.0",
"description": "Dummy package for the grpc-node repository tests",
"private": true,
"keywords": [],
"author": {
"name": "Google Inc."
},
"license": "Apache-2.0",
"contributors": [
{
"name": "Google Inc."
}
],
"dependencies": {
"google-auth-library": "^0.9.2",
"lodash": "^4.17.4"
}
}