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

Remove the argument from the project test support function #5752

Merged
merged 3 commits into from
Jul 20, 2018

Conversation

dwijnand
Copy link
Member

By rewriting the tests, with rerast (https://github.com/google/rerast), to
use the newly introduced "at" method.

First I added the following temporary function to cargotest::support:

pub fn project_foo() -> ProjectBuilder {
   project("foo")
}

Then I defined the following rewrite.rs:

use cargotest::support::{ project, project_foo };

fn rule1(a: &'static str) {
   replace!(project("foo") => project_foo());
   replace!(project(a) => project_foo().at(a));
}

Then I ran rerast:

cargo +nightly rerast --rules_file=rewrite.rs --force --targets tests --file tests/testsuite/main.rs

Finally I searched and replaced the references to project_foo with
argument-less project (a little awkardly on macOS with a git clean).

find tests -type f -exec sed -i -e 's/project_foo/project/g' {} +
git clean -d tests

Fixes #5746

dwijnand added 2 commits July 19, 2018 13:55
By rewriting the tests, with rerast (https://github.com/google/rerast),
to use the newly introduced "at" method.

First I added the following temporary function to cargotest::support:

    pub fn project_foo() -> ProjectBuilder {
        project("foo")
    }

Then I defined the following rewrite.rs:

    use cargotest::support::{ project, project_foo };

    fn rule1(a: &'static str) {
        replace!(project("foo") => project_foo());
        replace!(project(a) => project_foo().at(a));
    }

Then I ran rerast:

    cargo +nightly rerast --rules_file=rewrite.rs --force --targets tests --file tests/testsuite/main.rs

Finally I searched and replaced the references to project_foo with
argument-less project (a little awkardly on macOS with a git clean).

    find tests -type f -exec sed -i -e 's/project_foo/project/g' {} +
    git clean -d tests
@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@dwijnand
Copy link
Member Author

Good pick, highfive.

Copy link
Member Author

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

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

To help review I've pointed out the non-mechanical changes. 😄

pub fn project(name: &str) -> ProjectBuilder {
ProjectBuilder::new(paths::root().join(name))
pub fn project() -> ProjectBuilder {
ProjectBuilder::new(paths::root().join("foo"))
Copy link
Member Author

Choose a reason for hiding this comment

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

hard-coded "foo"

@@ -126,6 +126,11 @@ impl ProjectBuilder {
}
}

pub fn at<P: AsRef<Path>>(mut self, path: P) -> Self {
self.root = Project::Rooted(paths::root().join(path));
self
Copy link
Member Author

Choose a reason for hiding this comment

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

newly introduced "at" method

.. in docs, commented code & tests targetting non-macos.
@alexcrichton
Copy link
Member

@bors: r+

Nice!

@bors
Copy link
Contributor

bors commented Jul 20, 2018

📌 Commit 6da2ada has been approved by alexcrichton

bors added a commit that referenced this pull request Jul 20, 2018
Remove the argument from the `project` test support function

By rewriting the tests, with rerast (https://github.com/google/rerast), to
use the newly introduced "at" method.

First I added the following temporary function to cargotest::support:

    pub fn project_foo() -> ProjectBuilder {
       project("foo")
    }

Then I defined the following rewrite.rs:

    use cargotest::support::{ project, project_foo };

    fn rule1(a: &'static str) {
       replace!(project("foo") => project_foo());
       replace!(project(a) => project_foo().at(a));
    }

Then I ran rerast:

    cargo +nightly rerast --rules_file=rewrite.rs --force --targets tests --file tests/testsuite/main.rs

Finally I searched and replaced the references to project_foo with
argument-less project (a little awkardly on macOS with a git clean).

    find tests -type f -exec sed -i -e 's/project_foo/project/g' {} +
    git clean -d tests

Fixes #5746
@bors
Copy link
Contributor

bors commented Jul 20, 2018

⌛ Testing commit 6da2ada with merge 8482505...

@bors
Copy link
Contributor

bors commented Jul 20, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 8482505 to master...

@bors bors merged commit 6da2ada into rust-lang:master Jul 20, 2018
@dwijnand dwijnand deleted the project_at branch July 20, 2018 17:31
@ehuss ehuss added this to the 1.29.0 milestone Feb 6, 2022
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.

test cleanup: Remove the argument from the project function
5 participants