Skip to main content

wasmtime_test_util/
wast.rs

1use serde::de::DeserializeOwned;
2use serde_derive::Deserialize;
3use std::fmt;
4use std::fs;
5use std::path::Path;
6use std::path::PathBuf;
7use wasmtime_environ::prelude::*;
8
9/// Limits for running wast tests.
10///
11/// This is useful for sharing between `tests/wast.rs` and fuzzing, for
12/// example, and is used as the minimum threshold for configuration when
13/// fuzzing.
14///
15/// Note that it's ok to increase these numbers if a test comes along and needs
16/// it, they're just here as empirically found minimum thresholds so far and
17/// they're not too scientific.
18pub mod limits {
19    pub const MEMORY_SIZE: usize = 805 << 16;
20    pub const MEMORIES: u32 = 450;
21    pub const GC_HEAP_SIZE: usize = 10 << 16;
22    pub const TABLES: u32 = 200;
23    pub const MEMORIES_PER_MODULE: u32 = 9;
24    pub const TABLES_PER_MODULE: u32 = 5;
25    pub const COMPONENT_INSTANCES: u32 = 50;
26    pub const CORE_INSTANCES: u32 = 900;
27    pub const TABLE_ELEMENTS: usize = 1000;
28    pub const CORE_INSTANCE_SIZE: usize = 64 * 1024;
29    pub const TOTAL_STACKS: u32 = 20;
30}
31
32/// Local all `*.wast` tests under `root` which should be the path to the root
33/// of the wasmtime repository.
34pub fn find_tests(root: &Path) -> Result<Vec<WastTest>> {
35    let mut tests = Vec::new();
36
37    let spec_tests = root.join("tests/spec_testsuite");
38    add_tests(
39        &mut tests,
40        &spec_tests,
41        &FindConfig::Infer(spec_test_config),
42    )
43    .context("Do you need to `git submodule update --init`?")
44    .with_context(|| format!("failed to add tests from `{}`", spec_tests.display()))?;
45
46    let misc_tests = root.join("tests/misc_testsuite");
47    add_tests(&mut tests, &misc_tests, &FindConfig::InTest)
48        .with_context(|| format!("failed to add tests from `{}`", misc_tests.display()))?;
49
50    let cm_tests = root.join("tests/component-model/test");
51    add_tests(
52        &mut tests,
53        &cm_tests,
54        &FindConfig::Infer(component_test_config),
55    )
56    .context("Do you need to `git submodule update --init`?")
57    .with_context(|| format!("failed to add tests from `{}`", cm_tests.display()))?;
58
59    // Temporarily work around upstream tests that fail in unexpected ways (e.g.
60    // panics, loops, etc).
61    {
62        let skip_list = &[
63            // .. empty currently ..
64        ];
65        tests.retain(|test| {
66            test.path
67                .file_name()
68                .and_then(|name| name.to_str())
69                .map(|name| !skip_list.contains(&name))
70                .unwrap_or(true)
71        });
72    }
73
74    Ok(tests)
75}
76
77enum FindConfig {
78    InTest,
79    Infer(fn(&Path) -> TestConfig),
80}
81
82fn add_tests(tests: &mut Vec<WastTest>, path: &Path, config: &FindConfig) -> Result<()> {
83    for entry in path.read_dir().context("failed to read directory")? {
84        let entry = entry.context("failed to read directory entry")?;
85        let path = entry.path();
86        if entry
87            .file_type()
88            .context("failed to get file type")?
89            .is_dir()
90        {
91            add_tests(tests, &path, config).context("failed to read sub-directory")?;
92            continue;
93        }
94
95        if path.extension().and_then(|s| s.to_str()) != Some("wast") {
96            continue;
97        }
98
99        // These tests use `*.wast` directives not yet supported by Wasmtime, so
100        // wait for a `wasm-tools` update to ungate these.
101        if path.ends_with("spec_testsuite/custom/custom_annot.wast")
102            || path.ends_with("spec_testsuite/custom/branch_hint.wast")
103            || path.ends_with("spec_testsuite/custom/name_annot.wast")
104        {
105            continue;
106        }
107
108        let contents =
109            fs::read_to_string(&path).with_context(|| format!("failed to read test: {path:?}"))?;
110        let config = match config {
111            FindConfig::InTest => parse_test_config(&contents, ";;!")
112                .with_context(|| format!("failed to parse test configuration: {path:?}"))?,
113            FindConfig::Infer(f) => f(&path),
114        };
115        tests.push(WastTest {
116            path,
117            contents,
118            config,
119        })
120    }
121    Ok(())
122}
123
124fn spec_test_config(test: &Path) -> TestConfig {
125    let mut ret = TestConfig::default();
126    ret.spec_test = Some(true);
127    ret.bulk_memory = Some(true);
128    match spec_proposal_from_path(test) {
129        Some("wide-arithmetic") => {
130            ret.wide_arithmetic = Some(true);
131        }
132        Some("threads") => {
133            ret.threads = Some(true);
134            ret.reference_types = Some(false);
135        }
136        Some("custom-page-sizes") => {
137            ret.custom_page_sizes = Some(true);
138            ret.multi_memory = Some(true);
139            ret.memory64 = Some(true);
140            ret.reference_types = Some(true);
141
142            // See commentary below in `wasm-3.0` case for why these "hog
143            // memory"
144            if test.ends_with("memory_max.wast") || test.ends_with("memory_max_i64.wast") {
145                ret.hogs_memory = Some(true);
146            }
147        }
148        Some("custom-descriptors") => {
149            ret.custom_descriptors = Some(true);
150        }
151        Some(proposal) => panic!("unsupported proposal {proposal:?}"),
152
153        // The rough goal here is to enable a minimal set of features for the
154        // spec test in question. The fewer features required the more
155        // configurations this can run on. For example Winch doesn't currently
156        // support GC but it can still run all the simd tests which don't use
157        // GC. In general the upstream spec tests are not silo'd by feature
158        // meaning that one test probably requires a whole bunch of proposals.
159        // The tests are also quite large meaning the entire test may not need
160        // a particular feature, but there's not much we can do about that.
161        //
162        // What follows is a coarse algorithm of guessing, based on a test's
163        // name, what features are needed. The upstream spec test suite is a
164        // frozen commit in a git submodule within this repo meaning that this
165        // should work but will need updates when new tests are added or
166        // preexisting tests are changed.
167        None => {
168            let test_name = test.file_name().unwrap().to_str().unwrap();
169            ret.reference_types = Some(true);
170            ret.multi_memory = Some(true);
171            if test_name.contains("simd") {
172                ret.simd = Some(true);
173            }
174            if test_name.contains("relaxed") {
175                ret.relaxed_simd = Some(true);
176            }
177            if test_name.contains("64") || test_name.contains("mixed") {
178                ret.memory64 = Some(true);
179            }
180            if test_name.contains("ref")
181                || test_name.contains("array")
182                || test_name.contains("struct")
183                || test_name.contains("table")
184                || test_name.contains("type")
185                || test_name.contains("tag")
186                || test_name.contains("extern")
187                || test_name.contains("br_on_")
188                || test_name.contains("linking")
189                || test_name.contains("instance")
190                || test_name.contains("local_init")
191                || test_name.contains("elem")
192                || test_name.contains("global")
193                || test_name.contains("i31")
194                || test_name.contains("unreached-valid")
195                || test_name.contains("select")
196                || test_name.contains("data")
197            {
198                ret.gc = Some(true);
199            }
200            if test_name.contains("return_") || test_name.contains("try_table") {
201                ret.tail_call = Some(true);
202            }
203            if test_name.contains("tag")
204                || test_name.contains("try_table")
205                || test_name.contains("throw")
206                || test_name.contains("ref")
207                || test_name.contains("instance")
208                || test_name.contains("imports")
209            {
210                ret.exceptions = Some(true);
211            }
212            if test_name.contains("global")
213                || test_name.contains("elem")
214                || test_name.contains("data")
215            {
216                ret.extended_const = Some(true);
217            }
218
219            if test.parent().unwrap().ends_with("legacy") {
220                ret.legacy_exceptions = Some(true);
221            }
222
223            // These tests technically don't actually hog any memory but they
224            // do have a module definition with a table/memory that is the
225            // maximum size. These modules fail to compile in the pooling
226            // allocator which has limits on the minimum size of
227            // memories/tables by default.
228            //
229            // Pretend that these hog memory to avoid running the tests in the
230            // pooling allocator.
231            if test.ends_with("memory.wast")
232                || test.ends_with("table.wast")
233                || test.ends_with("memory64.wast")
234                || test.ends_with("table64.wast")
235            {
236                ret.hogs_memory = Some(true);
237            }
238        }
239    }
240
241    ret
242}
243
244fn component_test_config(test: &Path) -> TestConfig {
245    let mut ret = TestConfig::default();
246    ret.spec_test = Some(true);
247    ret.reference_types = Some(true);
248    ret.multi_memory = Some(true);
249    ret.component_model_implements = Some(true);
250    ret.bulk_memory = Some(true);
251    ret.component_model_async = Some(true);
252    ret.component_model_more_async_builtins = Some(true);
253    ret.component_model_async_stackful = Some(true);
254    ret.component_model_threading = Some(true);
255    ret.gc = Some(true);
256    ret.exceptions = Some(true);
257    ret.component_model_map = Some(true);
258    ret.component_model_fixed_length_lists = Some(true);
259
260    if test.ends_with("memory64.wast") {
261        ret.component_model_memory64 = Some(true);
262    }
263
264    if let Some(parent) = test.parent() {
265        if parent.ends_with("wasm-tools") {
266            ret.memory64 = Some(true);
267            ret.threads = Some(true);
268            ret.exceptions = Some(true);
269            ret.gc = Some(true);
270        }
271        if parent.ends_with("wasmtime") {
272            ret.exceptions = Some(true);
273            ret.gc = Some(true);
274        }
275    }
276
277    ret
278}
279
280/// Parse test configuration from the specified test, comments starting with
281/// `;;!`.
282pub fn parse_test_config<T>(wat: &str, comment: &'static str) -> Result<T>
283where
284    T: DeserializeOwned,
285{
286    // The test config source is the leading lines of the WAT file that are
287    // prefixed with `;;!`.
288    let config_lines: Vec<_> = wat
289        .lines()
290        .take_while(|l| l.starts_with(comment))
291        .map(|l| &l[comment.len()..])
292        .collect();
293    let config_text = config_lines.join("\n");
294
295    toml::from_str(&config_text).context("failed to parse the test configuration")
296}
297
298/// A `*.wast` test with its path, contents, and configuration.
299#[derive(Clone)]
300pub struct WastTest {
301    pub path: PathBuf,
302    pub contents: String,
303    pub config: TestConfig,
304}
305
306impl fmt::Debug for WastTest {
307    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
308        f.debug_struct("WastTest")
309            .field("path", &self.path)
310            .field("contents", &"...")
311            .field("config", &self.config)
312            .finish()
313    }
314}
315
316macro_rules! foreach_config_option {
317    ($m:ident) => {
318        $m! {
319            bulk_memory
320            memory64
321            custom_page_sizes
322            multi_memory
323            threads
324            shared_everything_threads
325            gc
326            function_references
327            relaxed_simd
328            reference_types
329            tail_call
330            extended_const
331            wide_arithmetic
332            branch_hinting
333            hogs_memory
334            nan_canonicalization
335            component_model_async
336            component_model_more_async_builtins
337            component_model_async_stackful
338            component_model_threading
339            component_model_error_context
340            component_model_gc
341            component_model_map
342            component_model_memory64
343            component_model_fixed_length_lists
344            component_model_implements
345            simd
346            gc_types
347            exceptions
348            legacy_exceptions
349            stack_switching
350            spec_test
351            custom_descriptors
352        }
353    };
354}
355
356macro_rules! define_test_config {
357    ($($option:ident)*) => {
358        /// Per-test configuration which is written down in the test file itself for
359        /// `misc_testsuite/**/*.wast` or in `spec_test_config` above for spec tests.
360        #[derive(Debug, PartialEq, Default, Deserialize, Clone)]
361        #[serde(deny_unknown_fields)]
362        pub struct TestConfig {
363            $(pub $option: Option<bool>,)*
364        }
365
366        impl TestConfig {
367            $(
368                pub fn $option(&self) -> bool {
369                    self.$option.unwrap_or(false)
370                }
371            )*
372        }
373    }
374}
375
376foreach_config_option!(define_test_config);
377
378impl TestConfig {
379    /// Returns an iterator over each option.
380    pub fn options_mut(&mut self) -> impl Iterator<Item = (&'static str, &mut Option<bool>)> {
381        macro_rules! mk {
382            ($($option:ident)*) => {
383                [
384                    $((stringify!($option), &mut self.$option),)*
385                ].into_iter()
386            }
387        }
388        foreach_config_option!(mk)
389    }
390}
391
392/// Configuration that spec tests can run under.
393#[derive(Debug)]
394pub struct WastConfig {
395    /// Compiler chosen to run this test.
396    pub compiler: Compiler,
397    /// Whether or not the pooling allocator is enabled.
398    pub pooling: bool,
399    /// What garbage collector is being used.
400    pub collector: Collector,
401}
402
403/// Different compilers that can be tested in Wasmtime.
404#[derive(PartialEq, Debug, Copy, Clone)]
405pub enum Compiler {
406    /// Cranelift backend.
407    ///
408    /// This tests the Cranelift code generator for native platforms. This
409    /// notably excludes Pulley since that's listed separately below even though
410    /// Pulley is a backend of Cranelift. This is only used for native code
411    /// generation such as x86_64.
412    CraneliftNative,
413
414    /// Winch backend.
415    ///
416    /// This tests the Winch backend for native platforms. Currently Winch
417    /// primarily supports x86_64.
418    Winch,
419
420    /// Pulley interpreter.
421    ///
422    /// This tests the Cranelift pulley backend plus the pulley execution
423    /// environment of the output bytecode. Note that this is separate from
424    /// `Cranelift` above to be able to test both on platforms where Cranelift
425    /// has native codegen support.
426    CraneliftPulley,
427}
428
429impl Compiler {
430    /// Returns whether this compiler is known to fail for the provided
431    /// `TestConfig`.
432    ///
433    /// This function will determine if the configuration of the test provided
434    /// is known to guarantee fail. This effectively tracks the proposal support
435    /// for each compiler backend/runtime and tests whether `config` enables or
436    /// disables features that aren't supported.
437    ///
438    /// Note that this is closely aligned with
439    /// `Config::compiler_panicking_wasm_features`.
440    pub fn should_fail(&self, config: &TestConfig) -> bool {
441        match self {
442            Compiler::CraneliftNative => {
443                if config.legacy_exceptions() {
444                    return true;
445                }
446
447                // Stack-switching is only implemented on x86_64 for unix
448                // platforms right now.
449                if config.stack_switching() && !(cfg!(target_arch = "x86_64") && cfg!(unix)) {
450                    return true;
451                }
452
453                false
454            }
455
456            Compiler::Winch => {
457                if config.gc()
458                    || config.tail_call()
459                    || config.function_references()
460                    || config.relaxed_simd()
461                    || config.legacy_exceptions()
462                    || config.stack_switching()
463                {
464                    return true;
465                }
466
467                if cfg!(target_arch = "aarch64") {
468                    return config.threads();
469                }
470
471                !cfg!(target_arch = "x86_64")
472            }
473
474            Compiler::CraneliftPulley => {
475                config.threads() || config.legacy_exceptions() || config.stack_switching()
476            }
477        }
478    }
479
480    /// Returns whether this compiler configuration supports the current host
481    /// architecture.
482    pub fn supports_host(&self) -> bool {
483        match self {
484            Compiler::CraneliftNative => {
485                cfg!(target_arch = "x86_64")
486                    || cfg!(target_arch = "aarch64")
487                    || cfg!(target_arch = "riscv64")
488                    || cfg!(target_arch = "s390x")
489            }
490            Compiler::Winch => cfg!(target_arch = "x86_64") || cfg!(target_arch = "aarch64"),
491            Compiler::CraneliftPulley => true,
492        }
493    }
494}
495
496#[derive(PartialEq, Debug, Copy, Clone)]
497pub enum Collector {
498    Auto,
499    Null,
500    DeferredReferenceCounting,
501    Copying,
502}
503
504impl WastTest {
505    /// Returns whether this test exercises the GC types and might want to use
506    /// multiple different garbage collectors.
507    pub fn test_uses_gc_types(&self) -> bool {
508        self.config.gc() || self.config.function_references()
509    }
510
511    /// Returns the optional spec proposal that this test is associated with.
512    pub fn spec_proposal(&self) -> Option<&str> {
513        spec_proposal_from_path(&self.path)
514    }
515
516    /// Returns whether this test should fail under the specified extra
517    /// configuration.
518    pub fn should_fail(&self, config: &WastConfig) -> bool {
519        if !config.compiler.supports_host() {
520            return true;
521        }
522
523        // Some tests are known to fail with the pooling allocator
524        if config.pooling {
525            // allocates too much memory for the pooling configuration here
526            if self.config.hogs_memory() {
527                return true;
528            }
529            let unsupported = [
530                // shared memories + pooling allocator aren't supported yet
531                "misc_testsuite/memory-combos.wast",
532                "misc_testsuite/threads/atomics-end-of-memory.wast",
533                "misc_testsuite/threads/atomic_wait_endianness.wast",
534                "misc_testsuite/threads/LB.wast",
535                "misc_testsuite/threads/LB_atomic.wast",
536                "misc_testsuite/threads/MP.wast",
537                "misc_testsuite/threads/MP_atomic.wast",
538                "misc_testsuite/threads/MP_wait.wast",
539                "misc_testsuite/threads/SB.wast",
540                "misc_testsuite/threads/SB_atomic.wast",
541                "misc_testsuite/threads/atomics_notify.wast",
542                "misc_testsuite/threads/atomics_wait_address.wast",
543                "misc_testsuite/threads/wait_notify.wast",
544                "spec_testsuite/proposals/threads/atomic.wast",
545                "spec_testsuite/proposals/threads/exports.wast",
546                "spec_testsuite/proposals/threads/memory.wast",
547                "misc_testsuite/memory64/threads.wast",
548                "misc_testsuite/winch/rmw32_cmpxchg_u_wrap.wast",
549            ];
550
551            if unsupported.iter().any(|part| self.path.ends_with(part)) {
552                return true;
553            }
554        }
555
556        if config.compiler.should_fail(&self.config) {
557            return true;
558        }
559
560        // Disable spec tests per target for proposals that Winch does not implement yet.
561        if config.compiler == Compiler::Winch {
562            // Common list for tests that fail in all targets supported by Winch.
563            let unsupported = [
564                "extended-const/elem.wast",
565                "extended-const/global.wast",
566                "misc_testsuite/externref-segments.wast",
567                "misc_testsuite/externref-table-dropped-segment-issue-8281.wast",
568                "misc_testsuite/many_table_gets_lead_to_gc.wast",
569                "misc_testsuite/no-panic.wast",
570                // Currently exceptions trap on throw, re-enable after catch
571                // is implemented.
572                "misc_testsuite/traps-skip-catch-all.wast",
573                "misc_testsuite/component-model/async/exceptions.wast",
574                "spec_testsuite/throw.wast",
575            ];
576
577            if unsupported.iter().any(|part| self.path.ends_with(part)) {
578                return true;
579            }
580
581            #[cfg(target_arch = "x86_64")]
582            {
583                // SIMD on Winch requires AVX instructions.
584                #[cfg(target_arch = "x86_64")]
585                if !(std::is_x86_feature_detected!("avx") && std::is_x86_feature_detected!("avx2"))
586                {
587                    let unsupported = [
588                        "annotations/simd_lane.wast",
589                        "memory64/simd.wast",
590                        "misc_testsuite/int-to-float-splat.wast",
591                        "misc_testsuite/issue6562.wast",
592                        "misc_testsuite/simd/almost-extmul.wast",
593                        "misc_testsuite/simd/canonicalize-nan.wast",
594                        "misc_testsuite/simd/cvt-from-uint.wast",
595                        "misc_testsuite/simd/edge-of-memory.wast",
596                        "misc_testsuite/simd/issue_3327_bnot_lowering.wast",
597                        "misc_testsuite/simd/issue6725-no-egraph-panic.wast",
598                        "misc_testsuite/simd/replace-lane-preserve.wast",
599                        "misc_testsuite/simd/spillslot-size-fuzzbug.wast",
600                        "misc_testsuite/simd/sse-cannot-fold-unaligned-loads.wast",
601                        "misc_testsuite/winch/issue-10331.wast",
602                        "misc_testsuite/int-to-float-splat.wast",
603                        "misc_testsuite/simd/cvt-from-uint.wast",
604                        "misc_testsuite/winch/replace_lane.wast",
605                        "misc_testsuite/simd/riscv64-replicated-imm5-works.wast",
606                        "misc_testsuite/simd/v128-equal.wast",
607                        "misc_testsuite/winch/issue-10331.wast",
608                        "misc_testsuite/int-to-float-splat.wast",
609                        "misc_testsuite/simd/cvt-from-uint.wast",
610                        "spec_testsuite/simd_align.wast",
611                        "spec_testsuite/simd_boolean.wast",
612                        "spec_testsuite/simd_conversions.wast",
613                        "spec_testsuite/simd_f32x4.wast",
614                        "spec_testsuite/simd_f32x4_arith.wast",
615                        "spec_testsuite/simd_f32x4_cmp.wast",
616                        "spec_testsuite/simd_f32x4_pmin_pmax.wast",
617                        "spec_testsuite/simd_f32x4_rounding.wast",
618                        "spec_testsuite/simd_f64x2.wast",
619                        "spec_testsuite/simd_f64x2_arith.wast",
620                        "spec_testsuite/simd_f64x2_cmp.wast",
621                        "spec_testsuite/simd_f64x2_pmin_pmax.wast",
622                        "spec_testsuite/simd_f64x2_rounding.wast",
623                        "spec_testsuite/simd_i16x8_cmp.wast",
624                        "spec_testsuite/simd_i32x4_cmp.wast",
625                        "spec_testsuite/simd_i64x2_arith2.wast",
626                        "spec_testsuite/simd_i64x2_cmp.wast",
627                        "spec_testsuite/simd_i8x16_arith2.wast",
628                        "spec_testsuite/simd_i8x16_cmp.wast",
629                        "spec_testsuite/simd_int_to_int_extend.wast",
630                        "spec_testsuite/simd_load.wast",
631                        "spec_testsuite/simd_load_extend.wast",
632                        "spec_testsuite/simd_load_splat.wast",
633                        "spec_testsuite/simd_load_zero.wast",
634                        "spec_testsuite/simd_splat.wast",
635                        "spec_testsuite/simd_store16_lane.wast",
636                        "spec_testsuite/simd_store32_lane.wast",
637                        "spec_testsuite/simd_store64_lane.wast",
638                        "spec_testsuite/simd_store8_lane.wast",
639                        "spec_testsuite/simd_load16_lane.wast",
640                        "spec_testsuite/simd_load32_lane.wast",
641                        "spec_testsuite/simd_load64_lane.wast",
642                        "spec_testsuite/simd_load8_lane.wast",
643                        "spec_testsuite/simd_bitwise.wast",
644                        "misc_testsuite/simd/load_splat_out_of_bounds.wast",
645                        "misc_testsuite/simd/unaligned-load.wast",
646                        "misc_testsuite/simd/riscv64-replicated-imm5-works.wast",
647                        "misc_testsuite/simd/issue6725-no-egraph-panic.wast",
648                        "misc_testsuite/winch/replace_lane.wast",
649                        "misc_testsuite/simd/v128-equal.wast",
650                        "misc_testsuite/winch/issue-10331.wast",
651                        "misc_testsuite/int-to-float-splat.wast",
652                        "misc_testsuite/simd/cvt-from-uint.wast",
653                        "spec_testsuite/simd_memory-multi.wast",
654                        "misc_testsuite/simd/issue4807.wast",
655                        "spec_testsuite/simd_const.wast",
656                        "spec_testsuite/simd_i8x16_sat_arith.wast",
657                        "spec_testsuite/simd_i64x2_arith.wast",
658                        "spec_testsuite/simd_i16x8_arith.wast",
659                        "spec_testsuite/simd_i16x8_arith2.wast",
660                        "spec_testsuite/simd_i16x8_q15mulr_sat_s.wast",
661                        "spec_testsuite/simd_i16x8_sat_arith.wast",
662                        "spec_testsuite/simd_i32x4_arith.wast",
663                        "spec_testsuite/simd_i32x4_dot_i16x8.wast",
664                        "spec_testsuite/simd_i32x4_trunc_sat_f32x4.wast",
665                        "spec_testsuite/simd_i32x4_trunc_sat_f64x2.wast",
666                        "spec_testsuite/simd_i8x16_arith.wast",
667                        "spec_testsuite/simd_bit_shift.wast",
668                        "spec_testsuite/simd_lane.wast",
669                        "spec_testsuite/simd_i16x8_extmul_i8x16.wast",
670                        "spec_testsuite/simd_i32x4_extmul_i16x8.wast",
671                        "spec_testsuite/simd_i64x2_extmul_i32x4.wast",
672                        "spec_testsuite/simd_i16x8_extadd_pairwise_i8x16.wast",
673                        "spec_testsuite/simd_i32x4_extadd_pairwise_i16x8.wast",
674                        "spec_testsuite/simd_i32x4_arith2.wast",
675                    ];
676
677                    if unsupported.iter().any(|part| self.path.ends_with(part)) {
678                        return true;
679                    }
680                }
681            }
682        }
683
684        // Not implemented in Wasmtime anywhere yet.
685        if self.config.custom_descriptors() {
686            let happens_to_work =
687                ["spec_testsuite/proposals/custom-descriptors/binary-leb128.wast"];
688
689            if happens_to_work.iter().any(|part| self.path.ends_with(part)) {
690                return false;
691            }
692            return true;
693        }
694
695        false
696    }
697}
698
699fn spec_proposal_from_path(path: &Path) -> Option<&str> {
700    let mut iter = path.iter();
701    loop {
702        match iter.next()?.to_str()? {
703            "proposals" => break,
704            _ => {}
705        }
706    }
707    Some(iter.next()?.to_str()?)
708}