dtf 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +44 -0
- data/.rspec +1 -0
- data/.rvmrc +52 -0
- data/.travis.yml +16 -0
- data/Gemfile +26 -0
- data/History.md +75 -0
- data/LICENSE +19 -10
- data/README.md +67 -45
- data/Rakefile +9 -0
- data/TODO +25 -0
- data/app/models/analysis_case.rb +12 -0
- data/app/models/case_test.rb +10 -0
- data/app/models/user.rb +12 -0
- data/app/models/verification_suite.rb +22 -0
- data/bin/dtf +24 -3
- data/bin/dtf-create_user +11 -0
- data/bin/dtf-create_vs +10 -0
- data/bin/dtf-delete_user +18 -0
- data/bin/dtf-delete_vs +14 -0
- data/bin/dtf-setup +7 -0
- data/db/migrate/20120503050925_create_users.rb +15 -0
- data/db/migrate/20120508000959_create_verification_suites.rb +14 -0
- data/db/migrate/20120616203047_create_analysis_cases.rb +15 -0
- data/db/migrate/20120616203436_create_case_tests.rb +15 -0
- data/db/schema.rb +48 -0
- data/doc/.gitkeep +0 -0
- data/dtf.gemspec +36 -0
- data/examples/db/config.yml +25 -0
- data/lib/config/environment.rb +49 -0
- data/lib/dtf.rb +4 -91
- data/lib/dtf/version.rb +5 -0
- data/lib/tasks/setup.thor +52 -0
- data/spec/acceptance/0001_create_basic_models.feature +9 -0
- data/spec/acceptance/0002_create_basic_associations.feature +11 -0
- data/spec/acceptance/0003_execute_help_switch.feature +7 -0
- data/spec/fabricators/analysis_case_fabricator.rb +7 -0
- data/spec/fabricators/case_test_fabricator.rb +6 -0
- data/spec/fabricators/user_fabricator.rb +8 -0
- data/spec/fabricators/verification_suite_fabricator.rb +6 -0
- data/spec/models/analysis_case_spec.rb +21 -0
- data/spec/models/case_test_spec.rb +20 -0
- data/spec/models/user_spec.rb +21 -0
- data/spec/models/verification_suite_spec.rb +21 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/steps/feature_steps.rb +18 -0
- data/spec/support/custom_matchers/model_steps.rb +46 -0
- data/spec/support/helpers/.gitkeep +0 -0
- metadata +303 -70
- data/lib/dtf/active_patches.rb +0 -21
- data/lib/dtf/plugins.rb +0 -102
- data/lib/plugins/dtf/comment_test_input.rb +0 -40
- data/lib/plugins/dtf/env_match_test.rb +0 -18
- data/lib/plugins/dtf/error_summary_output.rb +0 -93
- data/lib/plugins/dtf/output_match_test.rb +0 -17
- data/lib/plugins/dtf/stats_output.rb +0 -73
- data/lib/plugins/dtf/status_test.rb +0 -17
- data/lib/plugins/dtf/text_output.rb +0 -52
data/app/models/user.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
|
3
|
+
class User < ActiveRecord::Base
|
4
|
+
|
5
|
+
attr_accessible :full_name, :email_address, :user_name
|
6
|
+
validates_presence_of :full_name, :email_address, :user_name
|
7
|
+
|
8
|
+
has_many :verification_suites, :dependent => :destroy
|
9
|
+
has_many :analysis_cases, :through => :verification_suites, :dependent => :destroy
|
10
|
+
has_many :case_tests, :through => :verification_suites, :dependent => :destroy
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
|
3
|
+
class VerificationSuite < ActiveRecord::Base
|
4
|
+
|
5
|
+
attr_accessible :name, :description
|
6
|
+
validates_presence_of :name, :description
|
7
|
+
|
8
|
+
belongs_to :user, :autosave => :true
|
9
|
+
has_many :analysis_cases, :dependent => :destroy
|
10
|
+
has_many :case_tests, :through => :analysis_cases, :dependent => :destroy
|
11
|
+
|
12
|
+
# ASSOCIATIONS BREAKDOWN
|
13
|
+
# ----------------------
|
14
|
+
# Each VerificationSuite is comprised of many AnalysisCases, Each AnalysisCase
|
15
|
+
# contain multiple case_tests, owned by both the User and the AnalysisCase.
|
16
|
+
# The goal is to make 'packs' of tests which Users can share between Suites,
|
17
|
+
# grouped by Cases, and even share those Tests between Cases. Also, Users
|
18
|
+
# should be able to share their individual Test(s), AnalysisCase(s), and
|
19
|
+
# VerificationSuite(s) with other Users for inclusion in their own
|
20
|
+
# AnalysisCase(s) and Suite(s) allowing for mix-and-match batching.
|
21
|
+
|
22
|
+
end
|
data/bin/dtf
CHANGED
@@ -1,7 +1,28 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This is the master script to be used to manage the various Verification Suites,
|
4
|
+
# Analysis Cases, and Case Tests
|
5
|
+
#
|
6
|
+
# Ex: dtf create_user -u|--user @user_name -n|--name "John Public" -e|--email
|
7
|
+
# "j@public.com"
|
8
|
+
#
|
9
|
+
# -u -n and -e are _required_ parameters
|
10
|
+
#
|
11
|
+
# Accessing the help system
|
12
|
+
# Ex: dtf help create_user
|
2
13
|
|
3
|
-
|
14
|
+
require 'dtf'
|
15
|
+
require 'optparse'
|
4
16
|
|
5
|
-
|
17
|
+
options = {}
|
6
18
|
|
7
|
-
|
19
|
+
OptionParser.new do |opts|
|
20
|
+
opts.banner = "Usage: dtf <cmd> [options]"
|
21
|
+
|
22
|
+
opts.on("-h", "--help",
|
23
|
+
"Show this message") do |h|
|
24
|
+
options[:help] = h
|
25
|
+
puts opts
|
26
|
+
end
|
27
|
+
|
28
|
+
end.parse!
|
data/bin/dtf-create_user
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This script is used to create User entries in the db for owning the various
|
4
|
+
# Verification Suites, Analysis Cases, and Case Tests
|
5
|
+
#
|
6
|
+
# Ex: dtf-create_user -u|--user @user_name -n|--name "John Public" -e|--email
|
7
|
+
# "j@public.com"
|
8
|
+
#
|
9
|
+
# -u -n and -e are _required_ parameters
|
10
|
+
#
|
11
|
+
|
data/bin/dtf-create_vs
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file is used to create a Verification Suite from the commandline.
|
4
|
+
# A owning User, which must already exist, must be passed for ownership.
|
5
|
+
# At minimum, the name of the suite must also be passed.
|
6
|
+
#
|
7
|
+
# Ex: dtf-create_vs -u|--user @user_name -n|--name "DTF Testing Suite"
|
8
|
+
# -u and -n are _required_ parameters
|
9
|
+
#
|
10
|
+
|
data/bin/dtf-delete_user
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This script is used to delete existing User entries in the db
|
4
|
+
# This script will also need to reassign any existing entries such as for their
|
5
|
+
# Verification Suites, Analysis Cases, and Case Tests to the Public user
|
6
|
+
# The Public user is a generic user that needs to be created initially so that
|
7
|
+
# when a user is deleted, their suites are assigned to Public if they wish to
|
8
|
+
# be kept. The deletion should ask if the suites should be permanently deleted
|
9
|
+
# or reassigned to Public.
|
10
|
+
#
|
11
|
+
# Ex: dtf-delete_user -u|--user @user_name [--all] [--reassign]
|
12
|
+
# --all means to delete all the user test suites permenantly
|
13
|
+
# --reassign means reassign test suites to the Public user for reuse by others
|
14
|
+
# first, and then delete the specified user.
|
15
|
+
#
|
16
|
+
# -u and EITHER --all OR --reassign are _required_ parameters
|
17
|
+
#
|
18
|
+
|
data/bin/dtf-delete_vs
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This script is used to delete existing Verification Suite entries in the db
|
4
|
+
# The Public user is a generic user that needs to be created initially so that
|
5
|
+
# when a user is deleted, their suites are assigned to Public if they wish to
|
6
|
+
# be kept. The deletion should ask if the suites should be permanently deleted
|
7
|
+
# or reassigned to Public. This applies to all Analysis Cases, and Case Tests
|
8
|
+
# as well
|
9
|
+
#
|
10
|
+
# Ex dtf-delete_vs -u|--user @user_name -n|--name "DTF Testing Suite"
|
11
|
+
#
|
12
|
+
# -u and -n are _required_ parameters
|
13
|
+
#
|
14
|
+
|
data/bin/dtf-setup
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateVerificationSuites < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :verification_suites do |t|
|
4
|
+
t.string :name
|
5
|
+
t.text :description
|
6
|
+
t.references :user
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
drop_table :verification_suites
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateAnalysisCases < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :analysis_cases do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :description
|
6
|
+
t.references :verification_suite
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :analysis_cases
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateCaseTests < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :case_tests do |t|
|
4
|
+
t.string :description
|
5
|
+
t.text :cmd
|
6
|
+
t.references :analysis_case
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :case_tests
|
14
|
+
end
|
15
|
+
end
|
data/db/schema.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20120616203436) do
|
15
|
+
|
16
|
+
create_table "analysis_cases", :force => true do |t|
|
17
|
+
t.string "name"
|
18
|
+
t.string "description"
|
19
|
+
t.integer "verification_suite_id"
|
20
|
+
t.datetime "created_at", :null => false
|
21
|
+
t.datetime "updated_at", :null => false
|
22
|
+
end
|
23
|
+
|
24
|
+
create_table "case_tests", :force => true do |t|
|
25
|
+
t.string "description"
|
26
|
+
t.text "cmd"
|
27
|
+
t.integer "analysis_case_id"
|
28
|
+
t.datetime "created_at", :null => false
|
29
|
+
t.datetime "updated_at", :null => false
|
30
|
+
end
|
31
|
+
|
32
|
+
create_table "users", :force => true do |t|
|
33
|
+
t.string "full_name"
|
34
|
+
t.string "user_name"
|
35
|
+
t.string "email_address"
|
36
|
+
t.datetime "created_at", :null => false
|
37
|
+
t.datetime "updated_at", :null => false
|
38
|
+
end
|
39
|
+
|
40
|
+
create_table "verification_suites", :force => true do |t|
|
41
|
+
t.string "name"
|
42
|
+
t.text "description"
|
43
|
+
t.integer "user_id"
|
44
|
+
t.datetime "created_at", :null => false
|
45
|
+
t.datetime "updated_at", :null => false
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/doc/.gitkeep
ADDED
File without changes
|
data/dtf.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/dtf/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Deryl R. Doucette"]
|
6
|
+
gem.email = ["me@deryldoucette.com"]
|
7
|
+
gem.description = %q{DTF is a modular testing framework skeleton. This is the control gem which contains the Suite's db schema(s) and control/management scripts.}
|
8
|
+
gem.summary = %q{DTF is a modular testing framework. This is the control gem.}
|
9
|
+
gem.homepage = "https://github.com/dtf-gems/dtf"
|
10
|
+
gem.license = 'MIT'
|
11
|
+
gem.platform = Gem::Platform::RUBY
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = "dtf"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = Dtf::VERSION
|
18
|
+
gem.rubyforge_project = "dtf"
|
19
|
+
gem.required_ruby_version = ">= 1.9.3"
|
20
|
+
|
21
|
+
gem.add_dependency "thor"
|
22
|
+
gem.add_dependency "rake"
|
23
|
+
gem.add_dependency "activerecord"
|
24
|
+
gem.add_dependency "activemodel"
|
25
|
+
gem.add_dependency "activesupport"
|
26
|
+
gem.add_dependency "sqlite3"
|
27
|
+
gem.add_dependency "json"
|
28
|
+
gem.add_dependency "json_pure"
|
29
|
+
gem.add_dependency "standalone_migrations"
|
30
|
+
|
31
|
+
gem.add_development_dependency "turnip"
|
32
|
+
gem.add_development_dependency "rspec", [">=2.10.0"]
|
33
|
+
gem.add_development_dependency "fabrication"
|
34
|
+
gem.add_development_dependency "vcr"
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/dtf_development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/dtf_test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/dtf_production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
|
3
|
+
# Application wide requirements
|
4
|
+
require 'active_record'
|
5
|
+
require 'active_model'
|
6
|
+
require 'active_support'
|
7
|
+
require 'multi_json'
|
8
|
+
require 'sqlite3'
|
9
|
+
require 'yaml'
|
10
|
+
require 'logger'
|
11
|
+
require 'thor'
|
12
|
+
|
13
|
+
# NOTE: Set RAILS_ENV to 'production' for ActiveRecord. Affects the database to use.
|
14
|
+
# Change this to 'development' while working on the gem itself, or set it in the
|
15
|
+
# environment prefixed to commands, in order to gain access to testing gems.
|
16
|
+
ENV['RAILS_ENV'] ||= 'development'
|
17
|
+
|
18
|
+
# This section is for development and testing. Load your testing framework(s) require's here
|
19
|
+
case ENV['RAILS_ENV']
|
20
|
+
when 'development', 'test'
|
21
|
+
require 'rspec'
|
22
|
+
require 'turnip'
|
23
|
+
require 'pry'
|
24
|
+
require 'pry-debugger'
|
25
|
+
require 'pry-doc'
|
26
|
+
require 'pry-stack_explorer'
|
27
|
+
require 'pry-exception_explorer'
|
28
|
+
require 'pry-git'
|
29
|
+
require 'pry-editline'
|
30
|
+
require 'pry-highlight'
|
31
|
+
require 'pry-buffers'
|
32
|
+
require 'pry-developer_tools'
|
33
|
+
require 'pry-syntax-hacks'
|
34
|
+
require 'fabrication'
|
35
|
+
else
|
36
|
+
true
|
37
|
+
end
|
38
|
+
|
39
|
+
# Load the db config and create a connectoid. Make an ivar so its shared throughout the application
|
40
|
+
@dbconfig = YAML::load(File.open(File.join(File.dirname(__FILE__), '../../db/config.yml')))[ENV['RAILS_ENV']]
|
41
|
+
|
42
|
+
# Establish the database connection
|
43
|
+
ActiveRecord::Base.establish_connection(@dbconfig) # Line that actually connects the db.
|
44
|
+
|
45
|
+
# Load all the models
|
46
|
+
Dir["#{File.join(File.dirname(__FILE__), '../../app/models/*.rb')}"].each do |model|
|
47
|
+
load "#{model}"
|
48
|
+
end
|
49
|
+
|
data/lib/dtf.rb
CHANGED
@@ -1,94 +1,7 @@
|
|
1
|
-
|
2
|
-
require 'singleton'
|
3
|
-
require 'yaml'
|
4
|
-
require 'session'
|
1
|
+
# -*- coding: UTF-8 -*-
|
5
2
|
|
6
|
-
|
3
|
+
require "dtf/version"
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
class DTF; end
|
12
|
-
# load dtf/*.rb
|
13
|
-
Dir["#{lib_root}/dtf/*.rb"].each{|lib| require lib }
|
14
|
-
|
15
|
-
class DTF
|
16
|
-
def initialize
|
17
|
-
@ruby = File.join(RbConfig::CONFIG["bindir"],RbConfig::CONFIG["ruby_install_name"])
|
18
|
-
@plugins = DTF::Plugins.instance
|
19
|
-
@failures = 0
|
20
|
-
end
|
21
|
-
|
22
|
-
def run_tests args
|
23
|
-
@plugins.load(%w( all_test ))
|
24
|
-
input_files, not_processed = @plugins.parse_args(args)
|
25
|
-
if not_processed.size > 0
|
26
|
-
$stderr.puts "No plugin recognized this option '#{not_processed*" "}'."
|
27
|
-
exit 1
|
28
|
-
end
|
29
|
-
@plugins.load(%w( ErrorSummaryOutput )) if @plugins.output_plugins.empty?
|
30
|
-
process(input_files)
|
31
|
-
@failures == 0
|
32
|
-
end
|
33
|
-
|
34
|
-
def process input_files
|
35
|
-
@plugins.output_plugins(:start_processing)
|
36
|
-
input_files.each do |plugin,file|
|
37
|
-
process_test( plugin.load(file) )
|
38
|
-
end
|
39
|
-
@plugins.output_plugins(:end_processing)
|
40
|
-
end
|
41
|
-
|
42
|
-
def env shell
|
43
|
-
Hash[ shell.execute(
|
44
|
-
@ruby + ' -e \'ENV.each{|k,v| printf "#{k}=#{v}\0"}\''
|
45
|
-
)[0].split("\0").map{|var| var.split('=', 2) } ]
|
46
|
-
end
|
47
|
-
|
48
|
-
def process_test test
|
49
|
-
name, commands = test[:name], test[:commands]
|
50
|
-
shell = Session::Bash.new
|
51
|
-
_env = env(shell)
|
52
|
-
@plugins.output_plugins(:start_test, test, _env)
|
53
|
-
commands.each do |line|
|
54
|
-
command, tests = line[:cmd], line[:tests]
|
55
|
-
@plugins.output_plugins(:start_command, line)
|
56
|
-
_stdout = StringIO.new
|
57
|
-
_stderr = StringIO.new
|
58
|
-
_stdboth = StringIO.new
|
59
|
-
shell.execute "#{command}" do |out, err|
|
60
|
-
if out
|
61
|
-
@plugins.output_plugins(:command_out, out)
|
62
|
-
_stdout << out
|
63
|
-
_stdboth << out
|
64
|
-
end
|
65
|
-
if err
|
66
|
-
@plugins.output_plugins(:command_err, err)
|
67
|
-
_stderr << err
|
68
|
-
_stdboth << err
|
69
|
-
end
|
70
|
-
end
|
71
|
-
_status = shell.status
|
72
|
-
_env = env(shell)
|
73
|
-
@plugins.output_plugins(:end_command, line, _status, _env)
|
74
|
-
process_command_tests _stdout.string, _stderr.string, _stdboth.string, _status, _env, tests
|
75
|
-
end
|
76
|
-
@plugins.output_plugins(:end_test, test)
|
77
|
-
end
|
78
|
-
|
79
|
-
def process_command_tests _stdout, _stderr, _stdboth, _status, env, tests
|
80
|
-
tests.each do |test|
|
81
|
-
plugin = @plugins.test_plugins.find{|_plugin| _plugin.matches? test }
|
82
|
-
if plugin.nil?
|
83
|
-
status, msg = false, "Could not find plugin for test '#{test}'."
|
84
|
-
else
|
85
|
-
status, msg = plugin.execute(test, _stdout, _stderr, _stdboth, _status, env)
|
86
|
-
end
|
87
|
-
@failures+=1 unless status
|
88
|
-
@plugins.output_plugins(:test_processed, test, status, msg)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
class << self
|
93
|
-
end
|
5
|
+
module Dtf
|
6
|
+
load "#{File.join(File.dirname(__FILE__), "/config/environment.rb")}"
|
94
7
|
end
|