<commit_before>require 'support/test_case'
require 'jekyll/minibundle/asset_bundle'

module Jekyll::Minibundle::Test
  class AssetBundleTest < TestCase
    def test_raise_exception_if_bundle_command_fails
      capture_io do
        err = assert_raises(RuntimeError) { make_bundle('read ; false') }
        assert_equal 'Bundling js assets failed with exit status 1, command: read ; false', err.to_s
      end
    end

    def test_raise_exception_if_bundle_command_not_found
      assert_raises(Errno::ENOENT) { make_bundle('no-such-jekyll-minibundle-cmd') }
    end

    def test_raise_exception_if_bundle_command_not_configured
      err = assert_raises(RuntimeError) { make_bundle(nil) }
      assert_match(/\AMissing minification command for bundling js assets. Specify it in/, err.to_s)
    end

    private

    def make_bundle(minifier_cmd)
      bundle = AssetBundle.new(
        type: :js,
        asset_paths: [site_fixture_path('_assets/scripts/dependency.js')],
        site_dir: site_fixture_path,<commit_msg>Use POSIX compliant call to `read`<commit_after>require 'support/test_case'
require 'jekyll/minibundle/asset_bundle'

module Jekyll::Minibundle::Test
  class AssetBundleTest < TestCase
    def test_raise_exception_if_bundle_command_fails
      capture_io do
        err = assert_raises(RuntimeError) { make_bundle('read _ignore ; false') }
        assert_equal 'Bundling js assets failed with exit status 1, command: read _ignore ; false', err.to_s
      end
    end

    def test_raise_exception_if_bundle_command_not_found
      assert_raises(Errno::ENOENT) { make_bundle('no-such-jekyll-minibundle-cmd') }
    end

    def test_raise_exception_if_bundle_command_not_configured
      err = assert_raises(RuntimeError) { make_bundle(nil) }
      assert_match(/\AMissing minification command for bundling js assets. Specify it in/, err.to_s)
    end

    private

    def make_bundle(minifier_cmd)
      bundle = AssetBundle.new(
        type: :js,
        asset_paths: [site_fixture_path('_assets/scripts/dependency.js')],
        site_dir: site_fixture_path,
{'fraction_non_alphanumeric': 0.07969275084013443, 'fraction_numerical': 0.0009601536245799327, 'mean_word_length': 3.9150943396226414, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7224654', 'n_tokens_mistral': 677, 'n_tokens_neox': 656, 'n_words': 136}