<commit_before>module Travis
  module Build
    class Script
      module Stages
        def run_stages
          STAGES[:builtin].each { |stage| run_builtin_stage(stage) }
          STAGES[:custom].each  { |stage| run_stage(stage) }
        end

        def run_stage(stage)
          if config[stage] && stage != :after_result
            run_custom_stage(stage)
          elsif respond_to?(stage, false) || stage == :after_result
            run_builtin_stage(stage)
          end
        end

        def run_custom_stage(stage)
          stage(stage) do
            Array(config[stage]).each do |command|
              cmd command
              raw 'export TRAVIS_TEST_RESULT=$?' if stage == :script
            end
          end
        end

        def run_builtin_stage(stage)
          stage(stage) do
            send(stage)
            result if stage == :script
          end
        end

        def after_result<commit_msg>aggregate results for custom scripts, too<commit_after>module Travis
  module Build
    class Script
      module Stages
        def run_stages
          STAGES[:builtin].each { |stage| run_builtin_stage(stage) }
          STAGES[:custom].each  { |stage| run_stage(stage) }
        end

        def run_stage(stage)
          if config[stage] && stage != :after_result
            run_custom_stage(stage)
          elsif respond_to?(stage, false) || stage == :after_result
            run_builtin_stage(stage)
          end
        end

        def run_custom_stage(stage)
          stage(stage) do
            Array(config[stage]).each do |command|
              cmd command
              result if stage == :script
            end
          end
        end

        def run_builtin_stage(stage)
          stage(stage) do
            send(stage)
            result if stage == :script
          end
        end

        def after_result
{'fraction_non_alphanumeric': 0.07577374599786553, 'fraction_numerical': 0.0, 'mean_word_length': 1.6334269662921348, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '343940', 'n_tokens_mistral': 510, 'n_tokens_neox': 503, 'n_words': 128}