<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */
package org.apache.phoenix.end2end;

import java.io.IOException;
import java.io.PrintStream;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;

import org.apache.commons.cli.CommandLine;
import org.apache.hadoop.hbase.ClassFinder;
import org.apache.hadoop.hbase.ClassFinder.FileNameFilter;
import org.apache.hadoop.hbase.ClassTestFinder;
import org.apache.hadoop.hbase.IntegrationTestingUtility;
import org.apache.hadoop.hbase.util.AbstractHBaseTool;
import org.apache.hadoop.util.ToolRunner;
import org.junit.internal.TextListener;
import org.junit.runner.Description;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

/**
 * This class drives the End2End tests suite execution against an
 * already deployed distributed cluster.
 */
public class End2EndTestDriver extends AbstractHBaseTool {
    
    private static final String SHORT_REGEX_ARG = "r";
    private static final String SKIP_TESTS = "n";
    
    private End2EndTestFilter end2endTestFilter = new End2EndTestFilter();
    private boolean skipTests = false;
    

    public static void main(String[] args) throws Exception {
      int ret = ToolRunner.run(new End2EndTestDriver(), args);
      System.exit(ret);
    }
    
    public static class End2EndFileNameFilter implements FileNameFilter {

        @Override
        public boolean isCandidateFile(String fileName, String absFilePath) {
          return fileName.contains("IT");
        }
    };


    public class End2EndTestFilter extends ClassTestFinder.TestClassFilter {
      private Pattern testFilterRe = Pattern.compile(".*end2end.*");
      public End2EndTestFilter() {
        super();
      }

      public void setPattern(String pattern) {
        testFilterRe = Pattern.compile(pattern);
      }

      @Override
      public boolean isCandidateClass(Class<?> c) {
          Annotation[] annotations = c.getAnnotations();
          for (Annotation curAnnotation : annotations) {
              if (curAnnotation.toString().contains("NeedsOwnMiniClusterTest")) {<commit_msg>PHOENIX-3557 Provide a good error message when an invalid test pattern was provided<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */
package org.apache.phoenix.end2end;

import java.io.IOException;
import java.io.PrintStream;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

import org.apache.commons.cli.CommandLine;
import org.apache.hadoop.hbase.ClassFinder;
import org.apache.hadoop.hbase.ClassFinder.FileNameFilter;
import org.apache.hadoop.hbase.ClassTestFinder;
import org.apache.hadoop.hbase.IntegrationTestingUtility;
import org.apache.hadoop.hbase.util.AbstractHBaseTool;
import org.apache.hadoop.util.ToolRunner;
import org.junit.internal.TextListener;
import org.junit.runner.Description;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * This class drives the End2End tests suite execution against an
 * already deployed distributed cluster.
 */
public class End2EndTestDriver extends AbstractHBaseTool {
    
    private static final Logger LOG = LoggerFactory.getLogger(End2EndTestDriver.class);
    private static final String SHORT_REGEX_ARG = "r";
    private static final String SKIP_TESTS = "n";
    
    private End2EndTestFilter end2endTestFilter = new End2EndTestFilter();
    private boolean skipTests = false;
    

    public static void main(String[] args) throws Exception {
      int ret = ToolRunner.run(new End2EndTestDriver(), args);
      System.exit(ret);
    }
    
    public static class End2EndFileNameFilter implements FileNameFilter {

        @Override
        public boolean isCandidateFile(String fileName, String absFilePath) {
          return fileName.contains("IT");
        }
    };


    public class End2EndTestFilter extends ClassTestFinder.TestClassFilter {
      private Pattern testFilterRe = Pattern.compile(".*end2end.*");
      public End2EndTestFilter() {
        super();
      }

      public void setPattern(String pattern) {
        try {
          testFilterRe = Pattern.compile(pattern);
        } catch (PatternSyntaxException e) {
          LOG.error("Failed to find tests using pattern '" + pattern
              + "'. Is it a valid Java regular expression?", e);
          throw e;
        }
      }

      @Override
      public boolean isCandidateClass(Class<?> c) {
          Annotation[] annotations = c.getAnnotations();
          for (Annotation curAnnotation : annotations) {
              if (curAnnotation.toString().contains("NeedsOwnMiniClusterTest")) {
{'fraction_non_alphanumeric': 0.08346142022748232, 'fraction_numerical': 0.005687058100215186, 'mean_word_length': 3.74617067833698, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '4742602', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1709, 'n_words': 555}