diff --git a/spec/generate_interpreter_spec.sh b/spec/generate_interpreter_spec.sh index f3500115a737..960ab37f48db 100755 --- a/spec/generate_interpreter_spec.sh +++ b/spec/generate_interpreter_spec.sh @@ -19,7 +19,7 @@ echo "# $(date --rfc-3339 seconds) This file is autogenerated by \`${command% }\ run_spec () { spec=$1 require="require \"./${spec##spec/}\"" - timeout 150 $CRYSTAL_BIN i $spec > /dev/null; exit=$? + timeout --signal=KILL 150 $CRYSTAL_BIN i $spec > /dev/null; exit=$? if [ $exit -eq 0 ] ; then echo "$require" >> $OUT_FILE diff --git a/spec/interpreter_std_spec.cr b/spec/interpreter_std_spec.cr index 79b8bab3edbc..0bb16eeeb2a1 100644 --- a/spec/interpreter_std_spec.cr +++ b/spec/interpreter_std_spec.cr @@ -1,4 +1,4 @@ -# 2023-04-12 22:54:02-05:00 This file is autogenerated by `spec/generate_interpreter_spec.sh std spec/interpreter_std_spec.cr` +# 2024-03-22 14:01:27+08:00 This file is autogenerated by `./spec/generate_interpreter_spec.sh std spec/interpreter_std_spec.cr 8` require "./std/array_spec.cr" require "./std/atomic_spec.cr" require "./std/base64_spec.cr" @@ -50,6 +50,7 @@ require "./std/crystal/hasher_spec.cr" require "./std/crystal/pointer_linked_list_spec.cr" require "./std/crystal/syntax_highlighter/colorize_spec.cr" require "./std/crystal/syntax_highlighter/html_spec.cr" +require "./std/crystal/system_spec.cr" require "./std/csv/csv_build_spec.cr" require "./std/csv/csv_lex_spec.cr" require "./std/csv/csv_parse_spec.cr" @@ -62,7 +63,7 @@ require "./std/digest/md5_spec.cr" require "./std/digest/sha1_spec.cr" require "./std/digest/sha256_spec.cr" require "./std/digest/sha512_spec.cr" -# require "./std/dir_spec.cr" (failed to run) +require "./std/dir_spec.cr" require "./std/double_spec.cr" require "./std/ecr/ecr_lexer_spec.cr" require "./std/ecr/ecr_spec.cr" @@ -70,8 +71,8 @@ require "./std/enumerable_spec.cr" require "./std/enum_spec.cr" require "./std/env_spec.cr" require "./std/errno_spec.cr" -# require "./std/exception/call_stack_spec.cr" (failed to run) -# require "./std/exception_spec.cr" (failed to run) +require "./std/exception/call_stack_spec.cr" +require "./std/exception_spec.cr" require "./std/fiber_spec.cr" require "./std/file_spec.cr" require "./std/file/tempfile_spec.cr" @@ -80,6 +81,7 @@ require "./std/float_printer/diy_fp_spec.cr" require "./std/float_printer/grisu3_spec.cr" require "./std/float_printer/hexfloat_spec.cr" require "./std/float_printer/ieee_spec.cr" +require "./std/float_printer/ryu_printf_spec.cr" require "./std/float_printer/shortest_spec.cr" require "./std/float_spec.cr" require "./std/gc_spec.cr" @@ -116,7 +118,7 @@ require "./std/io/argf_spec.cr" require "./std/io/buffered_spec.cr" require "./std/io/byte_format_spec.cr" require "./std/io/delimited_spec.cr" -# require "./std/io/file_descriptor_spec.cr" (failed to run) +require "./std/io/file_descriptor_spec.cr" require "./std/io/hexdump_spec.cr" require "./std/io/io_spec.cr" require "./std/io/memory_spec.cr" @@ -131,7 +133,7 @@ require "./std/json/parser_spec.cr" require "./std/json/pull_parser_spec.cr" require "./std/json/serializable_spec.cr" require "./std/json/serialization_spec.cr" -# require "./std/kernel_spec.cr" (failed to run) +require "./std/kernel_spec.cr" require "./std/levenshtein_spec.cr" # require "./std/llvm/aarch64_spec.cr" (failed to run) # require "./std/llvm/arm_abi_spec.cr" (failed to run) @@ -185,7 +187,7 @@ require "./std/pointer_spec.cr" require "./std/pp_spec.cr" require "./std/pretty_print_spec.cr" require "./std/process/find_executable_spec.cr" -# require "./std/process_spec.cr" (failed to run) +require "./std/process_spec.cr" require "./std/process/status_spec.cr" require "./std/process/utils_spec.cr" require "./std/proc_spec.cr" @@ -201,7 +203,7 @@ require "./std/regex/match_data_spec.cr" require "./std/regex_spec.cr" require "./std/semantic_version_spec.cr" require "./std/set_spec.cr" -# require "./std/signal_spec.cr" (failed to run) +require "./std/signal_spec.cr" require "./std/slice_spec.cr" require "./std/socket/address_spec.cr" require "./std/socket/addrinfo_spec.cr" @@ -215,8 +217,9 @@ require "./std/spec/context_spec.cr" require "./std/spec/expectations_spec.cr" require "./std/spec/filters_spec.cr" require "./std/spec/helpers/iterate_spec.cr" -# require "./std/spec/hooks_spec.cr" (failed to run) +require "./std/spec/hooks_spec.cr" require "./std/spec/junit_formatter_spec.cr" +require "./std/spec/list_tags_spec.cr" require "./std/spec_spec.cr" require "./std/spec/tap_formatter_spec.cr" require "./std/sprintf_spec.cr" @@ -233,16 +236,16 @@ require "./std/symbol_spec.cr" # require "./std/syscall_spec.cr" (failed to run) require "./std/system_error_spec.cr" require "./std/system/group_spec.cr" -# require "./std/system_spec.cr" (failed to run) +require "./std/system_spec.cr" require "./std/system/user_spec.cr" -# require "./std/thread/condition_variable_spec.cr" (interpreter must support threads) -# require "./std/thread/mutex_spec.cr" (interpreter must support threads) -# require "./std/thread_spec.cr" (interpreter must support threads) +require "./std/thread/condition_variable_spec.cr" +require "./std/thread/mutex_spec.cr" +require "./std/thread_spec.cr" require "./std/time/custom_formats_spec.cr" -require "./std/time/format_spec.cr" +# require "./std/time/format_spec.cr" (failed to run) require "./std/time/location_spec.cr" require "./std/time/span_spec.cr" -require "./std/time/time_spec.cr" +# require "./std/time/time_spec.cr" (failed to run) require "./std/tuple_spec.cr" require "./std/uint_spec.cr" require "./std/uri/params_spec.cr" @@ -251,7 +254,7 @@ require "./std/uri_spec.cr" require "./std/uuid/json_spec.cr" require "./std/uuid_spec.cr" require "./std/uuid/yaml_spec.cr" -# require "./std/va_list_spec.cr" (failed to run) +require "./std/va_list_spec.cr" require "./std/weak_ref_spec.cr" require "./std/winerror_spec.cr" require "./std/xml/builder_spec.cr" diff --git a/spec/std/crystal/system_spec.cr b/spec/std/crystal/system_spec.cr index 06bc789055d4..8e710f860a53 100644 --- a/spec/std/crystal/system_spec.cr +++ b/spec/std/crystal/system_spec.cr @@ -1,4 +1,4 @@ -require "spec" +require "../spec_helper" private def print_error_to_s(format, *args) io = IO::Memory.new @@ -26,7 +26,8 @@ describe "Crystal::System" do print_error_to_s("%x,%x,%x,%x,%x", 0, 0x1234, UInt32::MAX, Int32::MIN, UInt64::MAX).should eq("0,1234,ffffffff,80000000,ffffffff") end - it "supports %p" do + # TODO: investigate why this prints `(???)` + pending_interpreted "supports %p" do print_error_to_s("%p,%p,%p", Pointer(Void).new(0x0), Pointer(Void).new(0x1234), Pointer(Void).new(UInt64::MAX)).should eq("0x0,0x1234,0xffffffffffffffff") end @@ -34,7 +35,8 @@ describe "Crystal::System" do print_error_to_s("%s,%s,%s", "abc\0def", "ghi".to_unsafe, Pointer(UInt8).null).should eq("abc\0def,ghi,(null)") end - it "supports %l width" do + # BUG: missing downcast_distinct from Tuple(Int64 | UInt64, Int64 | UInt64, Int64 | UInt64, Int64 | UInt64) to Tuple(Int64, Int64, Int64, Int64) + pending_interpreted "supports %l width" do values = {LibC::Long::MIN, LibC::Long::MAX, LibC::LongLong::MIN, LibC::LongLong::MAX} print_error_to_s("%ld,%ld,%lld,%lld", *values).should eq(values.join(',')) diff --git a/spec/std/dir_spec.cr b/spec/std/dir_spec.cr index c2d86eff7bb2..439da15becd9 100644 --- a/spec/std/dir_spec.cr +++ b/spec/std/dir_spec.cr @@ -631,7 +631,8 @@ describe "Dir" do end describe ".current" do - it "matches shell" do + # can't use backtick in interpreted code (#12241) + pending_interpreted "matches shell" do Dir.current.should eq(`#{{{ flag?(:win32) ? "cmd /c cd" : "pwd" }}}`.chomp) end diff --git a/spec/std/file_spec.cr b/spec/std/file_spec.cr index 1e9a9f53ae32..fedbf0889370 100644 --- a/spec/std/file_spec.cr +++ b/spec/std/file_spec.cr @@ -79,10 +79,9 @@ describe "File" do end end - {% if LibC.has_method?(:mkfifo) && !flag?(:interpreted) %} - # spec is disabled when interpreted because the interpreter doesn't - # support threads - it "opens fifo file as non-blocking" do + {% if LibC.has_method?(:mkfifo) %} + # interpreter doesn't support threads yet (#14287) + pending_interpreted "opens fifo file as non-blocking" do path = File.tempname("chardev") ret = LibC.mkfifo(path, File::DEFAULT_CREATE_PERMISSIONS) raise RuntimeError.from_errno("mkfifo") unless ret == 0 diff --git a/spec/std/file_utils_spec.cr b/spec/std/file_utils_spec.cr index bc730dde5c01..87591120ff7b 100644 --- a/spec/std/file_utils_spec.cr +++ b/spec/std/file_utils_spec.cr @@ -715,9 +715,9 @@ describe "FileUtils" do end end - # FIXME: `Process.run` and backtick don't work in the interpreter (#12241) - {% if flag?(:unix) && !flag?(:interpreted) %} - it "overwrites a destination named pipe" do + {% if flag?(:unix) %} + # can't use backtick in interpreted code (#12241) + pending_interpreted "overwrites a destination named pipe" do with_tempfile("ln_sf_src", "ln_sf_dst_pipe_exists") do |path1, path2| test_with_string_and_path(path1, path2) do |arg1, arg2| FileUtils.touch([path1]) diff --git a/spec/std/process_spec.cr b/spec/std/process_spec.cr index db3a058a7c44..6388b88fb70c 100644 --- a/spec/std/process_spec.cr +++ b/spec/std/process_spec.cr @@ -54,7 +54,8 @@ private def newline {% end %} end -describe Process do +# interpreted code doesn't receive SIGCHLD for `#wait` to work (#12241) +pending_interpreted describe: Process do describe ".new" do it "raises if command doesn't exist" do expect_raises(File::NotFoundError, "Error executing process: 'foobarbaz'") do diff --git a/spec/std/signal_spec.cr b/spec/std/signal_spec.cr index d1d3aa3f1643..cae1c5e83834 100644 --- a/spec/std/signal_spec.cr +++ b/spec/std/signal_spec.cr @@ -1,9 +1,10 @@ {% skip_file if flag?(:wasm32) %} -require "spec" +require "./spec_helper" require "signal" -describe "Signal" do +# interpreted code never receives signals (#12241) +pending_interpreted describe: "Signal" do typeof(Signal::ABRT.reset) typeof(Signal::ABRT.ignore) typeof(Signal::ABRT.trap { 1 }) diff --git a/spec/std/spec_helper.cr b/spec/std/spec_helper.cr index 18deaf0260bf..69c80968b117 100644 --- a/spec/std/spec_helper.cr +++ b/spec/std/spec_helper.cr @@ -3,6 +3,7 @@ require "../support/tempfile" require "../support/fibers" require "../support/win32" require "../support/wasm32" +require "../support/interpreted" def datapath(*components) File.join("spec", "std", "data", *components) @@ -77,6 +78,9 @@ def spawn_and_check(before : Proc(_), file = __FILE__, line = __LINE__, &block : end def compile_file(source_file, *, bin_name = "executable_file", flags = %w(), file = __FILE__, &) + # can't use backtick in interpreted code (#12241) + pending_interpreted! "Unable to compile Crystal code in interpreted code" + with_temp_executable(bin_name, file: file) do |executable_file| compiler = ENV["CRYSTAL_SPEC_COMPILER_BIN"]? || "bin/crystal" args = ["build"] + flags + ["-o", executable_file, source_file] diff --git a/spec/std/system_spec.cr b/spec/std/system_spec.cr index 7a87b1a238c8..58023f0c0e59 100644 --- a/spec/std/system_spec.cr +++ b/spec/std/system_spec.cr @@ -3,7 +3,8 @@ require "system" describe System do describe "hostname" do - it "returns current hostname" do + # can't use backtick in interpreted code (#12241) + pending_interpreted "returns current hostname" do shell_hostname = `hostname`.strip pending! "`hostname` command was unsuccessful" unless $?.success? @@ -13,7 +14,8 @@ describe System do end describe "cpu_count" do - it "returns current CPU count" do + # can't use backtick in interpreted code (#12241) + pending_interpreted "returns current CPU count" do shell_cpus = {% if flag?(:win32) %} ENV["NUMBER_OF_PROCESSORS"].to_i diff --git a/spec/std/thread/condition_variable_spec.cr b/spec/std/thread/condition_variable_spec.cr index 36e1963794b3..ff9c44204bb6 100644 --- a/spec/std/thread/condition_variable_spec.cr +++ b/spec/std/thread/condition_variable_spec.cr @@ -6,9 +6,10 @@ {% skip_file %} {% end %} -require "spec" +require "../spec_helper" -describe Thread::ConditionVariable do +# interpreter doesn't support threads yet (#14287) +pending_interpreted describe: Thread::ConditionVariable do it "signals" do mutex = Thread::Mutex.new cond = Thread::ConditionVariable.new diff --git a/spec/std/thread/mutex_spec.cr b/spec/std/thread/mutex_spec.cr index d028ffdd8f8a..ff298f318329 100644 --- a/spec/std/thread/mutex_spec.cr +++ b/spec/std/thread/mutex_spec.cr @@ -6,9 +6,10 @@ {% skip_file %} {% end %} -require "spec" +require "../spec_helper" -describe Thread::Mutex do +# interpreter doesn't support threads yet (#14287) +pending_interpreted describe: Thread::Mutex do it "synchronizes" do a = 0 mutex = Thread::Mutex.new diff --git a/spec/std/thread_spec.cr b/spec/std/thread_spec.cr index 136026667137..feb55454b621 100644 --- a/spec/std/thread_spec.cr +++ b/spec/std/thread_spec.cr @@ -1,4 +1,4 @@ -require "spec" +require "./spec_helper" {% if flag?(:musl) %} # FIXME: These thread specs occasionally fail on musl/alpine based ci, so @@ -8,7 +8,8 @@ require "spec" {% skip_file %} {% end %} -describe Thread do +# interpreter doesn't support threads yet (#14287) +pending_interpreted describe: Thread do it "allows passing an argumentless fun to execute" do a = 0 thread = Thread.new { a = 1; 10 } diff --git a/spec/support/interpreted.cr b/spec/support/interpreted.cr new file mode 100644 index 000000000000..79f8a688c72b --- /dev/null +++ b/spec/support/interpreted.cr @@ -0,0 +1,26 @@ +require "spec" + +{% if flag?(:interpreted) %} + def pending_interpreted(description = "assert", file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + pending("#{description} [interpreted]", file, line, end_line) + end + + def pending_interpreted(*, describe, file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + pending_interpreted(describe, file, line, end_line) { } + end + + def pending_interpreted!(msg = "Cannot run example", file = __FILE__, line = __LINE__) + pending!(msg, file, line) + end +{% else %} + def pending_interpreted(description = "assert", file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + it(description, file, line, end_line, &block) + end + + def pending_interpreted(*, describe, file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + describe(describe, file, line, end_line, &block) + end + + def pending_interpreted!(msg = "Cannot run example", file = __FILE__, line = __LINE__) + end +{% end %} diff --git a/spec/support/tempfile.cr b/spec/support/tempfile.cr index a5e0c57d010a..a77070d90e40 100644 --- a/spec/support/tempfile.cr +++ b/spec/support/tempfile.cr @@ -1,4 +1,5 @@ require "file_utils" +require "./interpreted" {% if flag?(:msvc) %} require "crystal/system/win32/visual_studio" {% end %} @@ -47,6 +48,9 @@ def with_temp_executable(name, file = __FILE__, &) end def with_temp_c_object_file(c_code, *, filename = "temp_c", file = __FILE__, &) + # can't use backtick in interpreted code (#12241) + pending_interpreted! "Unable to compile C code in interpreted code" + obj_ext = {{ flag?(:msvc) ? ".obj" : ".o" }} with_tempfile("#{filename}.c", "#{filename}#{obj_ext}", file: file) do |c_filename, o_filename| File.write(c_filename, c_code)