Align to new rubocop rules

pull/84/head
Andre Richter 4 years ago
parent a33f693e1c
commit b8f7764bbb
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -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 diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/tests/runner.rb
--- 12_exceptions_part1_groundwork/tests/runner.rb --- 12_exceptions_part1_groundwork/tests/runner.rb
+++ 13_integrated_testing/tests/runner.rb +++ 13_integrated_testing/tests/runner.rb
@@ -0,0 +1,139 @@ @@ -0,0 +1,143 @@
+#!/usr/bin/env ruby +#!/usr/bin/env ruby
+# frozen_string_literal: true +# frozen_string_literal: true
+ +
@ -1906,7 +1906,7 @@ diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/t
+ puts "#{INDENT}-------------------------------------------------------------------" + puts "#{INDENT}-------------------------------------------------------------------"
+ print INDENT + print INDENT
+ print '🦀 ' + print '🦀 '
+ print @output.join('').gsub("\n", "\n" + INDENT) + print @output.join('').gsub("\n", "\n#{INDENT}")
+ end + end
+ +
+ def finish(error) + def finish(error)
@ -1927,6 +1927,8 @@ diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/t
+# Executes tests with console I/O. +# Executes tests with console I/O.
+class ConsoleTest < Test +class ConsoleTest < Test
+ def initialize(binary, qemu_cmd, test_name, console_subtests) + def initialize(binary, qemu_cmd, test_name, console_subtests)
+ super()
+
+ @binary = binary + @binary = binary
+ @qemu_cmd = qemu_cmd + @qemu_cmd = qemu_cmd
+ @test_name = test_name + @test_name = test_name
@ -1937,7 +1939,7 @@ diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/t
+ end + end
+ +
+ def format_test_name(number, name) + 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, '.') + formatted_name.ljust(63, '.')
+ end + end
+ +
@ -1970,6 +1972,8 @@ diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/t
+ MAX_WAIT_SECS = 5 + MAX_WAIT_SECS = 5
+ +
+ def initialize(binary, qemu_cmd, test_name) + def initialize(binary, qemu_cmd, test_name)
+ super()
+
+ @binary = binary + @binary = binary
+ @qemu_cmd = qemu_cmd + @qemu_cmd = qemu_cmd
+ @test_name = test_name + @test_name = test_name
@ -1999,7 +2003,7 @@ diff -uNr 12_exceptions_part1_groundwork/tests/runner.rb 13_integrated_testing/t
+##-------------------------------------------------------------------------------------------------- +##--------------------------------------------------------------------------------------------------
+binary = ARGV.last +binary = ARGV.last
+test_name = binary.gsub(modulor{.*deps/}, '').split('-')[0] +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(' ') +qemu_cmd = ARGV.join(' ')
+ +
+test_runner = if File.exist?(console_test_file) +test_runner = if File.exist?(console_test_file)

@ -32,7 +32,7 @@ class Test
puts "#{INDENT}-------------------------------------------------------------------" puts "#{INDENT}-------------------------------------------------------------------"
print INDENT print INDENT
print '🦀 ' print '🦀 '
print @output.join('').gsub("\n", "\n" + INDENT) print @output.join('').gsub("\n", "\n#{INDENT}")
end end
def finish(error) def finish(error)
@ -53,6 +53,8 @@ end
# Executes tests with console I/O. # Executes tests with console I/O.
class ConsoleTest < Test class ConsoleTest < Test
def initialize(binary, qemu_cmd, test_name, console_subtests) def initialize(binary, qemu_cmd, test_name, console_subtests)
super()
@binary = binary @binary = binary
@qemu_cmd = qemu_cmd @qemu_cmd = qemu_cmd
@test_name = test_name @test_name = test_name
@ -63,7 +65,7 @@ class ConsoleTest < Test
end end
def format_test_name(number, name) 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, '.') formatted_name.ljust(63, '.')
end end
@ -96,6 +98,8 @@ class RawTest < Test
MAX_WAIT_SECS = 5 MAX_WAIT_SECS = 5
def initialize(binary, qemu_cmd, test_name) def initialize(binary, qemu_cmd, test_name)
super()
@binary = binary @binary = binary
@qemu_cmd = qemu_cmd @qemu_cmd = qemu_cmd
@test_name = test_name @test_name = test_name
@ -125,7 +129,7 @@ end
##-------------------------------------------------------------------------------------------------- ##--------------------------------------------------------------------------------------------------
binary = ARGV.last binary = ARGV.last
test_name = binary.gsub(%r{.*deps/}, '').split('-')[0] 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(' ') qemu_cmd = ARGV.join(' ')
test_runner = if File.exist?(console_test_file) test_runner = if File.exist?(console_test_file)

