Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #2430 from jruby/truffle-jt
Browse files Browse the repository at this point in the history
[Truffle] jt tool.
  • Loading branch information
chrisseaton committed Jan 6, 2015
2 parents ca55072 + c9b751d commit a191e49
Showing 1 changed file with 117 additions and 0 deletions.
117 changes: 117 additions & 0 deletions tool/jt.rb
@@ -0,0 +1,117 @@
# Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

# A workflow tool for JRuby+Truffle development

# Recommended: function jt { ruby tool/jt.rb $@; }

def sh(*args)
system args.join(' ')
raise "failed" unless $? == 0
end

def mvn(*args)
sh 'mvn', *args
end

def mspec(command, *args)
sh 'ruby', 'spec/mspec/bin/mspec', command, '--config', 'spec/truffle/truffle.mspec', *args
end

def help
puts 'jt build build'
puts 'jt clean clean'
puts 'jt rebuild clean and build'
puts 'jt test run all specs'
puts 'jt test spec/ruby/language run specs in this directory'
puts 'jt test spec/ruby/language/while_spec.rb run specs in this file'
puts 'jt tag spec/ruby/language tag failing specs in this directory'
puts 'jt tag spec/ruby/language/while_spec.rb tag failing specs in this file'
puts 'jt untag spec/ruby/language untag passing specs in this directory'
puts 'jt untag spec/ruby/language/while_spec.rb untag passing specs in this file'
puts 'jt findbugs run findbugs'
end

def build
mvn 'package'
end

def clean
mvn 'clean'
end

def rebuild
clean
build
end

def test(path=nil)
if path.nil?
mspec 'run', '--excl-tag', 'fails', ':language', ':core'
elsif path.start_with? 'spec/ruby'
mspec 'run', '--excl-tag', 'fails', path
else
raise "don't know how to test #{path}"
end
end

def tag(path)
mspec 'tag', '--add', 'fails', '--fail', path
end

def untag(path)
puts
puts "WARNING: untag is currently not very reliable - run test #{path} after and manually annotate any new failures"
puts
mspec 'tag', '--del', 'fails', '--pass', path
end

def findbugs
sh 'tool/truffle-findbugs.sh'
end

COMMANDS = [
['help'],
['build'],
['clean'],
['rebuild'],
['test'],
['test', :path],
['tag', :path],
['untag', :path],
['findbugs']
]

if [[], ['-h'], ['-help'], ['--help']].include? ARGV
help
exit
end

def match(args, command)
return false if ARGV.size != command.size

impl_args = []

command.zip(ARGV).each do |expected, actual|
if expected.is_a? String
return false if expected != actual
elsif expected.is_a? Symbol
impl_args.push actual
end
end

send command[0], *impl_args

exit
end

COMMANDS.each do |command|
match(ARGV, command)
end

raise "no command matched"

0 comments on commit a191e49

Please sign in to comment.