Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failure on x86_64-unknown-freebsd #2016

Open
Stranger6667 opened this issue Mar 29, 2024 · 0 comments
Open

Test failure on x86_64-unknown-freebsd #2016

Stranger6667 opened this issue Mar 29, 2024 · 0 comments

Comments

@Stranger6667
Copy link

Hi!

I adapted the FreeBSD CI template to the following so it also runs yarn test and it results in a serde-level error:

  test-freebsd:
    runs-on: macos-12
    name: NodeJS 20 on x86_64-unknown-freebsd
    steps:
      - uses: actions/checkout@v4
      - name: Build
        id: build
        uses: cross-platform-actions/action@v0.21.1
        timeout-minutes: 30
        env:
          DEBUG: 'napi:*'
          RUSTUP_IO_THREADS: 1
        with:
          operating_system: freebsd
          version: '13.2'
          memory: 8G
          cpu_count: 3
          environment_variables: 'DEBUG RUSTUP_IO_THREADS'
          shell: bash
          run: |
            sudo pkg install -y -f curl node libnghttp2 npm
            sudo npm install -g yarn --ignore-scripts
            curl https://sh.rustup.rs -sSf --output rustup.sh
            sh rustup.sh -y --profile minimal --default-toolchain stable
            source "$HOME/.cargo/env"
            cd bindings/javascript
            yarn install
            yarn build
            strip -x *.node
            yarn test

Fails with:

Finished release [optimized] target(s) in 1m 13s
2024-03-27T08:41:07.568Z napi:build Platform: freebsd
2024-03-27T08:41:07.569Z napi:build Platform name: .freebsd-x64
2024-03-27T08:41:07.569Z napi:build Write binary content to [css-inline.freebsd-x64.node]

  Uncaught exception in __test__/index.spec.ts

  Error: invalid type: unit value, expected struct Options

  Error: invalid type: unit value, expected struct Options
      at module.exports.__wbindgen_error_new (/Users/runner/work/css-inline/css-inline/bindings/javascript/node_modules/@swc/wasm/wasm.js:549:17)
      at null.<anonymous> (wasm://wasm/0493877a:1:13340270)
      at null.<anonymous> (wasm://wasm/0493877a:1:13693650)
      at null.<anonymous> (wasm://wasm/0493877a:1:13851783)
      at null.<anonymous> (wasm://wasm/0493877a:1:4298654)
      at null.<anonymous> (wasm://wasm/0493877a:1:3174[530](https://github.com/Stranger6667/css-inline/actions/runs/8448847870/job/23141712265?pr=352#step:3:536))
      at null.<anonymous> (wasm://wasm/0493877a:1:11246699)
      at null.<anonymous> (wasm://wasm/0493877a:1:2101782)
      at null.<anonymous> (wasm://wasm/0493877a:1:2889353)
      at null.<anonymous> (wasm://wasm/0493877a:1:3517515)

  ✘ __test__/index.spec.ts exited with a non-zero exit code: 1
  ─

  1 uncaught exception

The invalid type: unit value, expected struct Options part makes me think that it comes from the argument transformation step when serde fails to transform () to None (as I think it does with other platforms). Here is the code I have in the library:

#[cfg(not(target_arch = "wasm32"))]
#[napi]
/// Inline CSS styles from <style> tags to matching elements in the HTML tree and return a string.
pub fn inline(html: String, options: Option<Options>) -> Result<String, errors::JsError> {
    let options = options.unwrap_or_default();
    inline_inner(html, options)
}

Test code that fails (and similar tests):

import test from "ava";

import { inline } from "../index.js";

test("default inlining", (t) => {
  t.is(
    inline(
      "<html><head><style>h1 { color:red; }</style></head><body><h1>Test</h1></body></html>",
    ),
    '<html><head></head><body><h1 style="color: red;">Test</h1></body></html>',
  );
});

I assume that it expects an empty object as the second argument to inline. Relevant output from cargo expand:

                let arg1 = {
                    <Option<Options> as napi::bindgen_prelude::FromNapiValue>::from_napi_value(
                        env,
                        cb.get_arg(1usize),
                    )?
                };

Relevant PR

Is it something that is not supported, or I have some configuration mistake on my side?
I'd appreciate any input on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant