dtm 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf395d4e920a64bd54d96b9a1ce8fd43f9e972fe
4
- data.tar.gz: ace8f79feafaea29ae66328fb6d458abd9931ac6
3
+ metadata.gz: 356f199bc9910cbf6bbd1f4f632ace987aa419ca
4
+ data.tar.gz: 338550eeb95a1b4e7fadf2dc9e69de49afcc17c4
5
5
  SHA512:
6
- metadata.gz: 8de747d449ee92b2f2957040c8614376ecbec0619e79cc875ef8b1a2d01b959e3887bb8202d8fc02fdaf2ce3bd03d7ed4f4d0d387fff65cca19564835cf8b468
7
- data.tar.gz: 78b05c5bc3dec9f245dc91544bdec340920fb2b8816be4d235852ce36b5d9ee4d69e5db92c1729656b651c9d7871b518439ab6c54d006bfd69e7e115aab3c9dd
6
+ metadata.gz: e9095d7631cbbb45f5f00c5678b735083e1ac56d5317f8bce5aa2ac0bf29ece7719bf6706abdd77048df06a768267b59b90422d438238388eca2a6e5a6b59b8f
7
+ data.tar.gz: b4f5e53e6256c7e22da7e0ba57b703ac6b67100fa92a0ab26bab3fe961ebdf1caa8528662c0f49799c51c7d4697e036c177a0bdf0ef592b002266e1e13e7a8b9
data/Rakefile CHANGED
@@ -1,4 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
1
3
  require "bundler/gem_tasks"
2
4
  require 'rake/testtask'
3
5
 
4
- Rake::TestTask.new
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'lib' << 'test'
8
+ end
data/lib/dtm.rb CHANGED
@@ -2,6 +2,7 @@ require "dtm/version"
2
2
  require "dtm/job"
3
3
  require 'dtm/schedule'
4
4
  require 'dtm/dtm'
5
+ require 'dtm/task_desc'
5
6
 
6
7
  module Dtm
7
8
  # Your code goes here...
@@ -15,13 +15,13 @@ end
15
15
  module Dtm
16
16
  class Dtm
17
17
  def self.instance(data_store)
18
- wttcl = 'C:\\Program Files\\Microsoft Driver Test Manager\\Studio\\wttcl.exe'
18
+ wttcl = 'C:\Program Files\Microsoft Driver Test Manager\Studio\wttcl.exe'
19
19
  return Dtm.new(wttcl, data_store) if File.exist?(wttcl)
20
20
 
21
- wttcl = 'C:\\Program Files (x86)\\Microsoft Driver Test Manager\\Studio\\wttcl.exe'
21
+ wttcl = 'C:\Program Files (x86)\Microsoft Driver Test Manager\Studio\wttcl.exe'
22
22
  return Dtm.new(wttcl, data_store) if File.exist?(wttcl)
23
23
 
24
- raise
24
+ raise 'ERROR: fail to find wttcl.exe'
25
25
  end
26
26
 
27
27
  def initialize(wttcl, data_store)
@@ -37,15 +37,13 @@ module Dtm
37
37
  Schedule.new(self, schedule_id)
38
38
  end
39
39
 
40
- def machines(machine_pool)
41
- self.set_machine_status(:machine_pool => machine_pool) do |stdout|
42
- stdout.split("\n").collect {|line| line.scan(/\[\w+\]/) if line.match(/Machine \[\w+\] \(ID \d+\) is in \[\w+\] state./)}.compact
43
- end
44
- end
40
+ def machines(machine_pool, params = {})
41
+ params[:machine_pool] = machine_pool
42
+
43
+ self.set_machine_status(params) do |stdout|
44
+ raise stdout if stdout.match(/^ERROR:/)
45
45
 
46
- def availabe_machines(params)
47
- self.method_missing(:setmachinestatus, params) do |stdout|
48
- stdout.split("\n").collect{|line| line.scan(/\[\w+\]/) if line.match(/Machine \[\w+\] \(ID \d+\) is in \[\w+\] state./)}.compact
46
+ stdout.split("\n").collect {|line| line.scan(/\[\w+\]/) if line.match(/Machine \[\w+\] \(ID \d+\) is in \[\w+\] state./)}.compact
49
47
  end
50
48
  end
51
49
 
@@ -66,17 +64,20 @@ module Dtm
66
64
  params[:type] ||= "Automated"
67
65
 
68
66
  self.method_missing(:add_job, params) do |stdout|
69
- return self.job(stdout.slice(/\d+/)) if stdout.match(/Job Created Successfully with ID=\d+/)
70
- raise
67
+ raise stdout unless stdout.match(/Job Created Successfully with ID=\d+/)
68
+
69
+ self.job(stdout.slice(/\d+/))
71
70
  end
72
71
  end
73
72
 
74
73
  #FIXME design choice, put stdout processing here or leave it to job?
75
74
  def schedule_job(params)
76
75
  self.method_missing(:schedule_job, params) do |stdout|
76
+ raise stdout if stdout.match(/^\[?ERROR/)
77
+
77
78
  stdout.split("\n").select {|line| line.match(/Schedule Created with Id \d+/)}
78
- .collect {|line| line.slice(/\d+/)}
79
- .collect {|schedule_id| self.schedule(schedule_id)}
79
+ .map {|line| line.slice(/\d+/)}
80
+ .map {|schedule_id| self.schedule(schedule_id)}
80
81
  end
81
82
  end
82
83
 
@@ -0,0 +1,23 @@
1
+ module Dtm
2
+ class ExecuteTaskDesc
3
+ class << self
4
+ def desc(params)
5
+ ExecuteTaskDesc.new(params).desc
6
+ end
7
+ end
8
+
9
+ def initialize(params)
10
+ params[:type] = "Execute"
11
+ params[:execution_phase] ||= "Regular"
12
+ params[:failure_action] ||= "FailAndStop"
13
+ #FIXME should we do this for user?
14
+ params[:command_line] = "\"#{params[:command_line]}\""
15
+
16
+ @params = params
17
+ end
18
+
19
+ def desc
20
+ @params
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Dtm
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,5 +1,4 @@
1
- require 'simplecov'
2
- SimpleCov.start
1
+ require 'test_helper'
3
2
  require 'test/unit'
4
3
  require 'dtm'
5
4
 
@@ -0,0 +1,2 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruijia Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-13 00:00:00.000000000 Z
11
+ date: 2013-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,8 +70,10 @@ files:
70
70
  - lib/dtm/dtm.rb
71
71
  - lib/dtm/job.rb
72
72
  - lib/dtm/schedule.rb
73
+ - lib/dtm/task_desc.rb
73
74
  - lib/dtm/version.rb
74
75
  - test/test_dtm.rb
76
+ - test/test_helper.rb
75
77
  homepage: https://github.com/rli9/dtm
76
78
  licenses:
77
79
  - MIT
@@ -99,3 +101,4 @@ summary: A ruby wrapper for Microsoft DTM (Driver Test Manager) console applicat
99
101
  wttcl.exe
100
102
  test_files:
101
103
  - test/test_dtm.rb
104
+ - test/test_helper.rb