<commit_before><?php
/*
 * Copyright 2020 Google LLC
 *
 * 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
 *
 *     https://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.
 */
declare(strict_types=1);

namespace Google\Generator\IntegrationTests;

require __DIR__ . '/../vendor/autoload.php';
error_reporting(E_ALL);

// Initial integration test.
// Compare output of monolith and micro generators.
// They should match except for whitespace and trailing commas.

$ok = true;
// Generate and compare test APIs.
$ok = processDiff(Invoker::invoke('tests/ProtoTests/Basic/basic.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/BasicLro/basic-lro.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/BasicPaginated/basic-paginated.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/BasicBidiStreaming/basic-bidi-streaming.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/BasicServerStreaming/basic-server-streaming.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/BasicClientStreaming/basic-client-streaming.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/ResourceNames/resource-names.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/ProtoDocs/proto-docs.proto')) ? $ok : false;
// TODO: Re-enable when monolith updated.
// $ok = processDiff(Invoker::invoke('tests/ProtoTests/RoutingHeaders/routing-headers.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/Keywords/keywords.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/AllTypes/all-types.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke(
    'tests/ProtoTests/GrpcServiceConfig/*.proto',
    'testing.grpcserviceconfig',
    'tests/ProtoTests/GrpcServiceConfig/grpc-service-config_gapic.yaml',
    'tests/ProtoTests/GrpcServiceConfig/grpc-service-config.yaml',
    'tests/ProtoTests/GrpcServiceConfig/grpc-service-config.json'
)) ? $ok : false;

// Generate and compare a real APIs.
// TODO: Real API tests may be more suitable as their own integration test.
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/accessapproval/v1/*.proto',
    'google.cloud.accessapproval.v1',
    'googleapis/google/cloud/accessapproval/v1/accessapproval_gapic.yaml',
    'googleapis/google/cloud/accessapproval/v1/accessapproval_v1.yaml',
    'googleapis/google/cloud/accessapproval/v1/accessapproval_grpc_service_config.json'
)) ? $ok : false;
// TODO: googleapis/google/cloud/apigateway/v1/ doesn't have a gapic_config, so monolith crashes
// $ok = processDiff(Invoker::invoke(
//     'googleapis/google/cloud/apigateway/v1/*.proto',
//     'google.cloud.apigateway.v1',
//     null,
//     'googleapis/google/cloud/apigateway/v1/apigateway_v1.yaml',
//     'googleapis/google/cloud/apigateway/v1/apigateway_grpc_service_config.json'
// )) ? $ok : false;
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/asset/v1/*.proto',
    'google.cloud.asset.v1',
    'googleapis/google/cloud/asset/v1/cloudasset_gapic.yaml',
    'googleapis/google/cloud/asset/v1/cloudasset_v1.yaml',
    'googleapis/google/cloud/asset/v1/cloudasset_grpc_service_config.json'
)) ? $ok : false;
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/automl/v1/*.proto googleapis/google/cloud/common_resources.proto',
    'google.cloud.automl.v1',
    'googleapis/google/cloud/automl/v1/automl_gapic.yaml',
    'googleapis/google/cloud/automl/v1/automl_v1.yaml',
    'googleapis/google/cloud/automl/v1/automl_grpc_service_config.json'
)) ? $ok : false;
// TODO: BigQuery
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/billing/v1/*.proto googleapis/google/cloud/common_resources.proto',
    'google.cloud.billing.v1',
    'googleapis/google/cloud/billing/v1/cloud_billing_gapic.yaml',
    'googleapis/google/cloud/billing/v1/cloudbilling.yaml',
    'googleapis/google/cloud/billing/v1/cloud_billing_grpc_service_config.json'
)) ? $ok : false;
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/billing/budgets/v1/*.proto googleapis/google/cloud/common_resources.proto',
    'google.cloud.billing.budgets.v1',
    'googleapis/google/cloud/billing/budgets/v1/billingbudget_gapic.yaml',
    'googleapis/google/cloud/billing/budgets/v1/billingbudgets.yaml',
    'googleapis/google/cloud/billing/budgets/v1/billingbudgets_grpc_service_config.json'
)) ? $ok : false;
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/channel/v1/*.proto googleapis/google/cloud/common_resources.proto',
    'google.cloud.channel.v1',
    'googleapis/google/cloud/channel/v1/cloudchannel_gapic.yaml',
    'googleapis/google/cloud/channel/v1/cloudchannel_v1.yaml',
    'googleapis/google/cloud/channel/v1/cloudchannel_grpc_service_config.json'
)) ? $ok : false;
// Inconsistent PHP namespace casing between monolith and micro.
// Micro-generator gets PHP namespace from proto; monolith gets it from service config, which is missing for this API.
// $ok = processDiff(Invoker::invoke(
//     'googleapis/google/cloud/datacatalog/v1/*.proto googleapis/google/cloud/common_resources.proto',
//     'google.cloud.datacatalog.v1',
//     'googleapis/google/cloud/datacatalog/v1/datacatalog_gapic.yaml',
//     'googleapis/google/cloud/datacatalog/v1/datacatalog_v1.yaml',
//     'googleapis/google/cloud/datacatalog/v1/datacatalog_grpc_service_config.json'
// )) ? $ok : false;
// TODO: Re-enable when monolith updated.
// $ok = processDiff(Invoker::invoke(
//     'googleapis/google/cloud/dataproc/v1/*.proto googleapis/google/cloud/common_resources.proto',
//     'google.cloud.dataproc.v1',
//     'googleapis/google/cloud/dataproc/v1/dataproc_gapic.yaml',
//     'googleapis/google/cloud/dataproc/v1/dataproc_v1.yaml',
//     'googleapis/google/cloud/dataproc/v1/dataproc_grpc_service_config.json'
// )) ? $ok : false;
$ok = processDiff(Invoker::invoke(<commit_msg>Enable tests now that the monolith is updated (#115)<commit_after><?php
/*
 * Copyright 2020 Google LLC
 *
 * 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
 *
 *     https://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.
 */
