<commit_before>require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe SimpleShell do
  let (:shell) { SimpleShell.new }

  it "should keep track of perfomed commands" do
    shell.ls
    shell.ls

    shell.commands.count.should == 2
  end

  it "should remember the last exit status" do
    shell.ls "/path/non/existant"
    shell.S?.to_i.should_not == 0

    shell.ls
    shell.S?.to_i.should == 0
  end

  it "should perform system commands" do
    c = shell.system("ls -la")

    c.out.should_not be_empty
    c.err.should be_empty
    c.S?.to_i.should == 0
  end

  it "should allow a sub shell" do
    shell.ls
    shell.ls

    commands = shell.in("/tmp") do |sub|
      sub.ls
    end

    commands.should be_kind_of(Array)
    commands.count.should == 1

    shell.commands.count.should == 2
  end

  it "should allow a sub shell with relative paths" do
    shell.mkdir "-p", "here"
    shell.in("here") do |sh|
      sh.do :touch, "here_file"
    end

    shell.ls("here").out.split("\n").should include("here_file")
    shell.rm "-rf", "here"
  end


  it "should use blocks to write on stdin" do
    res = shell.wc("-w") do |pipe|
      pipe.puts "I was echoed"
    end

    res.out.should == "3"
  end

  it "should be settable to noisy" do
    SimpleShell.noisy = true
    SimpleShell.noisy.should be_true
  end

  it "should allow for environment setting" do
    shell = SimpleShell.new({ 'MY_ENV' => 'my environment' })
    shell.printenv.out.should =~ /my environment/

    shell = SimpleShell.new()
    shell.printenv.out.should_not =~ /my environment/
  end
end<commit_msg>Make specs STFU after the noisy test<commit_after>require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe SimpleShell do
  let (:shell) { SimpleShell.new }

  it "should keep track of perfomed commands" do
    shell.ls
    shell.ls

    shell.commands.count.should == 2
  end

  it "should remember the last exit status" do
    shell.ls "/path/non/existant"
    shell.S?.to_i.should_not == 0

    shell.ls
    shell.S?.to_i.should == 0
  end

  it "should perform system commands" do
    c = shell.system("ls -la")

    c.out.should_not be_empty
    c.err.should be_empty
    c.S?.to_i.should == 0
  end

  it "should allow a sub shell" do
    shell.ls
    shell.ls

    commands = shell.in("/tmp") do |sub|
      sub.ls
    end

    commands.should be_kind_of(Array)
    commands.count.should == 1

    shell.commands.count.should == 2
  end

  it "should allow a sub shell with relative paths" do
    shell.mkdir "-p", "here"
    shell.in("here") do |sh|
      sh.do :touch, "here_file"
    end

    shell.ls("here").out.split("\n").should include("here_file")
    shell.rm "-rf", "here"
  end


  it "should use blocks to write on stdin" do
    res = shell.wc("-w") do |pipe|
      pipe.puts "I was echoed"
    end

    res.out.should == "3"
  end

  it "should be settable to noisy" do
    SimpleShell.noisy = true
    SimpleShell.noisy.should be_true

    SimpleShell.noisy = false
    SimpleShell.noisy.should be_false
  end

  it "should allow for environment setting" do
    shell = SimpleShell.new({ 'MY_ENV' => 'my environment' })
    shell.printenv.out.should =~ /my environment/

    shell = SimpleShell.new()
    shell.printenv.out.should_not =~ /my environment/
  end
end
{'fraction_non_alphanumeric': 0.11995177817962628, 'fraction_numerical': 0.004219409282700422, 'mean_word_length': 2.623362445414847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5417226', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1112, 'n_words': 323}