|
| 1 | +# Local testing against the Firefox codebase |
| 2 | + |
| 3 | +Testing `fluent-rs` locally against a local copy of the Firefox codebase can be done with the following steps. |
| 4 | + |
| 5 | +## 1. Clone Firefox locally |
| 6 | + |
| 7 | +Bootstrap a copy of the Firefox source code without the Artifact Builds (it is needed to be able to modify the Rust dependencies). |
| 8 | + |
| 9 | +See the [Firefox Contributors’ Quick Reference](https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html) for more information on how to achieve that on your operating system. |
| 10 | + |
| 11 | +## 2. Delete the `fluent-rs` vendored packages |
| 12 | + |
| 13 | +Remove the following packages from the `mozilla-unified/third_party/rust` directory: |
| 14 | + |
| 15 | +- fluent |
| 16 | +- fluent-bundle |
| 17 | +- fluent-fallback |
| 18 | +- fluent-pseudo |
| 19 | +- fluent-syntax |
| 20 | +- fluent-testing |
| 21 | +- intl-memoizer |
| 22 | + |
| 23 | +## 3. Bump version numbers |
| 24 | + |
| 25 | +To avoid the `Some non-crates.io-fetched packages match published crates.io versions` error while checking the `fluent-rs` dependencies in the Firefox codebase, we must first bump the version of all the `fluent-rs` packages. |
| 26 | + |
| 27 | +To update a package, use the `cargo-release` tool. It can be installed with `cargo install cargo-release`. |
| 28 | + |
| 29 | +Run the following command in the `fluent-rs` directory to bump the version of all its packages: |
| 30 | + |
| 31 | +``` |
| 32 | +cargo release version patch -p fluent -p fluent-bundle -p fluent-fallback -p fluent-pseudo -p fluent-syntax -p fluent-testing -p intl-memoizer --execute` |
| 33 | +``` |
| 34 | + |
| 35 | +## 4. Upgrade dependencies |
| 36 | + |
| 37 | +Now we need to upgrade all the dependencies to `fluent-rs` in the Firefox codebase to match our local copy. |
| 38 | + |
| 39 | +- [Search for all references](https://searchfox.org/mozilla-central/search?q=%5E%28fluent%28-%5Cw%2B%29%3F%7Cintl-memoizer%29+%3D+%22.*%22&path=&case=false®exp=true) |
| 40 | +- Update all the references to our local packages by using `{ path = "..." }` in the `Cargo.toml` file of the impacted packages. |
| 41 | + |
| 42 | +### Exemple |
| 43 | + |
| 44 | +If both `fluent-rs` and `mozilla_unified` directories are on the same root directory, you can update the `fluent-fallback` entry from `fluent-fallback = "0.7.0"` to `fluent-fallback = { path = "../../../../../fluent-rs/fluent-fallback" }` in the `mozilla-unified/intl/l10n/rust/l10nregistry-ffi/Cargo.toml` file. |
| 45 | + |
| 46 | +## 5. Check the local `fluent-rs` dependencies |
| 47 | + |
| 48 | +It is done by running `./mach vendor rust` at the root of the `mozilla-unified` directory. If the `./mach vendor rust` command runs without any problems, you're good to go! |
| 49 | + |
| 50 | +### Vetting a dependency |
| 51 | + |
| 52 | +If you see an error similar to `intel-memoizer type-map = "0.5" must be vetted (current vetted version at 0.4) =`, it means that the current vetted version of the `type-map` package is `0.4` but we're using the `0.5` version in `fluent-rs`. |
| 53 | + |
| 54 | +It can be fixed in the `supply-chain/config.toml` file by bumping the version in the `[[exemptions.type-map]]` to `0.5`. |
0 commit comments