From b8f7764bbb2c8d78215e215e793fff3357c82b01 Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Thu, 24 Sep 2020 22:41:42 +0200 Subject: [PATCH] Align to new rubocop rules --- 13_integrated_testing/README.md | 12 ++++++++---- 13_integrated_testing/tests/runner.rb | 10 +++++++--- 14_exceptions_part2_peripheral_IRQs/tests/runner.rb | 10 +++++++--- Gemfile | 2 +- utils/devtool.rb | 8 ++++---- utils/minipush.rb | 8 ++++---- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/13_integrated_testing/README.md b/13_integrated_testing/README.md index 03027163..4169f9e5 100644 --- a/13_integrated_testing/README.md +++ b/13_integrated_testing/README.md @@ -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 + @@ -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) @@ -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 @@ -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 + @@ -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 @@ -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) diff --git a/13_integrated_testing/tests/runner.rb b/13_integrated_testing/tests/runner.rb index ef11f316..5b012304 100755 --- a/13_integrated_testing/tests/runner.rb +++ b/13_integrated_testing/tests/runner.rb @@ -32,7 +32,7 @@ class Test puts "#{INDENT}-------------------------------------------------------------------" print INDENT print '🦀 ' - print @output.join('').gsub("\n", "\n" + INDENT) + print @output.join('').gsub("\n", "\n#{INDENT}") end def finish(error) @@ -53,6 +53,8 @@ end # 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 @@ -63,7 +65,7 @@ class ConsoleTest < Test 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 @@ -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 @@ -125,7 +129,7 @@ end ##-------------------------------------------------------------------------------------------------- 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) diff --git a/14_exceptions_part2_peripheral_IRQs/tests/runner.rb b/14_exceptions_part2_peripheral_IRQs/tests/runner.rb index ef11f316..5b012304 100755 --- a/14_exceptions_part2_peripheral_IRQs/tests/runner.rb +++ b/14_exceptions_part2_peripheral_IRQs/tests/runner.rb @@ -32,7 +32,7 @@ class Test puts "#{INDENT}-------------------------------------------------------------------" print INDENT print '🦀 ' - print @output.join('').gsub("\n", "\n" + INDENT) + print @output.join('').gsub("\n", "\n#{INDENT}") end def finish(error) @@ -53,6 +53,8 @@ end # 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 @@ -63,7 +65,7 @@ class ConsoleTest < Test 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 @@ -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 @@ -125,7 +129,7 @@ end ##-------------------------------------------------------------------------------------------------- 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) diff --git a/Gemfile b/Gemfile index b007c391..74f76ccc 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :uart do end group :development do - gem 'rubocop', require: false + gem 'rubocop', '>= 0.90.0', require: false end diff --git a/utils/devtool.rb b/utils/devtool.rb index 53f51801..73579922 100755 --- a/utils/devtool.rb +++ b/utils/devtool.rb @@ -79,7 +79,7 @@ class TutorialCrate private def testable? - Dir.exist?(@folder + '/tests') + Dir.exist?("#{@folder}/tests") end end @@ -120,14 +120,14 @@ class DevTool 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) @@ -214,7 +214,7 @@ class DevTool 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}" diff --git a/utils/minipush.rb b/utils/minipush.rb index 60af9031..61447858 100755 --- a/utils/minipush.rb +++ b/utils/minipush.rb @@ -52,7 +52,7 @@ class MiniPush @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 @@ -148,7 +148,7 @@ class MiniPush 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. @@ -156,7 +156,7 @@ class MiniPush 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 @@ -164,7 +164,7 @@ class MiniPush connetion_reset puts - puts '[MP] ⚡ ' + "Unexpected Error: #{error.inspect}".light_red + puts "[MP] ⚡ #{"Unexpected Error: #{error.inspect}".light_red}" end public