Skip to content

Commit 341034d

Browse files
committed
add CI script to gem
1 parent 64e272d commit 341034d

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ script:
1313
- bundle exec rubocop --version
1414
- bundle exec rubocop -D .
1515
- bundle exec rspec
16+
- bundle exec ci_system_check.rb

arduino_ci.gemspec

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ Gem::Specification.new do |spec|
1414
spec.description = spec.description
1515
spec.homepage = "http://github.com/ifreecarve/arduino_ci"
1616

17-
spec.files = ['README.md', '.yardopts'] + Dir['lib/**/*.*'].reject { |f| f.match(%r{^(test|spec|features)/}) }
18-
1917
spec.bindir = "exe"
18+
rejection_regex = %r{^(test|spec|features)/}
19+
libfiles = Dir['lib/**/*.*'].reject { |f| f.match(rejection_regex) }
20+
binfiles = Dir[File.join(spec.bindir, '/**/*.*')].reject { |f| f.match(rejection_regex) }
21+
spec.files = ['README.md', '.yardopts'] + libfiles + binfiles
22+
2023
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2124
spec.require_paths = ["lib"]
2225

exe/ci_system_check.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require 'arduino_ci'
2+
3+
puts "Enabling display with display manager"
4+
ArduinoCI::DisplayManager::instance.enable
5+
6+
puts "Autlocating Arduino command"
7+
arduino_cmd = ArduinoCI::ArduinoCmd.autolocate!
8+
9+
board_tests = {
10+
"arduino:avr:uno" => true,
11+
"eggs:milk:wheat" => false,
12+
}
13+
14+
got_problem = false
15+
board_tests.each do |k, v|
16+
puts "I expect arduino_cmd.board_installed?(#{k}) to be #{v}"
17+
result = arduino_cmd.board_installed?(k)
18+
puts " board_installed?(#{k}) returns #{result}. expected #{v}"
19+
got_problem = true if v != result
20+
end
21+
22+
abort if got_problem
23+
exit(0)

lib/arduino_ci/arduino_cmd.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ def initialize(installation)
2626
@installation = installation
2727
end
2828

29+
def run(*args)
30+
full_args = [@installation.cmd_path] + args
31+
puts "Running $ #{full_args.join(' ')}"
32+
system(*full_args)
33+
end
34+
2935
def board_installed?(board)
30-
system(@installation, "--board", board)
36+
run("--board", board)
3137
end
3238

3339
end

0 commit comments

Comments
 (0)