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

feature: adds fixtures to support multiple files from string #272

Merged
merged 1 commit into from
Sep 28, 2020

Conversation

baszalmstra
Copy link
Collaborator

Adds the ability to construct test fixtures that consist of multiple files from a single string. A fixture with multiple files looks like this:

Fixture::parse(
    r#"
    //- /foo.mun
    fn hello_world() {
    }

    //- /bar.mun
    fn baz() {
    }
"#
)

This is used by the MockDatabase to enable creating tests for multiple files.

@baszalmstra baszalmstra self-assigned this Sep 22, 2020
@baszalmstra baszalmstra added the type: feat New feature or request label Sep 22, 2020
Copy link
Collaborator

@Wodann Wodann left a comment

Choose a reason for hiding this comment

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

Other than some grammar mistakes, this looks great! 👍

crates/mun_hir/Cargo.toml Outdated Show resolved Hide resolved
const DEFAULT_FILE_NAME: &str = "main.mun";
const META_LINE: &str = "//-";

/// A `Fixtures` describes an single file in a project workspace. `Fixture`s can be parsed from a
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// A `Fixtures` describes an single file in a project workspace. `Fixture`s can be parsed from a
/// A `Fixture` describes a multiple files in a project workspace. `Fixture`s can be parsed from a

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No thats actually correct. The struct itself describes a single file in a project workspace. When calling parse a collection is returned.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The fixtures (plural class name) part or the singular file? It seems like you define multiple Mun files in your fixture, not a single one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It should be A Fixture describes a single file in a project workspace. Does that make sense?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess my understanding of what a fixture is, is wrong then. I thought that the following snippet contained one fixture, comprised of two files.

Fixture::parse(
    r#"
    //- /foo.mun
    fn hello_world() {
    }

    //- /bar.mun
    fn baz() {
    }
"#
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Parsing the given strings returns a Vec<Fixture>. One entry for foo.mun and one for bar.mun.

crates/mun_test/src/fixture.rs Outdated Show resolved Hide resolved
crates/mun_test/src/fixture.rs Outdated Show resolved Hide resolved
@baszalmstra baszalmstra force-pushed the feature/fixtures branch 2 times, most recently from 8458f98 to ab46466 Compare September 24, 2020 15:54
@codecov
Copy link

codecov bot commented Sep 24, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@575a3ba). Click here to learn what that means.
The diff coverage is 89.58%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #272   +/-   ##
=========================================
  Coverage          ?   79.10%           
=========================================
  Files             ?      219           
  Lines             ?    13024           
  Branches          ?        0           
=========================================
  Hits              ?    10303           
  Misses            ?     2721           
  Partials          ?        0           
Impacted Files Coverage Δ
crates/mun_hir/src/expr/validator/tests.rs 100.00% <ø> (ø)
crates/mun_hir/src/item_tree/tests.rs 100.00% <ø> (ø)
crates/mun_hir/src/tests.rs 84.61% <ø> (ø)
crates/mun_hir/src/ty/tests.rs 96.38% <ø> (ø)
crates/mun_hir/src/mock.rs 76.92% <75.00%> (ø)
crates/mun_hir/src/fixture.rs 81.81% <81.81%> (ø)
crates/mun_test/src/fixture.rs 92.85% <92.85%> (ø)
crates/mun_memory/src/mapping.rs 96.59% <0.00%> (ø)
crates/mun_diagnostics/src/hir/missing_fields.rs 0.00% <0.00%> (ø)
...tes/mun_language_server/src/protocol/connection.rs 29.16% <0.00%> (ø)
... and 216 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 575a3ba...ab46466. Read the comment docs.

@baszalmstra
Copy link
Collaborator Author

Can we merge this @Wodann ?

@baszalmstra baszalmstra merged commit 720bdae into mun-lang:master Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feat New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants