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

Support custom path of a test file #1609

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

josefpihrt
Copy link
Collaborator

No description provided.

@josefpihrt josefpihrt self-assigned this Jan 19, 2025

Document additionalDocument = project.AddDocument(
documentName,
SourceText.From(additionalFiles[i].Source),
filePath: Path.Combine(directoryPath, documentName));
filePath: Path.Combine(directoryPath, additionalFiles[i].Path ?? documentName));
Copy link

Choose a reason for hiding this comment

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

I'd suggest

Suggested change
filePath: Path.Combine(directoryPath, additionalFiles[i].Path ?? documentName));
filePath: Path.Combine(directoryPath, Path.GetDirectoryName(additionalFiles[i].Path ?? documentName), documentName));

that should properly process passed paths without file name, like Foo/Bar/ or something like this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added validation of file path

@@ -362,12 +362,12 @@ internal static (Document document, ImmutableArray<ExpectedDocument> expectedDoc

for (int i = 0; i < additionalFiles.Length; i++)
{
string documentName = AppendNumberToFileName(options.DocumentName, i + 2);
string documentName = Path.GetFileName(additionalFiles[i].Path) ?? AppendNumberToFileName(options.DocumentName, i + 2);
Copy link

Choose a reason for hiding this comment

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

in case I am providing only a path, it could work erroneously. I do not know how it would behave for cases Foo/Bar and Foo/Bar/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added validation of file path

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