File: add_test.rb

package info (click to toggle)
tagua 1.0~alpha2-15
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 8,028 kB
  • ctags: 7,178
  • sloc: cpp: 26,149; ansic: 13,039; makefile: 182; ruby: 87; sh: 39
file content (27 lines) | stat: -rwxr-xr-x 503 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/ruby
require 'erb'

def usage
  warn "Usage: #$0 [(-f | --filename) FILENAME] TEST_NAME [TEST] [TEST] ..."
  exit 1
end

arg = ARGV.shift or usage
if arg =~ /^-/
  case arg
  when '-f', '--filename'
    @filename = ARGV.shift or usage
  else
    usage
  end
else
  @name = arg
  @filename = @name.downcase
end
@tests = ARGV

%w(cpp h).each do |ext|
  File.open("#{@name.downcase}.#{ext}",'w') do |file|
    file.write(ERB.new(File.open("template.#{ext}.erb").read).result(binding))
  end
end