<commit_before>require 'active_support/inflector/methods'
require 'active_support/core_ext/object/blank'
require 'timeout'

module Travis
  class Build
    module Job

      # Job::Test subclasses execute test suite run using presets for the given
      # language.
      #
      # A test job takes
      #  * a shell (ssh shell into a running vm) which will be used to run comands
      #  * a commit which can be checked out from Github
      #  * the configuration for this test run
      #
      # A test job performs the following steps:
      #
      #  * change to the vm's build working directory
      #  * export enviroment variables as defined by the configuration as well
      #    as variables that inform about the current environment
      #  * check out the commit from Github
      #  * setup the build if required for the current language (e.g. switch to
      #    the given Ruby version and define the Gemfile for bundler if used)
      #  * run the before_install, install, before_script, script, and
      #    after_script commands
      #
      # The install and script commands might be defined by the language
      # specific test subclasses. All of the commands can be defined in the
      # test configuration.
      class Test
        autoload :C,           'travis/build/job/test/c'
        autoload :Clojure,     'travis/build/job/test/clojure'
        autoload :Cpp,         'travis/build/job/test/cpp'
        autoload :Erlang,      'travis/build/job/test/erlang'
        autoload :Go,          'travis/build/job/test/go'
        autoload :Groovy,      'travis/build/job/test/groovy'
        autoload :Haskell,     'travis/build/job/test/haskell'
        autoload :JdkSwitcher, 'travis/build/job/test/jdk_switcher'
        autoload :JvmLanguage, 'travis/build/job/test/jvm_language'
        autoload :NodeJs,      'travis/build/job/test/node_js'
        autoload :Perl,        'travis/build/job/test/perl'
        autoload :Php,         'travis/build/job/test/php'
        autoload :PureJava,    'travis/build/job/test/pure_java'
        autoload :Python,      'travis/build/job/test/python'
        autoload :Ruby,        'travis/build/job/test/ruby'
        autoload :Scala,       'travis/build/job/test/scala'

        STAGES = [:before_install, :install, :before_script, :script, :after_script]

        extend Assertions
        include Logging

        log_header { [Thread.current[:log_header], "build:job:test"].join(':') }

        class << self
          def by_lang(lng)
            lang = (Array(lng).first || 'ruby').downcase.strip

            case lang
            when /^java/i then
              # just "Java" would conflict with JRuby's Java integration
              Job::Test::PureJava
            when "c++", "cpp", "cplusplus" then
              Job::Test::Cpp
            else
              args = [ActiveSupport::Inflector.camelize(lang.downcase)]
              args << false if Kernel.method(:const_get).arity == -1
              Job::Test.const_get(*args) rescue Job::Test::Ruby
            end
          end
        end

        attr_reader :shell, :commit, :config, :repository

        def initialize(shell, commit, config)
          @shell = shell
          @commit = commit
          @config = config

          @repository = @commit.repository
        end

        def install
          # intentional no-op. We need to overwrite Kernel#install which is added by Rake
          # because we use `respond_to?` in `commands_for`.
        end

        def run
          { :result => perform ? 0 : 1 }
        end
        log :run

        protected

        def perform
          chdir
          export
          start_services
          checkout
          setup if respond_to?(:setup)
          run_stages
        rescue CommandTimeout, OutputLimitExceeded => e
          shell.echo "\n\n#{e.message}\n\n", :force => true
          false
        rescue AssertionFailed => e
          log_exception(e)
          false
        end

        def start_services
          xs = Array(config.services || []).
            map { |s| normalize_service(s) }

          if xs.any?
            xs.each { |s| start_service(s) }
            # give services a moment to start
            shell.execute "sleep 3"
          end
        end

        def normalize_service(name)
          s = name.to_s.downcase
          case s
          when "rabbitmq" then
            "rabbitmq-server"
          when "memcache" then
            "memcached"
          else
            s
          end
        end<commit_msg>Normalize neo4j server service name<commit_after>require 'active_support/inflector/methods'
require 'active_support/core_ext/object/blank'
require 'timeout'

