mirror of
https://github.com/michaeldv/pit.git
synced 2025-12-10 08:25:34 +00:00
First incarnation of Ruby-based pit test suite
This commit is contained in:
4
Makefile
4
Makefile
@@ -79,3 +79,7 @@ clean:
|
|||||||
rmdir $(OBJDIR)
|
rmdir $(OBJDIR)
|
||||||
rmdir $(BINDIR)
|
rmdir $(BINDIR)
|
||||||
|
|
||||||
|
.PHONY : test
|
||||||
|
test:
|
||||||
|
./test/pit_test.rb
|
||||||
|
rm -f ./test/.pitfile
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ time_t pit_arg_date(char **arg, char *required)
|
|||||||
strcpy(format, "%m/%d/%Y %H:%M"); /* 10/10/1992 19:30 */
|
strcpy(format, "%m/%d/%Y %H:%M"); /* 10/10/1992 19:30 */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (strlen(*arg) > 12) {
|
if (strlen(*arg) >= 12) {
|
||||||
if (alpha_date) {
|
if (alpha_date) {
|
||||||
strcpy(format, "%b %d, %Y %H"); /* Oct 10, 1992 19 */
|
strcpy(format, "%b %d, %Y %H"); /* Oct 10, 1992 19 */
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
3
src/db.c
3
src/db.c
@@ -12,7 +12,8 @@ static char *pit_file_name()
|
|||||||
static char file_name[128];
|
static char file_name[128];
|
||||||
|
|
||||||
if (!*file_name) {
|
if (!*file_name) {
|
||||||
strcpy(file_name, expand_path(PITFILE, file_name));
|
char *penv = getenv("PITFILE");
|
||||||
|
strcpy(file_name, expand_path(penv ? penv : PITFILE, file_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
return file_name;
|
return file_name;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class Hand < RuntimeError
|
class Hand < RuntimeError
|
||||||
def oops(msg)
|
def oops(msg)
|
||||||
puts "\n#{msg} in #{self.backtrace[-1].sub(':', ' line ')}"
|
puts "\n#{msg} in #{self.backtrace[1].sub(':', ' line ')}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -42,17 +42,18 @@ class String
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
"123".should.equal "123"
|
if $0 == __FILE__
|
||||||
"123".should.equal "321"
|
"123".should.equal "123"
|
||||||
|
"123".should.equal "321"
|
||||||
|
|
||||||
"123".should_not.equal "321"
|
"123".should_not.equal "321"
|
||||||
"123".should_not.equal "123"
|
"123".should_not.equal "123"
|
||||||
|
|
||||||
"abc".should.match /B/i
|
"abc".should.match /B/i
|
||||||
"abc".should.match /xyz/
|
"abc".should.match /xyz/
|
||||||
|
|
||||||
"abc".should_not.match /xyz/
|
|
||||||
"abc".should_not.match /abc/
|
|
||||||
|
|
||||||
|
"abc".should_not.match /xyz/
|
||||||
|
"abc".should_not.match /abc/
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
80
test/pit_test.rb
Executable file
80
test/pit_test.rb
Executable file
@@ -0,0 +1,80 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
#
|
||||||
|
BASE = File.dirname(File.expand_path(__FILE__))
|
||||||
|
require "#{BASE}/pit_should"
|
||||||
|
|
||||||
|
class PitTestRunner
|
||||||
|
def self.run
|
||||||
|
runner = self.new
|
||||||
|
runner.public_methods.grep(/^should_/).each do |method|
|
||||||
|
runner.send(:before) if runner.respond_to?(:before)
|
||||||
|
runner.send(method)
|
||||||
|
runner.send(:after) if runner.respond_to?(:after)
|
||||||
|
end
|
||||||
|
puts
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@pit = "#{BASE.sub(/test$/, 'bin')}/pit"
|
||||||
|
if File.executable?(@pit)
|
||||||
|
ENV['PITFILE'] = "#{BASE}/test.pitfile"
|
||||||
|
puts "Testing #{@pit} with #{ENV['PITFILE']}"
|
||||||
|
else
|
||||||
|
raise("\nCould not run #{@pit}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def before
|
||||||
|
`#{@pit} init -f`
|
||||||
|
`#{@pit} project -c test`
|
||||||
|
end
|
||||||
|
|
||||||
|
def should_parse_alpha_dates
|
||||||
|
`#{@pit} task -c test -d "dec 1, 2011 19:30"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, 2011 19:30/m
|
||||||
|
`#{@pit} task -c test -d "dec 1, 2012 1:15pm"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, 2012 13:15/m
|
||||||
|
`#{@pit} task -c test -d "dec 1, 2013 11"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, 2013 11:00/m
|
||||||
|
`#{@pit} task -c test -d "dec 1, 2013 7pm"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, 2013 19:00/m
|
||||||
|
`#{@pit} task -c test -d "dec 1, 2013"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, 2013 /m
|
||||||
|
`#{@pit} task -c test -d "dec 1 5:55"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} 05:55/m
|
||||||
|
`#{@pit} task -c test -d "dec 1 2:40pm"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} 14:40/m
|
||||||
|
# `#{@pit} task -c test -d "dec 1 5"`
|
||||||
|
# `#{@pit} task`.should.match /Dec 01, #{Time.now.year} 05:00/m
|
||||||
|
# `#{@pit} task -c test -d "dec 1 3pm"`
|
||||||
|
# `#{@pit} task`.should.match /Dec 01, #{Time.now.year} 15:00/m
|
||||||
|
`#{@pit} task -c test -d "dec 1"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} /m
|
||||||
|
end
|
||||||
|
|
||||||
|
def should_parse_slash_dates
|
||||||
|
`#{@pit} task -c test -d "12/1/2011 19:30"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, 2011 19:30/m
|
||||||
|
`#{@pit} task -c test -d "12/1/2012 1:15pm"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, 2012 13:15/m
|
||||||
|
`#{@pit} task -c test -d "12/1/2013 11"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, 2013 11:00/m
|
||||||
|
`#{@pit} task -c test -d "12/1/2013 7pm"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, 2013 19:00/m
|
||||||
|
`#{@pit} task -c test -d "12/1/2013"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, 2013 /m
|
||||||
|
`#{@pit} task -c test -d "12/1 5:55"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} 05:55/m
|
||||||
|
`#{@pit} task -c test -d "12/1 2:40pm"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} 14:40/m
|
||||||
|
# `#{@pit} task -c test -d "12/1 5"`
|
||||||
|
# `#{@pit} task`.should.match /Dec 01, #{Time.now.year} 05:00/m
|
||||||
|
# `#{@pit} task -c test -d "12/1 3pm"`
|
||||||
|
# `#{@pit} task`.should.match /Dec 01, #{Time.now.year} 15:00/m
|
||||||
|
`#{@pit} task -c test -d "12/1"`
|
||||||
|
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} /m
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
PitTestRunner.run
|
||||||
BIN
test/test.pitfile
Normal file
BIN
test/test.pitfile
Normal file
Binary file not shown.
Reference in New Issue
Block a user