<commit_before># ruby requires
require 'test/unit'

# main source tree requires
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'main', 'lib')
require 'conf/config'

class TclongPermissions < Test::Unit::TestCase

  DISCOVERY_RB = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'main', 'lib', 'discovery.rb')) unless defined? DISCOVERY_RB
  PERMISSIONS_DIR_TO_DISCOVER = File.expand_path(File.join(File.dirname(__FILE__), '..', 'resources', 'content-cg', 'permission-tests')) unless defined? PERMISSIONS_DIR_TO_DISCOVER
  
  def setup
  end
  
  def teardown
  end
  
  def test_permission_count
    cmd = "ruby #{DISCOVERY_RB} --path #{PERMISSIONS_DIR_TO_DISCOVER}"
    output = `#{cmd}`
    pd_val = output.match(/^permission denied\s+:\s+(.*).*$/)[1]
    assert_equal(2, pd_val.to_i, "Expected to be denied permission to two items (one directory and one file) in the '#{PERMISSIONS_DIR_TO_DISCOVER}' directory.")
  end

end
<commit_msg>fixing permission tests so it doesn't break if it's being run as root<commit_after># ruby requires
require 'test/unit'

# main source tree requires
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'main', 'lib')
require 'conf/config'

class TclongPermissions < Test::Unit::TestCase
  
  @@log = Config.log

  DISCOVERY_RB = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'main', 'lib', 'discovery.rb')) unless defined? DISCOVERY_RB
  PERMISSIONS_DIR_TO_DISCOVER = File.expand_path(File.join(File.dirname(__FILE__), '..', 'resources', 'content-cg', 'permission-tests')) unless defined? PERMISSIONS_DIR_TO_DISCOVER
  
  def setup
  end
  
  def teardown
  end
  
  def test_permission_count
    whoami_result = `whoami`
    if (whoami_result.include?('root')) then
      assert true
      @@log.warn('TclongPermissions'){'Unable to test the permissions functionality because this process is being run by the root user, which has permissions to everything.'}
    else
      cmd = "ruby #{DISCOVERY_RB} --path #{PERMISSIONS_DIR_TO_DISCOVER}"
      output = `#{cmd}`
      pd_val = output.match(/^permission denied\s+:\s+(.*).*$/)[1]
      assert_equal(2, pd_val.to_i, "Expected to be denied permission to two items (one directory and one file) in the '#{PERMISSIONS_DIR_TO_DISCOVER}' directory.")
    end
  end

end

{'fraction_non_alphanumeric': 0.14521739130434783, 'fraction_numerical': 0.0017391304347826088, 'mean_word_length': 4.45260663507109, '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': '2878915', 'n_tokens_mistral': 787, 'n_tokens_neox': 778, 'n_words': 190}