<commit_before>#!/usr/bin/env ruby
# coding: utf-8
require 'yaml'
require 'test/unit'
require_relative '../cwl-inspector'

unless defined? CWL_PATH
  CWL_PATH=File.join(File.dirname(__FILE__), '..', 'examples')
end

class TestEcho < Test::Unit::TestCase
  def setup
    @cwl = YAML.load_file(File.join(CWL_PATH, 'echo', 'echo.cwl'))
  end

  def test_version
    assert_equal('v1.0',
                 cwl_inspect(@cwl, '.cwlVersion'))
  end

  def test_id_based_access
    assert_equal('Input string',
                 cwl_inspect(@cwl, '.inputs.input.label'))
  end

  def test_index_based_access
    assert_equal('Input string',
                 cwl_inspect(@cwl, '.inputs.0.label'))
  end

  def test_commandline
    assert_equal("docker run -i --rm --read-only --workdir=/private/var/spool/cwl --env=TMPDIR=/tmp --env=HOME=/private/var/spool/cwl --user=#{Process::UID.eid}:#{Process::GID.eid} -v #{Dir.pwd}:/private/var/spool/cwl docker/whalesay cowsay [ '$input' ] > #{Dir.pwd}/output",
                 cwl_inspect(@cwl, 'commandline',
                             { :args => {},
                               :runtime => { 'outdir' => File.absolute_path('.') },
                               :doc_dir => '.',
                             }))
  end

  def test_instantiated_commandline
    assert_equal("docker run -i --rm --read-only --workdir=/private/var/spool/cwl --env=TMPDIR=/tmp --env=HOME=/private/var/spool/cwl --user=#{Process::UID.eid}:#{Process::GID.eid} -v #{Dir.pwd}:/private/var/spool/cwl docker/whalesay cowsay \'Hello!\' > #{Dir.pwd}/output",
                 cwl_inspect(@cwl, 'commandline',
                             {
                               :args => { 'input' => 'Hello!' },
                               :runtime => { 'outdir' => File.absolute_path('.') },
                               :doc_dir => '.',
                             }))
  end

  def test_root_keys
    assert_equal(['class', 'cwlVersion', 'id', 'baseCommand',
                  'inputs', 'outputs', 'stdout', 'requirements'],
                 cwl_inspect(@cwl, 'keys(.)'))
  end

  def test_keys
    assert_equal(['input'],
                 cwl_inspect(@cwl, 'keys(.inputs)'))
  end
end<commit_msg>Fix tests for echo.cwl<commit_after>#!/usr/bin/env ruby
# coding: utf-8
require 'yaml'
require 'test/unit'
require_relative '../cwl/inspector'

unless defined? CWL_PATH
  CWL_PATH=File.join(File.dirname(__FILE__), '..', 'examples')
end

class TestEcho < Test::Unit::TestCase
  def setup
    @cwl = File.join(CWL_PATH, 'echo', 'echo.cwl')
    @runtime = {
      'outdir' => File.absolute_path('.'),
      'docdir' => '.',
      'tmpdir' => '/tmp',
    }
  end

  def test_version
    assert_equal('v1.0', walk(@cwl, '.cwlVersion'))
  end

  def test_id_based_access
    assert_equal('Input string', walk(@cwl, '.inputs.input.label'))
  end

  def test_index_based_access
    assert_equal('Input string', walk(@cwl, '.inputs.0.label'))
  end

  def test_commandline
    assert_equal("docker run -i --read-only --rm --workdir=/private/var/spool/cwl --env=HOME=/private/var/spool/cwl --env=TMPDIR=/tmp --user=#{Process::UID.eid}:#{Process::GID.eid} -v #{Dir.pwd}:/private/var/spool/cwl -v /tmp:/tmp docker/whalesay cowsay > #{Dir.pwd}/output",
                 commandline(@cwl, @runtime, parse_inputs(@cwl, {}, @runtime)))
  end

  def test_instantiated_commandline
    assert_equal("docker run -i --read-only --rm --workdir=/private/var/spool/cwl --env=HOME=/private/var/spool/cwl --env=TMPDIR=/tmp --user=#{Process::UID.eid}:#{Process::GID.eid} -v #{Dir.pwd}:/private/var/spool/cwl -v /tmp:/tmp docker/whalesay cowsay \'Hello!\' > #{Dir.pwd}/output",
                 commandline(@cwl, @runtime,
                             parse_inputs(@cwl, { 'input' => 'Hello!' }, @runtime)))
  end

  def test_root_keys
    assert_equal(['baseCommand', 'class', 'cwlVersion', 'id',
                  'inputs', 'outputs', 'requirements', 'stdout'],
                 keys(@cwl, '.').sort)
  end

  def test_keys
    assert_equal(['input'], keys(@cwl, '.inputs'))
  end
end
{'fraction_non_alphanumeric': 0.17884378843788437, 'fraction_numerical': 0.0019680196801968018, 'mean_word_length': 2.448685326547922, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3553691', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1378, 'n_words': 241}