<commit_before>require 'sauce/utilities'
require "sauce_whisk"

begin
  require 'spec'
  module Sauce
    module RSpec
      class SeleniumExampleGroup < Spec::Example::ExampleGroup
        attr_reader :selenium
        @@need_tunnel = false

        def self.inherited(subclass)
          # only setup tunnel if somebody needs it
          @@need_tunnel = true
          super(subclass)
        end

        before :suite do
          config = Sauce::Config.new
          if @@need_tunnel
            if config[:application_host]
              @@tunnel = Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port] || 80)
              @@tunnel.connect
              @@tunnel.wait_until_ready
            end
            if config[:start_local_application] &&
              Sauce::Utilities::RailsServer.is_rails_app?
              @@server = Sauce::Utilities::RailsServer.new
              @@server.start
            end
          end
        end

        after :suite do
          Sauce::Utilities::Connect.close
          @@server.stop if defined? @@server
        end

        def execute(*args)
          config = Sauce::Config.new
          description = [self.class.description, self.description].join(" ")
          config[:browsers].each do |os, browser, version|
            @selenium = Sauce::Selenium2.new({:os => os, :browser => browser,
                                              :browser_version => version,
                                              :job_name => description})
            super(*args)

            @selenium.stop
          end
        end

        alias_method :page, :selenium
        alias_method :s, :selenium

        Spec::Example::ExampleGroupFactory.register(:selenium, self)
      end
    end
  end
rescue LoadError
  # User doesn't have RSpec 1.x installed
rescue => e
  STDERR.puts "Exception occured: #{e.to_s}"
end

begin
  require 'rspec/core'
  module Sauce
    module RSpec
      module SeleniumExampleGroup
        attr_reader :selenium
        alias_method :page, :selenium
        alias_method :s, :selenium

        def self.included(othermod)
          othermod.around do |the_test|
            config = Sauce::Config.new
            description = the_test.metadata[:full_description]
            config.browsers.each do |os, browser, version|
              @selenium = Sauce::Selenium2.new({:os => os,
                                                :browser => browser,
                                                :browser_version => version,
                                                :job_name => description})
              Sauce.driver_pool[Thread.current.object_id] = @selenium

              begin
                the_test.run
                SauceWhisk::Jobs.change_status @selenium.session_id, example.exception.nil?
              ensure
                @selenium.stop
                Sauce.driver_pool.delete Thread.current.object_id
              end
            end
          end
        end

        ::RSpec.configuration.include(self, :example_group => {
              :file_path => Regexp.compile('spec[\\\/]selenium')
            })
        ::RSpec.configuration.include(self, :sauce => true)

        ::RSpec.configuration.before(:suite, sauce: true) do

          config = Sauce::Config.new
          if config[:application_host]
            @@tunnel ||= Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port] || 80)
            @@tunnel.connect
            @@tunnel.wait_until_ready
          end

          if config[:start_local_application] &&
            Sauce::Utilities::RailsServer.is_rails_app?
            # Start the app before the tests if this is a parallel run
            if ENV["TEST_ENV_NUMBER"].nil?
              @@server = Sauce::Utilities::RailsServer.new
              @@server.start
            end
          end
        end

        ::RSpec.configuration.before :suite do
          need_tunnel = false
          config = Sauce::Config.new
          files_to_run = ::RSpec.configuration.respond_to?(:files_to_run) ? ::RSpec.configuration.files_to_run :
            ::RSpec.configuration.settings[:files_to_run]
          if config[:application_host]
            need_tunnel = files_to_run.any? {|file| file =~ /spec\/selenium\//}
          end

          if need_tunnel || config[:start_tunnel]
            @@tunnel ||= Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port] || 80)
            @@tunnel.connect
            @@tunnel.wait_until_ready
          end

          if config[:start_local_application] &&
            files_to_run.any? {|file| file =~ /spec\/selenium\//} &&
            Sauce::Utilities::RailsServer.is_rails_app?
            ## Only open the tunnel once.
            ## TODO:  Why is this here?  It's above, also
            @@server = Sauce::Utilities::RailsServer.new
            @@server.start
          end
        end
        ::RSpec.configuration.after :suite do
          Sauce::Utilities::Connect.close
          @@server.stop if defined? @@server
        end
      end
    end
  end<commit_msg>Remove all the extra tunnel storage in integration.rg<commit_after>require 'sauce/utilities'
require "sauce_whisk"

begin
  require 'spec'
  module Sauce
    module RSpec
      class SeleniumExampleGroup < Spec::Example::ExampleGroup
        attr_reader :selenium
        @@need_tunnel = false

        def self.inherited(subclass)
          # only setup tunnel if somebody needs it
          @@need_tunnel = true
          super(subclass)
        end

        before :suite do
          config = Sauce::Config.new
          if @@need_tunnel
            if config[:application_host]
              Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port] || 80)
            end
            if config[:start_local_application] &&
              Sauce::Utilities::RailsServer.is_rails_app?
              @@server = Sauce::Utilities::RailsServer.new
              @@server.start
            end
          end
        end

        after :suite do
          Sauce::Utilities::Connect.close
          @@server.stop if defined? @@server
        end

        def execute(*args)
          config = Sauce::Config.new
          description = [self.class.description, self.description].join(" ")
          config[:browsers].each do |os, browser, version|
            @selenium = Sauce::Selenium2.new({:os => os, :browser => browser,
                                              :browser_version => version,
                                              :job_name => description})
            super(*args)

            @selenium.stop
          end
        end

        alias_method :page, :selenium
        alias_method :s, :selenium

        Spec::Example::ExampleGroupFactory.register(:selenium, self)
      end
    end
  end
