Sha256: f3ce158e9a8c1582d8219ec03f4ff6fec5bdbb9c27573b746ddfd4f86fd844b1

Contents?: true

Size: 1.62 KB

Versions: 4

Compression:

Stored size: 1.62 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require_relative '../lib/tryouts'

# Adding local lib directories allows the test files
# to require the ruby code they are testing without
# needing even if the files use regular requires. It
# skips the test files from having to muck with the
# load path or use `require_relative` which is easy
# to forget. This is a convenience feature.
#
# Here we're looking for directories relative to the
# current working directory (i.e. where this script
# is being run from.
lib_glob = File.join(Dir.pwd, '{lib,../lib,.}')
Tryouts.update_load_path(lib_glob)

# Parse command-line arguments
OptionParser.new do |opts|
  opts.on('-V', '--version', 'Display the version') do
    puts "Tryouts: #{Tryouts::VERSION}"
    exit
  end
  opts.on('-q', '--quiet', 'Run in quiet mode') { Tryouts.quiet = true }
  opts.on('-v', '--verbose', 'Run in verbose mode') { Tryouts.noisy = true }
  opts.on('-f', '--fails', 'Show only failing tryouts') { Tryouts.fails = true }
  opts.on('-D', '--debug', 'Run in debug mode') { Tryouts.debug = true }
  opts.on('-h', '--help', 'Display this help') do
    puts opts
    exit
  end
end.parse!

# Find tryouts path with a path glob unless thin
# script was called with arguments in which case
# we consume those as a list of paths.
paths = if ARGV.empty?
          Dir.glob(
            ['./{try,tryouts/,.}/*_{try,tryouts}.rb'],
            base: Dir.pwd
          ).sort # deterministic order

        else
          ARGV
        end

# Running the tryouts returns the number of
# test failures so here we pass that value
# through as the exit code for the script.
exit Tryouts.run_all(*paths)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tryouts-2.4.1 exe/try
tryouts-2.4.0 exe/try
tryouts-2.3.2 exe/try
tryouts-2.3.1 exe/try