<commit_before>require 'shellwords'
require 'stringio'

module Vendorificator
  module TestSupport
    module ArubaExt
      def last_process
        processes.last.last
      end

      def last_stdout
        unescape last_process.stdout
      end

      def last_stderr
        unescape last_process.stderr
      end

      def last_output
        unescape(last_stdout + last_stderr)
      end

      def without_bundler(cmd)
        cmd = %w[ RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE
                ].map { |v| "unset #{v} ; " }.join << cmd
        "sh -c #{Shellwords.escape(cmd)}"
      end

      def with_redirected_stdout(&block)
        redirect_stdout
        yield
        bring_back_stdout
      end

      def mock_stdout
        unescape @stdout_cache
      end

      def mock_stderr
        unescape @stderr_cache
      end

      def mock_output
        mock_stdout + mock_stderr
      end

      private
<commit_msg>Bring back stdout even if vendor has failed.<commit_after>require 'shellwords'
require 'stringio'

module Vendorificator
  module TestSupport
    module ArubaExt
      def last_process
        processes.last.last
      end

      def last_stdout
        unescape last_process.stdout
      end

      def last_stderr
        unescape last_process.stderr
      end

      def last_output
        unescape(last_stdout + last_stderr)
      end

      def without_bundler(cmd)
        cmd = %w[ RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE
                ].map { |v| "unset #{v} ; " }.join << cmd
        "sh -c #{Shellwords.escape(cmd)}"
      end

      def with_redirected_stdout(&block)
        redirect_stdout
        yield
      ensure
        bring_back_stdout
      end

      def mock_stdout
        unescape @stdout_cache
      end

      def mock_stderr
        unescape @stderr_cache
      end

      def mock_output
        mock_stdout + mock_stderr
      end

      private

{'fraction_non_alphanumeric': 0.05113636363636364, 'fraction_numerical': 0.0, 'mean_word_length': 1.8997005988023952, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2859267', 'n_tokens_mistral': 583, 'n_tokens_neox': 579, 'n_words': 146}