module Travis
  class Build
    module Job

      # Job::Test subclasses execute test suite run using presets for the given
      # language.
      #
      # A test job takes
      #  * a shell (ssh shell into a running vm) which will be used to run comands
      #  * a commit which can be checked out from Github
      #  * the configuration for this test run
      #
      # A test job performs the following steps:
      #
      #  * change to the vm's build working directory
      #  * export enviroment variables as defined by the configuration as well
      #    as variables that inform about the current environment
      #  * check out the commit from Github
      #  * setup the build if required for the current language (e.g. switch to
      #    the given Ruby version and define the Gemfile for bundler if used)
      #  * run the before_install, install, before_script, script, and
      #    after_script commands
      #
      # The install and script commands might be defined by the language
      # specific test subclasses. All of the commands can be defined in the
      # test configuration.
      class Test
        autoload :C,           'travis/build/job/test/c'
        autoload :Clojure,     'travis/build/job/test/clojure'
        autoload :Cpp,         'travis/build/job/test/cpp'
        autoload :Erlang,      'travis/build/job/test/erlang'
        autoload :Go,          'travis/build/job/test/go'
        autoload :Groovy,      'travis/build/job/test/groovy'
        autoload :Haskell,     'travis/build/job/test/haskell'
        autoload :JdkSwitcher, 'travis/build/job/test/jdk_switcher'
        autoload :JvmLanguage, 'travis/build/job/test/jvm_language'
        autoload :NodeJs,      'travis/build/job/test/node_js'
        autoload :Perl,        'travis/build/job/test/perl'
        autoload :Php,         'travis/build/job/test/php'
        autoload :PureJava,    'travis/build/job/test/pure_java'
        autoload :Python,      'travis/build/job/test/python'
        autoload :Ruby,        'travis/build/job/test/ruby'
        autoload :Scala,       'travis/build/job/test/scala'

        STAGES = [:before_install, :install, :before_script, :script, :after_script]

        extend Assertions
        include Logging

        log_header { [Thread.current[:log_header], "build:job:test"].join(':') }

        class << self
          def by_lang(lng)
            lang = (Array(lng).first || 'ruby').downcase.strip

            case lang
            when /^java/i then
              # just "Java" would conflict with JRuby's Java integration
              Job::Test::PureJava
            when "c++", "cpp", "cplusplus" then
              Job::Test::Cpp
            else
              args = [ActiveSupport::Inflector.camelize(lang.downcase)]
              args << false if Kernel.method(:const_get).arity == -1
              Job::Test.const_get(*args) rescue Job::Test::Ruby
            end
          end
        end

        attr_reader :shell, :commit, :config, :repository

        def initialize(shell, commit, config)
          @shell = shell
          @commit = commit
          @config = config

          @repository = @commit.repository
        end

        def install
          # intentional no-op. We need to overwrite Kernel#install which is added by Rake
          # because we use `respond_to?` in `commands_for`.
        end

        def run
          { :result => perform ? 0 : 1 }
        end
        log :run

        protected

        def perform
          chdir
          export
          start_services
          checkout
          setup if respond_to?(:setup)
          run_stages
        rescue CommandTimeout, OutputLimitExceeded => e
          shell.echo "\n\n#{e.message}\n\n", :force => true
          false
        rescue AssertionFailed => e
          log_exception(e)
          false
        end

        def start_services
          xs = Array(config.services || []).
            map { |s| normalize_service(s) }

          if xs.any?
            xs.each { |s| start_service(s) }
            # give services a moment to start
            shell.execute "sleep 3"
          end
        end

        def normalize_service(name)
          s = name.to_s.downcase
          case s
          when "rabbitmq" then
            "rabbitmq-server"
          when "memcache" then
            "memcached"
          when "neo4j", "neo4j-server" then
            "neo4j"
          else
            s
          end
        end
{'fraction_non_alphanumeric': 0.08742931709438886, 'fraction_numerical': 0.0013049151805132667, 'mean_word_length': 1.7827534039334343, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3281687', 'n_tokens_mistral': 2702, 'n_tokens_neox': 2622, 'n_words': 754}