declare(strict_types=1);

namespace Google\Generator\IntegrationTests;

require __DIR__ . '/../vendor/autoload.php';
error_reporting(E_ALL);

// Initial integration test.
// Compare output of monolith and micro generators.
// They should match except for whitespace and trailing commas.

$ok = true;
// Generate and compare test APIs.
$ok = processDiff(Invoker::invoke('tests/ProtoTests/Basic/basic.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/BasicLro/basic-lro.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/BasicPaginated/basic-paginated.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/BasicBidiStreaming/basic-bidi-streaming.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/BasicServerStreaming/basic-server-streaming.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/BasicClientStreaming/basic-client-streaming.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/ResourceNames/resource-names.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/ProtoDocs/proto-docs.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/RoutingHeaders/routing-headers.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/Keywords/keywords.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke('tests/ProtoTests/AllTypes/all-types.proto')) ? $ok : false;
$ok = processDiff(Invoker::invoke(
    'tests/ProtoTests/GrpcServiceConfig/*.proto',
    'testing.grpcserviceconfig',
    'tests/ProtoTests/GrpcServiceConfig/grpc-service-config_gapic.yaml',
    'tests/ProtoTests/GrpcServiceConfig/grpc-service-config.yaml',
    'tests/ProtoTests/GrpcServiceConfig/grpc-service-config.json'
)) ? $ok : false;

// Generate and compare a real APIs.
// TODO: Real API tests may be more suitable as their own integration test.
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/accessapproval/v1/*.proto',
    'google.cloud.accessapproval.v1',
    'googleapis/google/cloud/accessapproval/v1/accessapproval_gapic.yaml',
    'googleapis/google/cloud/accessapproval/v1/accessapproval_v1.yaml',
    'googleapis/google/cloud/accessapproval/v1/accessapproval_grpc_service_config.json'
)) ? $ok : false;
// TODO: googleapis/google/cloud/apigateway/v1/ doesn't have a gapic_config, so monolith crashes
// $ok = processDiff(Invoker::invoke(
//     'googleapis/google/cloud/apigateway/v1/*.proto',
//     'google.cloud.apigateway.v1',
//     null,
//     'googleapis/google/cloud/apigateway/v1/apigateway_v1.yaml',
//     'googleapis/google/cloud/apigateway/v1/apigateway_grpc_service_config.json'
// )) ? $ok : false;
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/asset/v1/*.proto',
    'google.cloud.asset.v1',
    'googleapis/google/cloud/asset/v1/cloudasset_gapic.yaml',
    'googleapis/google/cloud/asset/v1/cloudasset_v1.yaml',
    'googleapis/google/cloud/asset/v1/cloudasset_grpc_service_config.json'
)) ? $ok : false;
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/automl/v1/*.proto googleapis/google/cloud/common_resources.proto',
    'google.cloud.automl.v1',
    'googleapis/google/cloud/automl/v1/automl_gapic.yaml',
    'googleapis/google/cloud/automl/v1/automl_v1.yaml',
    'googleapis/google/cloud/automl/v1/automl_grpc_service_config.json'
)) ? $ok : false;
// TODO: BigQuery
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/billing/v1/*.proto googleapis/google/cloud/common_resources.proto',
    'google.cloud.billing.v1',
    'googleapis/google/cloud/billing/v1/cloud_billing_gapic.yaml',
    'googleapis/google/cloud/billing/v1/cloudbilling.yaml',
    'googleapis/google/cloud/billing/v1/cloud_billing_grpc_service_config.json'
)) ? $ok : false;
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/billing/budgets/v1/*.proto googleapis/google/cloud/common_resources.proto',
    'google.cloud.billing.budgets.v1',
    'googleapis/google/cloud/billing/budgets/v1/billingbudget_gapic.yaml',
    'googleapis/google/cloud/billing/budgets/v1/billingbudgets.yaml',
    'googleapis/google/cloud/billing/budgets/v1/billingbudgets_grpc_service_config.json'
)) ? $ok : false;
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/channel/v1/*.proto googleapis/google/cloud/common_resources.proto',
    'google.cloud.channel.v1',
    'googleapis/google/cloud/channel/v1/cloudchannel_gapic.yaml',
    'googleapis/google/cloud/channel/v1/cloudchannel_v1.yaml',
    'googleapis/google/cloud/channel/v1/cloudchannel_grpc_service_config.json'
)) ? $ok : false;
// Inconsistent PHP namespace casing between monolith and micro.
// Micro-generator gets PHP namespace from proto; monolith gets it from service config, which is missing for this API.
// $ok = processDiff(Invoker::invoke(
//     'googleapis/google/cloud/datacatalog/v1/*.proto googleapis/google/cloud/common_resources.proto',
//     'google.cloud.datacatalog.v1',
//     'googleapis/google/cloud/datacatalog/v1/datacatalog_gapic.yaml',
//     'googleapis/google/cloud/datacatalog/v1/datacatalog_v1.yaml',
//     'googleapis/google/cloud/datacatalog/v1/datacatalog_grpc_service_config.json'
// )) ? $ok : false;
$ok = processDiff(Invoker::invoke(
    'googleapis/google/cloud/dataproc/v1/*.proto googleapis/google/cloud/common_resources.proto',
    'google.cloud.dataproc.v1',
    'googleapis/google/cloud/dataproc/v1/dataproc_gapic.yaml',
    'googleapis/google/cloud/dataproc/v1/dataproc_v1.yaml',
    'googleapis/google/cloud/dataproc/v1/dataproc_grpc_service_config.json'
)) ? $ok : false;
$ok = processDiff(Invoker::invoke(
{'fraction_non_alphanumeric': 0.14514231945424605, 'fraction_numerical': 0.009801615306202462, 'mean_word_length': 4.758013544018059, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '784057', 'n_tokens_mistral': 4282, 'n_tokens_neox': 4195, 'n_words': 645}