rust-raspberrypi-OS-tutorials/common/tests/dispatch.rb
Andre Richter 8c661977b8
Use a virtual manifest starting tutorial 12
This is finally possible since the new feature resolver.

For reference:
https://github.com/rust-lang/rust-analyzer/issues/6197#issuecomment-827564835
2022-04-19 22:44:01 +02:00

42 lines
1.2 KiB
Ruby
Executable File

#!/usr/bin/env ruby
# frozen_string_literal: true
# SPDX-License-Identifier: MIT OR Apache-2.0
#
# Copyright (c) 2019-2022 Andre Richter <andre.o.richter@gmail.com>
file_dir = File.dirname(__FILE__)
$LOAD_PATH.unshift(file_dir) unless $LOAD_PATH.include?(file_dir)
require 'boot_test'
require 'console_io_test'
require 'exit_code_test'
qemu_cmd = ARGV.join(' ')
binary = ARGV.last
test_name = binary.gsub(%r{.*deps/}, '').split('-')[0]
# Check if virtual manifest (tutorial 12 or later) or not
path_prefix = File.exist?('kernel/Cargo.toml') ? 'kernel/' : ''
case test_name
when 'kernel8.img'
load "#{path_prefix}tests/boot_test_string.rb" # provides 'EXPECTED_PRINT'
BootTest.new(qemu_cmd, EXPECTED_PRINT).run # Doesn't return
when 'libkernel'
ExitCodeTest.new(qemu_cmd, 'Kernel library unit tests').run # Doesn't return
else
console_test_file = "#{path_prefix}tests/#{test_name}.rb"
test_name.concat('.rs')
test = if File.exist?(console_test_file)
load console_test_file # provides 'subtest_collection'
ConsoleIOTest.new(qemu_cmd, test_name, subtest_collection)
else
ExitCodeTest.new(qemu_cmd, test_name)
end
test.run # Doesn't return
end