Skip to content

Commit

Permalink
Align to new rubocop rules
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-richter committed Sep 24, 2020
1 parent a33f693 commit b8f7764
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 19 deletions.
12 changes: 8 additions & 4 deletions 13_integrated_testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ diff -uNr 12_exceptions_part1_groundwork/tests/panic_exit_success/mod.rs 13_inte
diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/tests/runner.rb
--- 12_exceptions_part1_groundwork/tests/runner.rb
+++ 13_integrated_testing/tests/runner.rb
@@ -0,0 +1,139 @@
@@ -0,0 +1,143 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
Expand Down Expand Up @@ -1906,7 +1906,7 @@ diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/t
+ puts "#{INDENT}-------------------------------------------------------------------"
+ print INDENT
+ print '🦀 '
+ print @output.join('').gsub("\n", "\n" + INDENT)
+ print @output.join('').gsub("\n", "\n#{INDENT}")
+ end
+
+ def finish(error)
Expand All @@ -1927,6 +1927,8 @@ diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/t
+# Executes tests with console I/O.
+class ConsoleTest < Test
+ def initialize(binary, qemu_cmd, test_name, console_subtests)
+ super()
+
+ @binary = binary
+ @qemu_cmd = qemu_cmd
+ @test_name = test_name
Expand All @@ -1937,7 +1939,7 @@ diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/t
+ end
+
+ def format_test_name(number, name)
+ formatted_name = number.to_s.rjust(3) + '. ' + name
+ formatted_name = "#{number.to_s.rjust(3)}. #{name}"
+ formatted_name.ljust(63, '.')
+ end
+
Expand Down Expand Up @@ -1970,6 +1972,8 @@ diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/t
+ MAX_WAIT_SECS = 5
+
+ def initialize(binary, qemu_cmd, test_name)
+ super()
+
+ @binary = binary
+ @qemu_cmd = qemu_cmd
+ @test_name = test_name
Expand Down Expand Up @@ -1999,7 +2003,7 @@ diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/t
+##--------------------------------------------------------------------------------------------------
+binary = ARGV.last
+test_name = binary.gsub(modulor{.*deps/}, '').split('-')[0]
+console_test_file = 'tests/' + test_name + '.rb'
+console_test_file = "tests/#{test_name}.rb"
+qemu_cmd = ARGV.join(' ')
+
+test_runner = if File.exist?(console_test_file)
Expand Down
10 changes: 7 additions & 3 deletions 13_integrated_testing/tests/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def print_output
puts "#{INDENT}-------------------------------------------------------------------"
print INDENT
print '🦀 '
print @output.join('').gsub("\n", "\n" + INDENT)
print @output.join('').gsub("\n", "\n#{INDENT}")
end

def finish(error)
Expand All @@ -53,6 +53,8 @@ def finish(error)
# Executes tests with console I/O.
class ConsoleTest < Test
def initialize(binary, qemu_cmd, test_name, console_subtests)
super()

@binary = binary
@qemu_cmd = qemu_cmd
@test_name = test_name
Expand All @@ -63,7 +65,7 @@ def initialize(binary, qemu_cmd, test_name, console_subtests)
end

def format_test_name(number, name)
formatted_name = number.to_s.rjust(3) + '. ' + name
formatted_name = "#{number.to_s.rjust(3)}. #{name}"
formatted_name.ljust(63, '.')
end

Expand Down Expand Up @@ -96,6 +98,8 @@ class RawTest < Test
MAX_WAIT_SECS = 5

def initialize(binary, qemu_cmd, test_name)
super()

@binary = binary
@qemu_cmd = qemu_cmd
@test_name = test_name
Expand Down Expand Up @@ -125,7 +129,7 @@ def exec
##--------------------------------------------------------------------------------------------------
binary = ARGV.last
test_name = binary.gsub(%r{.*deps/}, '').split('-')[0]
console_test_file = 'tests/' + test_name + '.rb'
console_test_file = "tests/#{test_name}.rb"
qemu_cmd = ARGV.join(' ')