rescue LoadError
  # User doesn't have RSpec 1.x installed
rescue => e
  STDERR.puts "Exception occured: #{e.to_s}"
end

begin
  require 'rspec/core'
  module Sauce
    module RSpec
      module SeleniumExampleGroup
        attr_reader :selenium
        alias_method :page, :selenium
        alias_method :s, :selenium

        def self.included(othermod)
          othermod.around do |the_test|
            config = Sauce::Config.new
            description = the_test.metadata[:full_description]
            config.browsers.each do |os, browser, version|
              @selenium = Sauce::Selenium2.new({:os => os,
                                                :browser => browser,
                                                :browser_version => version,
                                                :job_name => description})
              Sauce.driver_pool[Thread.current.object_id] = @selenium

              begin
                the_test.run
                SauceWhisk::Jobs.change_status @selenium.session_id, example.exception.nil?
              ensure
                @selenium.stop
                Sauce.driver_pool.delete Thread.current.object_id
              end
            end
          end
        end

        ::RSpec.configuration.include(self, :example_group => {
              :file_path => Regexp.compile('spec[\\\/]selenium')
            })
        ::RSpec.configuration.include(self, :sauce => true)

        ::RSpec.configuration.before(:suite, sauce: true) do

          config = Sauce::Config.new
          if config[:application_host]
            Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port] || 80)
          end

          if config[:start_local_application] &&
            Sauce::Utilities::RailsServer.is_rails_app?
            # Start the app before the tests if this is a parallel run
            if ENV["TEST_ENV_NUMBER"].nil?
              @@server = Sauce::Utilities::RailsServer.new
              @@server.start
            end
          end
        end

        ::RSpec.configuration.before :suite do
          need_tunnel = false
          config = Sauce::Config.new
          files_to_run = ::RSpec.configuration.respond_to?(:files_to_run) ? ::RSpec.configuration.files_to_run :
            ::RSpec.configuration.settings[:files_to_run]
          if config[:application_host]
            need_tunnel = files_to_run.any? {|file| file =~ /spec\/selenium\//}
          end

          if need_tunnel || config[:start_tunnel]
            Sauce::Utilities::Connect.start(:host => config[:application_host], :port => config[:application_port] || 80)
          end

          if config[:start_local_application] &&
            files_to_run.any? {|file| file =~ /spec\/selenium\//} &&
            Sauce::Utilities::RailsServer.is_rails_app?
            ## Only open the tunnel once.
            ## TODO:  Why is this here?  It's above, also
            @@server = Sauce::Utilities::RailsServer.new
            @@server.start
          end
        end
        ::RSpec.configuration.after :suite do
          Sauce::Utilities::Connect.close
          @@server.stop if defined? @@server
        end
      end
    end
  end
{'fraction_non_alphanumeric': 0.10143785700216663, 'fraction_numerical': 0.0017727004136300964, 'mean_word_length': 1.757263100733098, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4860269', 'n_tokens_mistral': 2791, 'n_tokens_neox': 2665, 'n_words': 573}