<commit_before>require "test_helper"
class ScriptTest < MiniTest::Unit::TestCase
  def setup
    @Fixture                   = Mobilize::Fixture
    @box                       = Mobilize::Box.find_or_create_by_name "mobilize-script-test"
    @user                      = @Fixture::User.default
    @stdin                     = "(echo 'log this to the log' > log) && cmd"
    @script                    = Mobilize::Script.find_or_create_by stdin: @stdin
    @script_session            = Mobilize::Script.session
    @job                       = @Fixture::Job.default     @user, @box, "job_script_test"
    @stage                     = @Fixture::Stage.default   @job, 1, "run"
    @script_task               = @Fixture::Task.default    @stage, @script, @script_session,
                                                           subs: { cmd: 'pwd' }
  end

  def test_run
    @script.run                  @script_task
    @result                    = @script.streams                @script_task
    assert_equal                 @result[ :stdin ].strip,         @stdin.gsub( "cmd", "pwd" )
    assert_equal                 @result[ :stdout ].strip,        @script_task.dir
    assert_equal                 @result[ :stderr ].strip,        ""
    assert_equal                 @result[ :exit_signal ].strip,   "0"
    assert_equal                 @result[ :log ].strip,           "log this to the log"
  end

  def teardown
    @box.terminate
    @job.purge!
    @script.delete
  end
end<commit_msg>working on script test<commit_after>require "test_helper"
class ScriptTest < MiniTest::Unit::TestCase
  def setup
    @test                      = self
    @Fixture                   = Mobilize::Fixture
    @user                      = @Fixture::User.default
    @crontab                   = @Fixture::Crontab.default  @user
    @cron                      = @Fixture::Cron._once       @crontab,    "script_test"
    @stdin                     = "(echo 'log this to the log' > log) && cmd"
    @script                    = Mobilize::Script.find_or_create_by stdin: @stdin
    @stage                     = @Fixture::Stage.default   @cron, 1, "run"
    @script_task               = @Fixture::Task.default    @stage, 1, @script, subs: { cmd: 'pwd' }
  end

  def test_run
    Mobilize::Log.write                   "starting github test"
    #_start_time                         = Time.now.utc
    Mobilize::Cli.perform                 [ "cron", "enqueue", @cron.id ]
    #monitor logs until expected messages are complete
    #@test.expect _start_time
  end
end
{'fraction_non_alphanumeric': 0.10431372549019607, 'fraction_numerical': 0.001568627450980392, 'mean_word_length': 1.4718992248062015, 'pattern_counts': {'":': 0, '<': 5, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4981282', 'n_tokens_mistral': 756, 'n_tokens_neox': 728, 'n_words': 165}