Closed mycognosist closed 3 years ago
Great to see this PR! In running it locally I bumped into some goblins:
➜ ssb-validate2-rsjs git:(web_tests) ✗ npm run build:web
> ssb-validate2-rsjs@0.3.0 build:web /home/staltz/oss/ssb-validate2-rsjs
> cd web && wasm-pack build --target web
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Downloaded miniz_oxide v0.4.0
Downloaded addr2line v0.14.0
Downloaded hashbrown v0.9.0
Downloaded getopts v0.2.21
Downloaded object v0.22.0
Downloaded compiler_builtins v0.1.39
Downloaded dlmalloc v0.2.1
Downloaded libc v0.2.85
Downloaded gimli v0.23.0
Downloaded 9 crates (1.8 MB) in 1.16s
Compiling compiler_builtins v0.1.39
Compiling core v0.0.0 (/home/staltz/.rustup/toolchains/nightly-2021-02-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
Compiling libc v0.2.85
Compiling cc v1.0.60
Compiling dlmalloc v0.2.1
Compiling std v0.0.0 (/home/staltz/.rustup/toolchains/nightly-2021-02-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std)
Compiling typenum v1.13.0
Compiling proc-macro2 v1.0.26
Compiling unicode-xid v0.2.2
Compiling syn v1.0.72
Compiling autocfg v1.0.1
Compiling version_check v0.9.3
Compiling serde_derive v1.0.126
Compiling autocfg v0.1.7
Compiling serde v1.0.126
Compiling getrandom v0.1.16
Compiling cc v1.0.67
Compiling wasm-bindgen-shared v0.2.74
Compiling log v0.4.14
Compiling libc v0.2.94
Compiling ryu v1.0.5
Compiling rayon-core v1.9.1
Compiling cfg-if v1.0.0
Compiling serde_json v1.0.64
Compiling ryu-ecmascript v0.1.1
Compiling rand_core v0.4.2
Compiling lazy_static v1.4.0
Compiling bumpalo v3.6.1
Compiling memchr v2.4.0
Compiling doc-comment v0.3.3
Compiling byteorder v1.4.3
Compiling subtle v2.4.0
Compiling wasm-bindgen v0.2.74
Compiling unwind v0.0.0 (/home/staltz/.rustup/toolchains/nightly-2021-02-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/unwind)
Compiling crossbeam-utils v0.8.4
Compiling memoffset v0.6.3
Compiling indexmap v1.6.2
Compiling rayon v1.5.1
Compiling generic-array v0.14.4
Compiling rand_chacha v0.1.1
Compiling rand_pcg v0.1.2
Compiling rand v0.6.5
Compiling rand_core v0.3.1
Compiling clear_on_drop v0.2.4
error: failed to run custom build command for `clear_on_drop v0.2.4`
Caused by:
process didn't exit successfully: `/home/staltz/oss/ssb-validate2-rsjs/target/release/build/clear_on_drop-88fd4a0e60567bfb/build-script-build` (exit code: 1)
--- stdout
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-o" "/home/staltz/oss/ssb-validate2-rsjs/target/wasm32-unknown-unknown/release/build/clear_on_drop-86c2dc42ab4a5968/out/src/hide.o" "-c" "src/hide.c"
--- stderr
error occurred: Failed to find tool. Is `clang` installed?
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
More info
Default host: x86_64-unknown-linux-gnu
rustup home: /home/staltz/.rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu
nightly-2021-02-11-x86_64-unknown-linux-gnu
installed targets for active toolchain
--------------------------------------
aarch64-linux-android
arm-linux-androideabi
armv7-linux-androideabi
i686-linux-android
x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.46.0 (04488afe3 2020-08-24)
cargo 1.46.0 (149022b1d 2020-07-17)
release: 1.46.0
commit-hash: 149022b1d8f382e69c1616f6a46b69ebf59e2dea
commit-date: 2020-07-17
I ran sudo apt install clang
on my Ubuntu 18.04 and then I got this:
clang not found
➜ ssb-validate2-rsjs git:(web_tests) ✗ npm run build:web
> ssb-validate2-rsjs@0.3.0 build:web /home/staltz/oss/ssb-validate2-rsjs
> cd web && wasm-pack build --target web
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Compiling rustc-std-workspace-core v1.99.0 (/home/staltz/.rustup/toolchains/nightly-2021-02-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
Compiling clear_on_drop v0.2.4
Compiling generic-array v0.12.4
Compiling quote v1.0.9
The following warnings were emitted during compilation:
warning: error: unable to create target: 'No available targets are compatible with this triple.'
warning: 1 error generated.
error: failed to run custom build command for `clear_on_drop v0.2.4`
Caused by:
process didn't exit successfully: `/home/staltz/oss/ssb-validate2-rsjs/target/release/build/clear_on_drop-88fd4a0e60567bfb/build-script-build` (exit code: 1)
--- stdout
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-o" "/home/staltz/oss/ssb-validate2-rsjs/target/wasm32-unknown-unknown/release/build/clear_on_drop-86c2dc42ab4a5968/out/src/hide.o" "-c" "src/hide.c"
cargo:warning=error: unable to create target: 'No available targets are compatible with this triple.'
cargo:warning=1 error generated.
exit code: 1
--- stderr
error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-o" "/home/staltz/oss/ssb-validate2-rsjs/target/wasm32-unknown-unknown/release/build/clear_on_drop-86c2dc42ab4a5968/out/src/hide.o" "-c" "src/hide.c" with args "clang" did not execute successfully (status code exit code: 1).
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
I believe the key to the latest error is:
cargo:warning=error: unable to create target: 'No available targets are compatible with this triple.'
When I compared your rustup show
output (very helpful) with mine, I noticed that the wasm32-unknown-unknown
target is missing on your end. You can add it and retry the npm run build:web
step.
rustup target add wasm32-unknown-unknown
I ran rustup target add wasm32-unknown-unknown
and still get the same error. Is it perhaps that clang
needs to support that target, not just rustc
?
Could you share which version of clang do you have on your machine? Or maybe does wasm-pack docs describe which versions we need?
➜ ~ clang --version
clang version 11.1.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Okay, clang-10 worked (that was the highest version I found in apt search
). These instructions should be added to the web readme:
rustup target add wasm32-unknown-unknown
clang
10 or higherI got a strange error in running the tests though, it might be some Karma sadness, because it seems like the actual tests did run and passed (see below). I'm okay with merging without fixing these:
26 05 2021 11:20:16.278:INFO [karma-server]: Karma v6.3.2 server started at http://localhost:9876/
26 05 2021 11:20:16.280:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
26 05 2021 11:20:16.283:INFO [launcher]: Starting browser Chrome
26 05 2021 11:20:17.422:INFO [Chrome 86.0.4240.111 (Linux x86_64)]: Connected on socket DvccERlhYftph9zWAAAB with id 84022170
Chrome 86.0.4240.111 (Linux x86_64): Executed 0 of 0 SUCCESS (0.013 secs / 0 secs)
TOTAL: 0 SUCCESS
Great that it's working. Thanks for your perseverance. I will add the necessary docs and commit before merging.
The spies
error is very odd (we're not even using spies
in our test suite). It's annoying that the error results in the output being:
Executed 0 of 0 SUCCESS (0.013 secs / 0 secs)
-_-
Will look to see if this is a known issue.
The same error is discussed in this issue: error ".spies undefined" after all specs run as of v.2.5.x #1231
Reverting to jasmine 2.4.1
seems to fix it for some of those folx. If I had to guess, I'd say the problem is originating in karma-esm
which uses SystemJS
. It's weird that I don't see the same error when running the tests on my machine. I'm not going to spend time on this now but will make a note to potentially look at it in the future (at least we have in-console confirmation that the tests are passing on your setup).
Obligatory: are we web yet? Why yes, I do believe we are :)
Test verification and validation in the browser
Major changes
web/test/singleAuthorMessages.js
andweb/test/multiAuthorMessages.js
)web/test/test.js
andweb/test/multiAuthorTest.js
)native/test/
(consistency betweenweb
andnative
)Minor changes
Adds convenience dev scripts for testing
web
andweb + native
Updates READMEs in repo root,
web
andnative
web
andnative
versions contain extra info for developersPrettifies all the JS things (kind of 'oops' but I'm not mad about it)
Bumps version to
0.3.0
Still to come
Run web tests in Firefox (possibly other popular browsers too)