Module: Jstdutil

Defined in:
lib/jstdutil.rb,
lib/jstdutil/cli.rb,
lib/jstdutil/autotest.rb,
lib/jstdutil/redgreen.rb,
lib/jstdutil/formatter.rb,
lib/jstdutil/test_file.rb,
lib/jstdutil/test_runner.rb,
lib/jstdutil/colorful_html.rb,
lib/jstdutil/jstestdriver/config.rb

Overview

require “jstdutil/autotest”

Defined Under Namespace

Modules: JsTestDriver Classes: Autotest, Cli, ColorfulHtml, Formatter, RedGreen, TestFile, TestRunner

Class Method Summary collapse

Class Method Details

.install_dirObject



7
8
9
# File 'lib/jstdutil.rb', line 7

def self.install_dir
  File.expand_path(File.dirname(__FILE__))
end

.jar(classpath = ENV["JSTESTDRIVER_HOME"] || Dir.pwd) ⇒ Object

Locate Jar file from a given path. Default classpath is $JSTDUTIL_HOME Finds and returns the first file matching jstest*.jar (case insensitive). Also checks current working directory



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jstdutil.rb', line 16

def self.jar(classpath = ENV["JSTESTDRIVER_HOME"] || Dir.pwd)
  files = Dir.glob(File.expand_path(File.join(classpath, 'jstest*.jar')),
                   File::FNM_CASEFOLD)
  files.sort! { |f1, f2| f1.downcase <=> f2.downcase }

  if !files || !files.first
    msg = "Unable to load jar file from #{classpath}\n" <<
          "Check that $JSTESTDRIVER_HOME is set correctly"
    raise FileNotFoundError.new(msg)
  end

  files[-1]
end

.run(args, jar) ⇒ Object

Run the jar through the java command



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jstdutil.rb', line 33

def self.run(args, jar)
  begin
    res = `java -jar #{jar} #{args}`
    $exit_status = $?
    return res
  rescue Exception => err
    puts "Unable to run java command. This probably means java is not available " +
      "on your path. Original error was"
    puts err.message
  end
end