Building tests with gn

3 views
Skip to first unread message

Tim Kilbourn

unread,
Jul 24, 2017, 3:20:29 PM7/24/17
to rust-f...@fuchsia.com
When I build a rust_library that sets with_tests = true, I don't see full error messages from the compiler. Is there a way to get those errors printed during a gn build? Or some equivalent Cargo commandline I can use?

[1/12] ACTION //rust/mxio:mxio(//build/toolchain/fuchsia:x64)
FAILED: obj/rust/mxio/mxio.rust/x86_64-unknown-fuchsia/release/libmxio.rmeta gen/rust/mxio/mxio.rust/mxio.info.toml obj/rust/mxio/mxio.rust/mxio-lib-test 
/usr/bin/env ../../build/rust/build_target.py --type lib --name mxio --out-dir /usr/local/google/home/tkilbourn/src/fuchsia/out/release-x86-64/obj/rust/mxio/mxio.rust --gen-dir /usr/local/google/home/tkilbourn/src/fuchsia/out/release-x86-64/gen/rust/mxio/mxio.rust --root-out-dir /usr/local/google/home/tkilbourn/src/fuchsia/out/release-x86-64 --root-gen-dir /usr/local/google/home/tkilbourn/src/fuchsia/out/release-x86-64/gen --crate-root /usr/local/google/home/tkilbourn/src/fuchsia/rust/mxio --cargo /usr/local/google/home/tkilbourn/src/fuchsia/buildtools/rust/rust-x86_64-unknown-linux-gnu/bin/cargo --rustc /usr/local/google/home/tkilbourn/src/fuchsia/buildtools/rust/rust-x86_64-unknown-linux-gnu/bin/rustc --target-triple x86_64-unknown-fuchsia --label //rust/mxio:mxio --cmake-dir /usr/local/google/home/tkilbourn/src/fuchsia/buildtools/cmake/bin --vendor-directory /usr/local/google/home/tkilbourn/src/fuchsia/third_party/rust-crates/vendor --deps //rust/magenta-rs:magenta //rust/magenta-rs/magenta-sys:magenta-sys //third_party/rust-crates:tempdir-0.3.5 --shared-libs-root /usr/local/google/home/tkilbourn/src/fuchsia/out/release-x86-64/x64-shared --with-tests --release --linker /usr/local/google/home/tkilbourn/src/fuchsia/out/release-x86-64/host_x64/x86_64-unknown-fuchsia-cc
error: Could not compile `mxio`.

To learn more, run the command again with --verbose.
Traceback (most recent call last):
  File "../../build/rust/build_target.py", line 351, in <module>
    sys.exit(main())
  File "../../build/rust/build_target.py", line 332, in main
    messages = subprocess.check_output(test_args, env=env, cwd=args.gen_dir)
  File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['/usr/local/google/home/tkilbourn/src/fuchsia/buildtools/rust/rust-x86_64-unknown-linux-gnu/bin/cargo', 'test', '--target=x86_64-unknown-fuchsia', '-q', '--release', '--lib', '--no-run', '--message-format=json']' returned non-zero exit status 101
ninja: build stopped: subcommand failed.

Tim Kilbourn

unread,
Jul 24, 2017, 4:54:14 PM7/24/17
to rust-f...@fuchsia.com
Rob pointed me at Fargo which can build the tests to show the compilation errors. With cargo, it's as easy as checking out fargo and running 'cargo install'. Then set $FUCHSIA_ROOT (bug filed to find it automatically if you're in a Fuchsia checkout) and run 'fargo build-tests' in the crate's dir. Now I just have to figure out how to get our package system to put a library's tests into user.bootfs.
Reply all
Reply to author
Forward
0 new messages