<commit_before># See how to write hooks and plugins
# https://github.com/seattlerb/minitest/blob/master/lib/minitest/test.rb
module Knapsack
  module Adapters
    class MinitestAdapter < BaseAdapter
      TEST_DIR_PATTERN = 'test/**/*_test.rb'
      REPORT_PATH = 'knapsack_minitest_report.json'
      @@parent_of_test_dir = nil

      def set_test_helper_path(file_path)
        test_dir_path = File.dirname(file_path)
        @@parent_of_test_dir = File.expand_path('../', test_dir_path)
      end

      module BindTimeTrackerMinitestPlugin
        def before_setup
          super

          Knapsack.tracker.test_path = MinitestAdapter.test_path(self)
          Knapsack.tracker.start_timer
        end

        def after_teardown
          Knapsack.tracker.stop_timer
          super
        end
      end

      def bind_time_tracker
        ::Minitest::Test.send(:include, BindTimeTrackerMinitestPlugin)

        ::Minitest.after_run do
          #::Kernel.at_exit do
          Knapsack.logger.info(Presenter.global_time)
          #end
        end
      end


      def bind_report_generator
        Minitest.after_run do
          #::Kernel.at_exit do
          Knapsack.report.save
          Knapsack.logger.info(Presenter.report_details)
          #end
        end
      end

      def bind_time_offset_warning
        Minitest.after_run do
          #::Kernel.at_exit do
          Knapsack.logger.warn(Presenter.time_offset_warning)
          #end
        end
      end<commit_msg>Get rid of Kernel at exit in minitest adapter<commit_after># See how to write hooks and plugins
# https://github.com/seattlerb/minitest/blob/master/lib/minitest/test.rb
module Knapsack
  module Adapters
    class MinitestAdapter < BaseAdapter
      TEST_DIR_PATTERN = 'test/**/*_test.rb'
      REPORT_PATH = 'knapsack_minitest_report.json'
      @@parent_of_test_dir = nil

      def set_test_helper_path(file_path)
        test_dir_path = File.dirname(file_path)
        @@parent_of_test_dir = File.expand_path('../', test_dir_path)
      end

      module BindTimeTrackerMinitestPlugin
        def before_setup
          super
          Knapsack.tracker.test_path = MinitestAdapter.test_path(self)
          Knapsack.tracker.start_timer
        end

        def after_teardown
          Knapsack.tracker.stop_timer
          super
        end
      end

      def bind_time_tracker
        ::Minitest::Test.send(:include, BindTimeTrackerMinitestPlugin)

        ::Minitest.after_run do
          Knapsack.logger.info(Presenter.global_time)
        end
      end


      def bind_report_generator
        Minitest.after_run do
          Knapsack.report.save
          Knapsack.logger.info(Presenter.report_details)
        end
      end

      def bind_time_offset_warning
        Minitest.after_run do
          Knapsack.logger.warn(Presenter.time_offset_warning)
        end
      end
{'fraction_non_alphanumeric': 0.06976744186046512, 'fraction_numerical': 0.0, 'mean_word_length': 2.238202247191011, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4614278', 'n_tokens_mistral': 925, 'n_tokens_neox': 899, 'n_words': 154}