diff --git a/.github/workflows/wasm32.yml b/.github/workflows/wasm32.yml index 721ded21b861..0d4f32f4c044 100644 --- a/.github/workflows/wasm32.yml +++ b/.github/workflows/wasm32.yml @@ -40,7 +40,7 @@ jobs: rm wasm32-wasi-libs.tar.gz - name: Build spec/wasm32_std_spec.cr - run: bin/crystal build spec/wasm32_std_spec.cr -o wasm32_std_spec.wasm --target wasm32-wasi -Duse_pcre -Dwithout_openssl + run: bin/crystal build spec/wasm32_std_spec.cr -o wasm32_std_spec.wasm --target wasm32-wasi -Dwithout_iconv -Dwithout_openssl env: CRYSTAL_LIBRARY_PATH: ${{ github.workspace }}/wasm32-wasi-libs diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index 98f39b1fc042..a1ee9f49daa1 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -8,6 +8,7 @@ require "compiler/requires" require "./support/syntax" require "./support/tempfile" require "./support/win32" +require "./support/wasm32" class Crystal::Program setter temp_var_counter diff --git a/spec/std/html_spec.cr b/spec/std/html_spec.cr index b4f374dca936..2cb5980bd658 100644 --- a/spec/std/html_spec.cr +++ b/spec/std/html_spec.cr @@ -1,4 +1,4 @@ -require "spec" +require "./spec_helper" require "html" describe "HTML" do @@ -12,7 +12,7 @@ describe "HTML" do end end - describe ".unescape" do + pending_wasm32 describe: ".unescape" do it "identity" do HTML.unescape("safe_string").should be("safe_string") end diff --git a/spec/std/path_spec.cr b/spec/std/path_spec.cr index d1ad7bbf9d81..baa7cffd37b8 100644 --- a/spec/std/path_spec.cr +++ b/spec/std/path_spec.cr @@ -931,7 +931,7 @@ describe Path do assert_paths_raw("foo..txt/", "foo.", &.stem) end - describe ".home" do + pending_wasm32 describe: ".home" do it "uses home from environment variable if set" do with_env({HOME_ENV_KEY => "foo/bar"}) do Path.home.should eq(Path.new("foo/bar")) diff --git a/spec/std/regex_spec.cr b/spec/std/regex_spec.cr index 0d600603c3cc..310f94ffc9b4 100644 --- a/spec/std/regex_spec.cr +++ b/spec/std/regex_spec.cr @@ -308,7 +308,7 @@ describe "Regex" do end end - it "doesn't crash with a large single line string" do + pending_wasm32 "doesn't crash with a large single line string" do str = File.read(datapath("large_single_line_string.txt")) {% if Regex::Engine.resolve.name == "Regex::PCRE" %} diff --git a/spec/std/spec_helper.cr b/spec/std/spec_helper.cr index 75f8a1fe36d3..7f4b80405826 100644 --- a/spec/std/spec_helper.cr +++ b/spec/std/spec_helper.cr @@ -2,6 +2,7 @@ require "spec" require "../support/tempfile" require "../support/fibers" require "../support/win32" +require "../support/wasm32" def datapath(*components) File.join("spec", "std", "data", *components) diff --git a/spec/std/string_spec.cr b/spec/std/string_spec.cr index 178fa81a172c..0d60b3ac2466 100644 --- a/spec/std/string_spec.cr +++ b/spec/std/string_spec.cr @@ -2687,14 +2687,12 @@ describe "String" do end end - {% unless flag?(:wasm32) %} - it "allocates buffer of correct size (#3332)" do - String.new(255_u8) do |buffer| - LibGC.size(buffer).should be > 255 - {255, 0} - end + pending_wasm32 "allocates buffer of correct size (#3332)" do + String.new(255_u8) do |buffer| + LibGC.size(buffer).should be > 255 + {255, 0} end - {% end %} + end it "raises if returned bytesize is greater than capacity" do expect_raises ArgumentError, "Bytesize out of capacity bounds" do diff --git a/spec/support/wasm32.cr b/spec/support/wasm32.cr new file mode 100644 index 000000000000..98c9de69ea9e --- /dev/null +++ b/spec/support/wasm32.cr @@ -0,0 +1,19 @@ +require "spec" + +{% if flag?(:wasm32) %} + def pending_wasm32(description = "assert", file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + pending("#{description} [wasm32]", file, line, end_line) + end + + def pending_wasm32(*, describe, file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + pending_wasm32(describe, file, line, end_line) { } + end +{% else %} + def pending_wasm32(description = "assert", file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + it(description, file, line, end_line, &block) + end + + def pending_wasm32(*, describe, file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + describe(describe, file, line, end_line, &block) + end +{% end %} diff --git a/spec/wasm32_std_spec.cr b/spec/wasm32_std_spec.cr index bd1fd39de7a0..7d762e479b91 100644 --- a/spec/wasm32_std_spec.cr +++ b/spec/wasm32_std_spec.cr @@ -84,7 +84,7 @@ require "./std/float_printer/ieee_spec.cr" require "./std/float_spec.cr" require "./std/gc_spec.cr" require "./std/hash_spec.cr" -# require "./std/html_spec.cr" (failed to run) +require "./std/html_spec.cr" # require "./std/http/chunked_content_spec.cr" (failed linking) # require "./std/http/client/client_spec.cr" (failed linking) # require "./std/http/client/response_spec.cr" (failed linking) @@ -181,7 +181,7 @@ require "./std/named_tuple_spec.cr" # require "./std/openssl/x509/certificate_spec.cr" (failed linking) # require "./std/openssl/x509/name_spec.cr" (failed linking) require "./std/option_parser_spec.cr" -# require "./std/path_spec.cr" (failed to run) +require "./std/path_spec.cr" require "./std/pointer_spec.cr" require "./std/pp_spec.cr" require "./std/pretty_print_spec.cr" @@ -196,7 +196,7 @@ require "./std/random/secure_spec.cr" # require "./std/range_spec.cr" (failed linking) require "./std/record_spec.cr" # require "./std/reference_spec.cr" (failed to run) -# require "./std/regex_spec.cr" (failed to run) +require "./std/regex_spec.cr" require "./std/semantic_version_spec.cr" require "./std/set_spec.cr" require "./std/signal_spec.cr"