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

Bug 1679793: Change the RLB Configuration to use PathBuf for the data… #1493

Merged
merged 1 commit into from
Feb 11, 2021

Conversation

ChinYing-Li
Copy link
Contributor

Use std::path::PathBuf instead of String for glean::configueation::Configuration.data_path. Several test cases had also been modified to reflect the change.

All commands succeeded:

make build-rust
make test-rust
make rustfmt
make clippy

@badboy Please review and let me know in case any change is needed. Thank you!

@auto-assign auto-assign bot requested a review from badboy February 10, 2021 01:29
Copy link
Member

@badboy badboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks mostly good. Some simplications are possible, I think I annotated all (you can batch them up here on GitHub and commit that as one thing right from the UI).

I rekicked the tests, I'm not sure why they failed. That's definitely unrelated. If they fail again I need to take another look before we can land this.

} else {
let root = Builder::new().prefix("simple-db").tempdir().unwrap();
root.path().display().to_string()
PathBuf::from(root.path().display().to_string())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PathBuf::from(root.path().display().to_string())
root.path().to_path_buf()

@@ -36,7 +37,7 @@ pub(crate) fn new_glean(
clear_stores: bool,
) -> tempfile::TempDir {
let dir = tempfile::tempdir().unwrap();
let tmpname = dir.path().display().to_string();
let tmpname = PathBuf::from(dir.path().display().to_string());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let tmpname = PathBuf::from(dir.path().display().to_string());
let tmpname = dir.path().to_path_buf();

@@ -35,7 +35,7 @@ fn send_a_ping() {

// Create a custom configuration to use a fake uploader.
let dir = tempfile::tempdir().unwrap();
let tmpname = dir.path().display().to_string();
let tmpname = PathBuf::from(dir.path().display().to_string());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let tmpname = PathBuf::from(dir.path().display().to_string());
let tmpname = dir.path().to_path_buf();

@@ -144,7 +144,7 @@ fn test_experiments_recording_before_glean_inits() {
set_experiment_inactive("experiment_preinit_disabled".to_string());

let dir = tempfile::tempdir().unwrap();
let tmpname = dir.path().display().to_string();
let tmpname = PathBuf::from(dir.path().display().to_string());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let tmpname = PathBuf::from(dir.path().display().to_string());
let tmpname = dir.path().to_path_buf();

@@ -205,7 +205,7 @@ fn sending_of_foreground_background_pings() {

// Create a custom configuration to use a fake uploader.
let dir = tempfile::tempdir().unwrap();
let tmpname = dir.path().display().to_string();
let tmpname = PathBuf::from(dir.path().display().to_string());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let tmpname = PathBuf::from(dir.path().display().to_string());
let tmpname = dir.path().to_path_buf();

@@ -22,7 +23,7 @@ const GLOBAL_APPLICATION_ID: &str = "org.mozilla.glean.test.app";
// We need to keep the `TempDir` alive, so that it's not deleted before we stop using it.
fn new_glean(configuration: Option<Configuration>) -> tempfile::TempDir {
let dir = tempfile::tempdir().unwrap();
let tmpname = dir.path().display().to_string();
let tmpname = PathBuf::from(dir.path().display().to_string());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let tmpname = PathBuf::from(dir.path().display().to_string());
let tmpname = dir.path().to_path_buf();

@@ -74,7 +75,7 @@ fn validate_against_schema() {

// Create a custom configuration to use a validating uploader.
let dir = tempfile::tempdir().unwrap();
let tmpname = dir.path().display().to_string();
let tmpname = PathBuf::from(dir.path().display().to_string());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let tmpname = PathBuf::from(dir.path().display().to_string());
let tmpname = dir.path().to_path_buf();

@@ -3,6 +3,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::io::Read;
use std::path::PathBuf;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use std::path::PathBuf;

@@ -11,6 +11,7 @@
mod common;

use glean::Configuration;
use std::path::PathBuf;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use std::path::PathBuf;

@@ -57,7 +58,7 @@ fn simple_lifecycle() {

// Create a custom configuration to use a validating uploader.
let dir = tempfile::tempdir().unwrap();
let tmpname = dir.path().display().to_string();
let tmpname = PathBuf::from(dir.path().display().to_string());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let tmpname = PathBuf::from(dir.path().display().to_string());
let tmpname = dir.path().to_path_buf();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing that out (how come I didn't notice the to_path_buf()method?).
The requested changes had been made.

Copy link
Member

@badboy badboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 -- One last thing, sorry I forgot to mention it in the first review, this is a breaking change due to the type change.

Can you add an entry to the Changelog?
Something like

* RLB
  * **Breaking change:** Configuration now expects data path as a `PathBuf` ([#1493](https://github.com/mozilla/glean/pull/1493)).

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

Successfully merging this pull request may close these issues.

2 participants