@ -32,7 +32,7 @@ class Test
puts "#{INDENT}-------------------------------------------------------------------" puts "#{INDENT}-------------------------------------------------------------------"
print INDENT print INDENT
print '🦀 ' print '🦀 '
print @output.join('').gsub("\n", "\n" + INDENT) print @output.join('').gsub("\n", "\n#{INDENT}")
end end
def finish(error) def finish(error)
@ -53,6 +53,8 @@ end
# Executes tests with console I/O. # Executes tests with console I/O.
class ConsoleTest < Test class ConsoleTest < Test
def initialize(binary, qemu_cmd, test_name, console_subtests) def initialize(binary, qemu_cmd, test_name, console_subtests)
super()
@binary = binary @binary = binary
@qemu_cmd = qemu_cmd @qemu_cmd = qemu_cmd
@test_name = test_name @test_name = test_name
@ -63,7 +65,7 @@ class ConsoleTest < Test
end end
def format_test_name(number, name) 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, '.') formatted_name.ljust(63, '.')
end end
@ -96,6 +98,8 @@ class RawTest < Test
MAX_WAIT_SECS = 5 MAX_WAIT_SECS = 5
def initialize(binary, qemu_cmd, test_name) def initialize(binary, qemu_cmd, test_name)
super()
@binary = binary @binary = binary
@qemu_cmd = qemu_cmd @qemu_cmd = qemu_cmd
@test_name = test_name @test_name = test_name
@ -125,7 +129,7 @@ end
##-------------------------------------------------------------------------------------------------- ##--------------------------------------------------------------------------------------------------
binary = ARGV.last binary = ARGV.last
test_name = binary.gsub(%r{.*deps/}, '').split('-')[0] 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(' ') qemu_cmd = ARGV.join(' ')
test_runner = if File.exist?(console_test_file) test_runner = if File.exist?(console_test_file)

@ -10,5 +10,5 @@ group :uart do
end end
group :development do group :development do
gem 'rubocop', require: false gem 'rubocop', '>= 0.90.0', require: false
end end

@ -79,7 +79,7 @@ class TutorialCrate
private private
def testable? def testable?
Dir.exist?(@folder + '/tests') Dir.exist?("#{@folder}/tests")
end end
end end
@ -120,14 +120,14 @@ class DevTool
end end
end end
def fmt(check = false) def fmt(check: false)
args = '-- --check' if check args = '-- --check' if check
@crates.each { |c| c.fmt(args) } @crates.each { |c| c.fmt(args) }
end end
def fmt_check def fmt_check
fmt(true) fmt(check: true)
end end
def make(bsp = nil) def make(bsp = nil)
@ -214,7 +214,7 @@ class DevTool
return nil if folders.empty? 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| crates.each do |c|
unless File.exist?(c) unless File.exist?(c)
puts "Crate not found: #{c}" puts "Crate not found: #{c}"

@ -52,7 +52,7 @@ class MiniPush
@target_serial.sync = true @target_serial.sync = true
rescue Errno::EACCES => e rescue Errno::EACCES => e
puts puts
puts '[MP] 🚫 ' + e.message + " - Maybe try with 'sudo'" puts "[MP] 🚫 #{e.message} - Maybe try with 'sudo'"
exit exit
else else
puts puts
@ -148,7 +148,7 @@ class MiniPush
connetion_reset connetion_reset
puts puts
puts '[MP] ⚡ ' + 'Connection Error: Reinsert the USB serial again'.light_red puts "[MP] ⚡ #{'Connection Error: Reinsert the USB serial again'.light_red}"
end end
# When the serial is still powered. # When the serial is still powered.
@ -156,7 +156,7 @@ class MiniPush
connetion_reset connetion_reset
puts 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? sleep(1) while serial_connected?
end end
@ -164,7 +164,7 @@ class MiniPush
connetion_reset connetion_reset
puts puts
puts '[MP] ⚡ ' + "Unexpected Error: #{error.inspect}".light_red puts "[MP] ⚡ #{"Unexpected Error: #{error.inspect}".light_red}"
end end
public public

Loading…
Cancel
Save