calypso 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 18c02c94d3be06550f507b2e2318c3f5e7dea130
4
+ data.tar.gz: 531ef2d2eb7dcaacfbd3eee8c02053e3fa9d18d4
5
+ SHA512:
6
+ metadata.gz: ed43a49b4a8acbd8b8ebc1aefb31efd589de49f4e8d9aebb61a0d697285f1b6889723c9920119fe14146902a119c15e7169abc00b44df8e9c17aa64fb0b38bf0
7
+ data.tar.gz: 7eb5682cfd6d3a12eddce97027f7efa095ce5237f9f7447cefe24cab306230c0f784e67d4f7585b808a2b79fbf4aa2d82b1bed9bffc680776acf37903ef5d2dd
data/bin/calypso ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ STDOUT.sync = true
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w(.. lib)))
5
+
6
+ require 'calypso'
7
+
8
+ Calypso.start(ARGV)
9
+
@@ -0,0 +1,23 @@
1
+ #
2
+ # Calypso version
3
+ # Copyright (C) 2016 Michel Megens <dev@bietje.net>
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #
18
+
19
+ #
20
+ module Calypso
21
+ # Calypso version constant
22
+ VERSION = '0.1.0'
23
+ end
data/lib/calypso.rb ADDED
@@ -0,0 +1,183 @@
1
+ #
2
+ # Calypso module
3
+ # Copyright (C) 2016 Michel Megens <dev@bietje.net>
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #
18
+
19
+ require 'pp'
20
+ require 'optparse'
21
+ require 'optparse/time'
22
+ require 'ostruct'
23
+
24
+ require 'calypso/version'
25
+ require 'calypso/hardware'
26
+ require 'calypso/version'
27
+ require 'calypso/parserproxy'
28
+
29
+ # Calypso base module
30
+ module Calypso
31
+ class << self
32
+ attr_reader :options
33
+
34
+ # Start Calypso.
35
+ #
36
+ # @param args [Array] Argument list
37
+ # @return [nil]
38
+ def start(args)
39
+ options = OpenStruct.new
40
+ options.parser = nil
41
+ options.config = nil
42
+ options.path = Dir.pwd
43
+ options.single = nil
44
+ options.bare = false
45
+ options.hardware = nil
46
+ options.run_mode = :all
47
+
48
+ parser = OptionParser.new do |p|
49
+ p.banner = "Usage: calypso [options] -c [config]"
50
+ p.separator ""
51
+ p.separator "Specific options:"
52
+
53
+ p.on('-y', '--yaml', "Parse configuration as YAML") do
54
+ options.parser = :yaml
55
+ end
56
+
57
+ p.on('-b', '--bare', "Do not recompile ETA/OS before running the test") do
58
+ options.bare = true
59
+ end
60
+
61
+ p.on('-t [TESTID]', '--test [TESTID]',
62
+ 'Run a specific test') do |id|
63
+ options.single = id
64
+ options.run_mode = :single
65
+ end
66
+
67
+ p.on('-c [FILE]', '--config [FILE]',
68
+ 'Path to the test configuration') do |conf|
69
+ options.config = conf
70
+ end
71
+
72
+ p.on('-H [hardware-id]', '--hardware [hardware-id]',
73
+ 'Run all tests configured for a specific MCU') do |hardware|
74
+ options.hardware = hardware
75
+ options.run_mode = :hardware
76
+ end
77
+
78
+ p.separator ""
79
+ p.separator "Common options:"
80
+
81
+ p.on_tail("-h", "--help", "Show this message") do
82
+ puts p
83
+ exit
84
+ end
85
+
86
+ p.on_tail("-v", "--version", "Print the Calypso version") do
87
+ puts "Calypso #{Calypso::VERSION}"
88
+ exit
89
+ end
90
+ end
91
+
92
+ parser.parse!
93
+
94
+ mandatory = [:config, :parser]
95
+ missing = mandatory.select do |param|
96
+ if options[param].nil? or options[param] == false
97
+ param
98
+ end
99
+ end
100
+
101
+ unless missing.empty?
102
+ puts "Missing mandatory options!"
103
+ puts ""
104
+ puts parser
105
+ exit
106
+ end
107
+
108
+ unless options.single.nil? or options.hardware.nil?
109
+ puts "The options -t and -H cannot be used together!"
110
+ puts ""
111
+ puts parser
112
+ exit
113
+ end
114
+
115
+ @options = options
116
+ config = Calypso::ParserProxy.new(options.parser, options.config)
117
+ config.parse
118
+
119
+ case options.run_mode
120
+ when :all
121
+ Calypso.run(config)
122
+ when :hardware
123
+ Calypso.run_hardware(config, options.hardware)
124
+ when :single
125
+ Calypso.run_single(config, options.single)
126
+ end
127
+ end
128
+
129
+ # Run a single test.
130
+ #
131
+ # @param parser [Calypso::ParserProxy] Configuration parser.
132
+ # @param testid [String] Test identifier.
133
+ # @return [nil]
134
+ def run_single(parser, testid)
135
+ test = parser.tests[testid]
136
+ puts "Running test [#{test.name}]"
137
+
138
+ test.execute
139
+ puts "[#{test.name}]: #{test.success? ? 'OK' : 'FAIL'}"
140
+ end
141
+
142
+ # Run all tests for a specific piece of hardware.
143
+ #
144
+ # @param config [Calypso::ParserProxy] Configuration parser.
145
+ # @param hwid [String] Hardware ID.
146
+ # @return [nil]
147
+ def run_hardware(config, hwid)
148
+ hw = config.hardware[hwid]
149
+ tests = hw.tests
150
+ puts "Running #{hw.name} tests. Press enter to continue..."
151
+ gets
152
+
153
+ tests.each do |test|
154
+ next unless test.autorun
155
+ test.execute
156
+ success = "successfully" if test.success?
157
+ success = "unsuccessfully" unless test.success?
158
+ puts ""
159
+ puts "#{test.name} ran #{success}!"
160
+ puts ""
161
+ end
162
+
163
+ puts "Unit test results:\n"
164
+ tests.each do |test|
165
+ next unless test.autorun
166
+ puts "[#{test.name}]: #{test.success? ? 'OK' : 'FAIL'}"
167
+ end
168
+ end
169
+
170
+ # Run all unit tests.
171
+ #
172
+ # @param parser [Calypso::ParserProxy] Configuration parser.
173
+ # @return [nil]
174
+ def run(parser)
175
+ hw = parser.hardware
176
+
177
+ hw.each do |hwid, hwdata|
178
+ Calypso.run_hardware(parser, hwid)
179
+ end
180
+ end
181
+ end
182
+ end
183
+
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: calypso
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michel Megens
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 3.4.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.4.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: serialport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.0
69
+ description: Automate tests for embedded system based on a specific configuration.
70
+ email:
71
+ - dev@bietje.net
72
+ executables:
73
+ - calypso
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - bin/calypso
78
+ - lib/calypso.rb
79
+ - lib/calypso/version.rb
80
+ homepage: http://etaos.bietje.net/calypso
81
+ licenses:
82
+ - GPLv3
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.4.8
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Embedded test automation.
104
+ test_files: []
105
+ has_rdoc: