From 5b27ae7ddf5eac6d000868d752b660042dc13d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20R=C3=BCger?= Date: Sat, 8 Feb 2020 17:44:35 +0700 Subject: [PATCH] use env, not class var aas compilation switch --- lib/rubyx/rubyxc.rb | 2 +- test/mains/test_arm.rb | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/rubyx/rubyxc.rb b/lib/rubyx/rubyxc.rb index 8bc30878..344ee14b 100644 --- a/lib/rubyx/rubyxc.rb +++ b/lib/rubyx/rubyxc.rb @@ -6,7 +6,7 @@ class RubyXC < Thor class_option :integers , type: :numeric class_option :messages , type: :numeric class_option :elf , type: :boolean - class_option :preload , type: :boolean + class_option :preload , type: :boolean , default: true # # Actual commands are required at the end, one per file, same name as command diff --git a/test/mains/test_arm.rb b/test/mains/test_arm.rb index e9899916..7d7ea4e2 100644 --- a/test/mains/test_arm.rb +++ b/test/mains/test_arm.rb @@ -1,5 +1,11 @@ require_relative 'helper' +# set environment TEST_ARM to true to have these tests run +# They need qemu and arm cross linker to be installed +# Also they are too slow to include in normal runs, so only by request and on travis + +# set TEST_ARM to DEBUG to get extra output + module Mains class TestArm < MiniTest::Test @Qemu = "qemu-arm" @@ -10,7 +16,6 @@ module Mains def self.Qemu @Qemu end - DEBUG = false # runnable_methods is called by minitest to determine which tests to run def self.runnable_methods @@ -34,9 +39,9 @@ module Mains def self.has_qemu if `uname -a`.include?("torsten") - @Linker = "arm-linux-gnu-ld" - return false unless DEBUG + @Linker = "arm-linux-gnu-ld" #on fedora end + return false unless ENV["TEST_ARM"] begin `#{@Qemu} -version` `#{@Linker} -v` @@ -48,22 +53,22 @@ module Mains end def run_code(input , name ) - puts "Compiling #{name}.o" if DEBUG + puts "Compiling #{name}.o" if ENV["TEST_ARM"] == "DEBUG" linker = ::RubyX::RubyXCompiler.new({}).ruby_to_binary( input , :arm ) writer = Elf::ObjectWriter.new(linker) writer.save "mains.o" - puts "Linking #{name}" if DEBUG + puts "Linking #{name}" if ENV["TEST_ARM"] == "DEBUG" `#{TestArm.Linker} -N mains.o` assert_equal 0 , $?.exitstatus , "Linking #{name} failed #{$?}" - puts "Running #{name}" if DEBUG + puts "Running #{name}" if ENV["TEST_ARM"] == "DEBUG" stdout = `#{TestArm.Qemu} ./a.out` exit_code = $?.exitstatus - puts "Result #{stdout} #{exit_code}" if DEBUG + puts "Result #{stdout} #{exit_code}" if ENV["TEST_ARM"] == "DEBUG" return stdout , exit_code end