test_runner = if File.exist?(console_test_file)
Expand Down
10 changes: 7 additions & 3 deletions 14_exceptions_part2_peripheral_IRQs/tests/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def print_output
puts "#{INDENT}-------------------------------------------------------------------"
print INDENT
print '🦀 '
print @output.join('').gsub("\n", "\n" + INDENT)
print @output.join('').gsub("\n", "\n#{INDENT}")
end

def finish(error)
Expand All @@ -53,6 +53,8 @@ def finish(error)
# Executes tests with console I/O.
class ConsoleTest < Test
def initialize(binary, qemu_cmd, test_name, console_subtests)
super()

@binary = binary
@qemu_cmd = qemu_cmd
@test_name = test_name
Expand All @@ -63,7 +65,7 @@ def initialize(binary, qemu_cmd, test_name, console_subtests)
end

def format_test_name(number, name)
formatted_name = number.to_s.rjust(3) + '. ' + name
formatted_name = "#{number.to_s.rjust(3)}. #{name}"
formatted_name.ljust(63, '.')
end

Expand Down Expand Up @@ -96,6 +98,8 @@ class RawTest < Test
MAX_WAIT_SECS = 5

def initialize(binary, qemu_cmd, test_name)
super()

@binary = binary
@qemu_cmd = qemu_cmd
@test_name = test_name
Expand Down Expand Up @@ -125,7 +129,7 @@ def exec
##--------------------------------------------------------------------------------------------------
binary = ARGV.last
test_name = binary.gsub(%r{.*deps/}, '').split('-')[0]
console_test_file = 'tests/' + test_name + '.rb'
console_test_file = "tests/#{test_name}.rb"
qemu_cmd = ARGV.join(' ')

test_runner = if File.exist?(console_test_file)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ group :uart do
end

group :development do
gem 'rubocop', require: false
gem 'rubocop', '>= 0.90.0', require: false
end
8 changes: 4 additions & 4 deletions utils/devtool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_integration
private

def testable?
Dir.exist?(@folder + '/tests')
Dir.exist?("#{@folder}/tests")
end
end

Expand Down Expand Up @@ -120,14 +120,14 @@ def diff
end
end

def fmt(check = false)
def fmt(check: false)
args = '-- --check' if check

@crates.each { |c| c.fmt(args) }
end

def fmt_check
fmt(true)
fmt(check: true)
end

def make(bsp = nil)
Expand Down Expand Up @@ -214,7 +214,7 @@ def user_supplied_crate_list

return nil if folders.empty?

crates = folders.map { |d| d + '/Cargo.toml' }.sort
crates = folders.map { |d| "#{d}/Cargo.toml" }.sort
crates.each do |c|
unless File.exist?(c)
puts "Crate not found: #{c}"
Expand Down
8 changes: 4 additions & 4 deletions utils/minipush.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def open_serial
@target_serial.sync = true
rescue Errno::EACCES => e
puts
puts '[MP] 🚫 ' + e.message + " - Maybe try with 'sudo'"
puts "[MP] 🚫 #{e.message} - Maybe try with 'sudo'"
exit
else
puts
Expand Down Expand Up @@ -148,23 +148,23 @@ def handle_reconnect
connetion_reset

puts
puts '[MP] ⚡ ' + 'Connection Error: Reinsert the USB serial again'.light_red
puts "[MP] ⚡ #{'Connection Error: Reinsert the USB serial again'.light_red}"
end

# When the serial is still powered.
def handle_protocol_error
connetion_reset

puts
puts '[MP] ⚡ ' + 'Protocol Error: Remove and insert the USB serial again'.light_red
puts "[MP] ⚡ #{'Protocol Error: Remove and insert the USB serial again'.light_red}"
sleep(1) while serial_connected?
end

def handle_unexpected(error)
connetion_reset

puts
puts '[MP] ⚡ ' + "Unexpected Error: #{error.inspect}".light_red
puts "[MP] ⚡ #{"Unexpected Error: #{error.inspect}".light_red}"
end

public
Expand Down

0 comments on commit b8f7764

Please sign in to comment.