[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-bugs] #25639 [Core Tor/Tor]: think about Rust crate boundaries



#25639: think about Rust crate boundaries
--------------------------+----------------------------------
 Reporter:  Hello71       |          Owner:  Hello71
     Type:  enhancement   |         Status:  assigned
 Priority:  High          |      Milestone:
Component:  Core Tor/Tor  |        Version:  Tor: unspecified
 Severity:  Normal        |     Resolution:
 Keywords:  rust          |  Actual Points:
Parent ID:                |         Points:
 Reviewer:                |        Sponsor:
--------------------------+----------------------------------

Comment (by manish.earth):

 From Firefox's point of view, there's basically a single crate (the
 "shared"[1] crate you see) that links in everything. The crate itself is
 (almost) empty aside from `extern crate` declarations. The individual
 crate dependencies can be cfgd on or off, but all of it must go through
 this single crate.

 Firefox doesn't run Rust tests (i.e. `cargo test` tests). Servo does, in
 its CI, however Servo is a standalone application that doesn't need
 Firefox C code to run. The Servo compilation mode that's used in Firefox
 ("libgeckoservo") *does* need Firefox C code to run. There are some tests
 for the libgeckoservo mode, however they only test very specific things.
 The understanding is that Firefox's tests will take care of bugs in
 libgeckoservo, so we don't need to specifically test libgeckoservo
 (commits get CId on both sides).


 If Firefox wishes to test Rust code, it gets put in the gktest crate,
 which integrates with the GTest framework which Firefox already uses.

 The way it works is that the "shared" crate is linked to by an empty
 "gkrust"[2] crate, as well as another empty "gktest" crate[3]. The gkrust
 crate is what's actually included in the Firefox build, whereas the gktest
 crate additionally contains some extra test crates which have a bunch of
 extern "C" Rust test functions that get called.

 You can see an example of some tests here[4], which get called from a
 GTest file here[5].


 --------------


 Applying this to Tor, the way to make it work would be to have a single
 toplevel crate, which optionally includes some testing crates which export
 test symbols that get called from a C test file for whatever framework
 y'all use. This isn't great; I'm hoping in the future `cargo test` will be
 better at this (we're working on custom test frameworks which should make
 this easier).




  [1]: https://hg.mozilla.org/mozilla-
 central/file/tip/toolkit/library/rust/shared/Cargo.toml
  [2]: https://hg.mozilla.org/mozilla-
 central/file/tip/toolkit/library/rust/Cargo.toml
  [3]: https://hg.mozilla.org/mozilla-
 central/file/tip/toolkit/library/gtest/rust/Cargo.toml
  [4]: https://hg.mozilla.org/mozilla-
 central/file/tip/xpcom/rust/gtest/nsstring/test.rs
  [5]: https://hg.mozilla.org/mozilla-
 central/file/tip/xpcom/rust/gtest/nsstring/Test.cpp

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/25639#comment:9>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs