• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

facebookincubator / TTPForge / 10495847045 / 1
64%
main: 67%

Build:
Build:
LAST BUILD BRANCH: export-D89671295
DEFAULT BRANCH: main
Ran 21 Aug 2024 07:01PM UTC
Files 57
Run time 1s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

21 Aug 2024 06:59PM UTC coverage: 63.821%. First build
10495847045.1

Pull #509

github

facebook-github-bot
Properly process powershell nested scripts as TTP steps (#509)

Summary:
Pull Request resolved: https://github.com/facebookincubator/TTPForge/pull/509

## Problem scope
Let's test with the following simple powershell script
```
% cat nested.ps
echo "start"
if ($true) {
  echo "nested"
}
echo "stop"
```

Here is results of running this script differently
```
% pwsh -File nested.ps
start
nested
stop
% pwsh nested.ps
start
nested
stop
% cat nested.ps | pwsh -File -
PS /data/users/nesusvet/fbsource/fbcode> echo "start"
start
PS /data/users/nesusvet/fbsource/fbcode> if ($true) {
>>   echo "nested"
>> }
>> echo "stop"
>> %
% cat nested.ps | pwsh -Command -
start
```

## Initial proposal
Instead of writing the TTP step body to power shell process stdin, we might rely on a new temp file to hold the body of TTP step to pass it to PowerShell as only argument.  This produces the best results.

### Limitations
Runtime environment where standard golang library call to `os.CreateTemp` fails or the file created is not writable.

## Can We Do Better?

Actually **yes** when we better understand the way PowerShell processes scripts from stdin.
It is expected to wrap your commands into `&{}` block before passing it to PowerShell's stdin.
See [documentation](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_pwsh?view=powershell-7.4#-command---c) on `-Command` param for details.

Resolves https://github.com/facebookincubator/TTPForge/issues/481

Reviewed By: CrimsonK1ng

Differential Revision: D61387125
Pull Request #509: Use temp file to process powershell nested scripts as TTP steps

1787 of 2800 relevant lines covered (63.82%)

13.66 hits per line

Source Files on job 10495847045.1
  • Tree
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 10495847045
  • 50c613a0 on github
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc