<commit_before>require "mixlib/shellout"
require "bundler"

describe "Chef Fips Specs" do
  def windows?
    if RUBY_PLATFORM =~ /mswin|mingw|windows/
      true
    else
      false
    end
  end

  let(:chef_dir) do
    if windows?
      Dir.glob("c:/opscode/chef/embedded/lib/ruby/gems/*/gems/chef-[0-9]*").last
    else
      Dir.glob("/opt/chef/embedded/lib/ruby/gems/*/gems/chef-[0-9]*").last
    end
  end

  let(:path) do
    if windows?
      'C:\opscode\chef\embedded\bin'
    else
      "/opt/chef/embedded/bin"
    end
  end

  it "passes the unit and functional specs" do
    Bundler.with_clean_env do
      ruby_cmd = Mixlib::ShellOut.new(
        "bundle exec rspec -t ~requires_git spec/unit spec/functional", :env => { "PATH" => [ENV["PATH"], path].join(File::PATH_SEPARATOR),
                                                                                  "GEM_PATH" => nil, "GEM_CACHE" => nil, "GEM_HOME" => nil,
                                                                                  "CHEF_FIPS" => "1" },
                                                                        :live_stream => STDOUT, :cwd => chef_dir, :timeout => 3600)
      expect { ruby_cmd.run_command.error! }.not_to raise_exception
    end
  end
end
<commit_msg>Make FIPS use the /opt/chef bundle to run the tests<commit_after>require "mixlib/shellout"
require "bundler"

describe "Chef Fips Specs" do
  def windows?
    if RUBY_PLATFORM =~ /mswin|mingw|windows/
      true
    else
      false
    end
  end

  let(:omnibus_root) do
    if windows?
      "c:/opscode/chef"
    else
      "/opt/chef"
    end
  end

  let(:env) do
    {
      "PATH" => [ "#{omnibus_root}/embedded/bin", ENV["PATH"] ].join(File::PATH_SEPARATOR),
      "BUNDLE_GEMFILE" => "#{omnibus_root}/Gemfile",
      "GEM_PATH" => nil, "GEM_CACHE" => nil, "GEM_HOME" => nil,
      "BUNDLE_IGNORE_CONFIG" => "true",
      "BUNDLE_FROZEN" => "1",
      "CHEF_FIPS" => "1"
    }
  end

  let(:chef_dir) do
    cmd = Mixlib::ShellOut.new("bundle show chef", env: env).run_command
    cmd.error!
    cmd.stdout.chomp
  end

  it "passes the unit and functional specs" do
    Bundler.with_clean_env do
      cmd = Mixlib::ShellOut.new(
        "bundle exec rspec -t ~requires_git spec/unit spec/functional",
        env: env, live_stream: STDOUT, cwd: chef_dir, timeout: 3600
      )
      cmd.run_command.error!
    end
  end
end

{'fraction_non_alphanumeric': 0.1286427976686095, 'fraction_numerical': 0.0062447960033305576, 'mean_word_length': 1.9703337453646477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6985878', 'n_tokens_mistral': 875, 'n_tokens_neox': 833, 'n_words': 181}