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

Make hexidecimal named scripts execute without requiring .\ prefix #18349

Closed
wants to merge 17 commits into from

Conversation

GigaScratch
Copy link
Contributor

@GigaScratch GigaScratch commented Oct 22, 2022

PR Summary

In #15543 it was discovered that if you have a case where a script is named in a way that can be interpreted as hexadecimal (such as 0x.ps1 and you execute it without the dot backslash convention (.\0x.ps1 the script will always return null.
@vexx32 identified the problem as being an oversight in an if statement that doesn't account for a number appended a few lines above.

PR Context

This aims to solve #15543.

PR Checklist

Copy link
Collaborator

@vexx32 vexx32 left a comment

Choose a reason for hiding this comment

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

Fix seems good to me, thanks for fixing this up!! 💖 😊

Test needs a quick once over but other than that this is all good.

test/powershell/Language/Parser/Parser.Tests.ps1 Outdated Show resolved Hide resolved
@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Oct 22, 2022
@GigaScratch
Copy link
Contributor Author

The change is cuausing some unexpected behavior - https://dev.azure.com/powershell/PowerShell/_build/results?buildId=111934&view=ms.vss-test-web.build-test-results-tab&runId=1961790&resultId=108814&paneView=debug

I'm not sure how this can be related at all to the changes I made.

@iSazonov
Copy link
Collaborator

I'm not sure how this can be related at all to the changes I made.

I hope @vexx32 and @SeeminglyScience could help.

@vexx32
Copy link
Collaborator

vexx32 commented Oct 22, 2022

🤔 Not seeing anything in those tests that feels really relevant here, unsure what's going on there.

@GigaScratch
Copy link
Contributor Author

In conclusion:
On Windows the following tests fail:

On Linux and MacOS, both of the new test cases fail for this reason:
The term '0x.ps1' is not recognized as a name of a cmdlet, function, script file, or executable program. / CommandNotFoundException

@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Oct 24, 2022
@GigaScratch
Copy link
Contributor Author

@vexx32 @iSazonov I'm unable to get the tests to work after multiple attempts and speaking with people in the Powershell Discord.
Alll pipeline tests pass when I exclude edits to the Parser.Tests.ps1 file, so I am sure that the issue isn't the changes we made, but the test cases I created.
Is there any protocol for excluding tests when they prove to be too cumbersome to reasonably implement? If so I strongly believe that it's the best option.

@iSazonov
Copy link
Collaborator

iSazonov commented Oct 26, 2022

Eh, any change in Parser is very sensitive and nobody sign the change until we get clear understanding why the tests fail.

Alll pipeline tests pass when I exclude edits to the Parser.Tests.ps1 file, so I am sure that the issue isn't the changes we made, but the test cases I created.

I suggest to pull new draft test PR with only the new your tests and without the code change and see CI results.
Expectation is all tests pass except new.

@GigaScratch
Copy link
Contributor Author

I suggest to pull new draft test PR with only the new your tests and without the code change and see CI results.
Expectation is all tests pass except new.

Please see failures here: #18398

@iSazonov iSazonov mentioned this pull request Oct 27, 2022
22 tasks
@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Oct 30, 2022
@GigaScratch
Copy link
Contributor Author

Not waiting on author. Waiting on experienced pester user input on broken tests.

@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Nov 5, 2022
@iSazonov
Copy link
Collaborator

iSazonov commented Nov 5, 2022

Ready to review?

@GigaScratch GigaScratch marked this pull request as ready for review November 6, 2022 04:06
@GigaScratch GigaScratch requested review from vexx32 and SteveL-MSFT and removed request for daxian-dbw and vexx32 November 6, 2022 04:06
@GigaScratch
Copy link
Contributor Author

Ready to review?

Yes!

@ghost ghost added the Review - Needed The PR is being reviewed label Nov 13, 2022
@ghost
Copy link

ghost commented Nov 13, 2022

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@daxian-dbw daxian-dbw added the WG-Engine core PowerShell engine, interpreter, and runtime label May 1, 2023
@StevenBucher98 StevenBucher98 added the PowerShell-Docs not needed The PR was reviewed and doesn't appear to require a PowerShell Docs update label May 15, 2023
@SteveL-MSFT SteveL-MSFT added the CommunityDay-Small A small PR that the PS team has identified to prioritize to review label May 15, 2023
Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

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

One suggestion that I committed, otherwise LGTM

test/powershell/Language/Parser/Parser.Tests.ps1 Outdated Show resolved Hide resolved
@iSazonov
Copy link
Collaborator

/rebase

@ghost ghost removed the Review - Needed The PR is being reviewed label May 16, 2023
@pull-request-quantifier-deprecated

This PR has 22 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Extra Small
Size       : +20 -2
Percentile : 8.8%

Total files changed: 2

Change summary by file extension:
.cs : +3 -1
.ps1 : +17 -1

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detected.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

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

0x0.ps1 doesn't work with the PR build. Do we expect this should be fixed in the PR too?

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label May 16, 2023
@ghost ghost added the Stale label May 31, 2023
@ghost
Copy link

ghost commented May 31, 2023

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment.

@ghost ghost closed this Jun 10, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CommunityDay-Small A small PR that the PS team has identified to prioritize to review Extra Small PowerShell-Docs not needed The PR was reviewed and doesn't appear to require a PowerShell Docs update Stale Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept WG-Engine core PowerShell engine, interpreter, and runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants