Skip to content

Commit 4610ea3

Browse files
Konstantin VlasenkoKonstantin Vlasenko
authored andcommitted
Merge pull request #75 from SergeyZalyadeev/master
several fixes
2 parents 427f02e + 438c372 commit 4610ea3

File tree

9 files changed

+85
-16
lines changed

9 files changed

+85
-16
lines changed

FitNesseRoot/PowerSlim/OriginalMode/SuiteCommon/TestPreformated/content.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
!|scenario|Execute block|!- block -! |result|!- result -!|
1+
!|scenario|Execute block| block |result| result |
22
|check |eval |!- &@block -!|@result |
33

44
!|script|
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-!|script|
2+
|eval|!-function Get-NewString($val){ return "$val no quotes" }-!|
3+
4+
5+
-!|script |
6+
|show|eval|$obj= new-object PsObject -Property @{A=42;B="string value";C=(Get-NewString "it is")}|
7+
#|check|eval|$obj.C|it is no quotes|
8+
9+
!|script|
10+
|show|eval|!-$extended = $obj | select *, @{Name='A1';Expression={$_.A*2}}, @{Name='B1';Expression={$_.B+" extended"}}-!|
11+
#|check|eval|$extended.A1|84|
12+
#|check|eval|$extended.B1|string value extended|
13+
14+
-!|script |
15+
|show|eval|!-$obj | add-member NoteProperty -Name NewProperty -Value (Get-NewString $obj.B) -!|
16+
#|check|eval|$obj.NewProperty|string value no quotes|
17+
18+
!|query:Local|$obj |
19+
|A |B |NewProperty |C|
20+
|42 |string value|string value no quotes|it is no quotes|
21+
22+
!|query:Local|$extended |
23+
|A |B |A1|B1 |
24+
|42 |string value|84|string value extended|
25+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<properties>
3+
<Edit>true</Edit>
4+
<Files>true</Files>
5+
<Properties>true</Properties>
6+
<RecentChanges>true</RecentChanges>
7+
<Refactor>true</Refactor>
8+
<Search>true</Search>
9+
<Test>true</Test>
10+
<Versions>true</Versions>
11+
<WhereUsed>true</WhereUsed>
12+
</properties>

FitNesseRoot/PowerSlim/OriginalMode/SuiteCommon/TestQueryTable/content.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
!|Query:Local|get-host|
22
|Name |Version |
3-
|ConsoleHost |${HOST_VERSION}|
3+
|ConsoleHost |=~/${HOST_VERSION}/|
44
!* Empty dictionary
55
!|script|
66
|eval|$list= New-Object "system.collections.generic.dictionary[string,object]";|
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
!define TEST_SYSTEM {slim}
22
!define COMMAND_PATTERN (PowerShell -NonInteractive -ExecutionPolicy unrestricted -file .\slim.ps1)
3-
!define HOST_VERSION (4.0)
3+
!define HOST_VERSION (3.0|4.0)
44
!contents -R2 -g -p -f -h
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
!4 !-[PowerShell -Version 2] can start PowerShell 3.0 if powershell.exe.config file contains v4.0 runtime support -!
2+
3+
!|query:Local |!-[PsObject].Assembly | select ManifestModule,ImageRuntimeVersion,Location -!|
4+
|ManifestModule |ImageRuntimeVersion|Location |
5+
|System.Management.Automation.dll|=~/v2.0.\d+/ |=~/.*System.Management.Automation.1.0.0.0.*/|
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<properties>
3+
<Edit>true</Edit>
4+
<Files>true</Files>
5+
<Properties>true</Properties>
6+
<RecentChanges>true</RecentChanges>
7+
<Refactor>true</Refactor>
8+
<Search>true</Search>
9+
<Versions>true</Versions>
10+
<WhereUsed>true</WhereUsed>
11+
</properties>

FitNesseRoot/PowerSlim/PowerShell20Mode/properties.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
<Search/>
99
<Suite/>
1010
<SymbolicLinks>
11+
<SuiteNoHangup>.PowerSlim.OriginalMode.SuiteNoHangup</SuiteNoHangup>
12+
<SuiteFixes>.PowerSlim.OriginalMode.SuiteFixes</SuiteFixes>
1113
<SuiteRemoting>.PowerSlim.OriginalMode.SuiteRemoting</SuiteRemoting>
12-
<SuiteCommon>.PowerSlim.OriginalMode.SuiteCommon</SuiteCommon>
1314
<SuiteSymbols>.PowerSlim.OriginalMode.SuiteSymbols</SuiteSymbols>
15+
<SuiteCommon>.PowerSlim.OriginalMode.SuiteCommon</SuiteCommon>
1416
<SuiteExceptions>.PowerSlim.OriginalMode.SuiteExceptions</SuiteExceptions>
15-
<SuiteFixes>.PowerSlim.OriginalMode.SuiteFixes</SuiteFixes>
16-
<SuiteNoHangup>.PowerSlim.OriginalMode.SuiteNoHangup</SuiteNoHangup>
1717
</SymbolicLinks>
1818
<Versions/>
1919
<WhereUsed/>

slim.ps1

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
######################
22
# PowerSlim 20150617 #
33
######################
4+
[CmdletBinding()]
5+
Param(
6+
[Parameter(Mandatory=$True,Position=0)]
7+
[int]$Port,
8+
9+
[Parameter(Mandatory=$False, Position=1)]
10+
[string]$Mode="runner"
11+
)
12+
413
$slimver = "Slim -- V0.3`n"
514
$slimnull = "000004:null:"
615
#$slimvoid = "/__VOID__/"
@@ -144,6 +153,9 @@ function PropertyTo-Slim($ps_obj,$ps_prop){
144153
if($($ps_obj.$ps_prop) -eq $null){
145154
$slimview += $slimnull + "]"
146155
}
156+
elseif( $($ps_obj.$ps_prop) -is [string]){
157+
$slimview += (slimlen $($ps_obj.$ps_prop)) + ":" + $($ps_obj.$ps_prop) + ":]"
158+
}
147159
elseif($($ps_obj.$ps_prop) -is [system.array] -or $($ps_obj.$ps_prop) -is [psobject]){
148160
if ($Host.Version.Major -ge 3) { $slimview += (ConvertTo-Json -Compress $($ps_obj.$ps_prop)) |% {(slimlen $_) + ":" + $_.ToString() + ":]"} }
149161
else { $slimview += ConvertTo-JSON20 ($ps_obj.$ps_prop) |% {(slimlen $_) + ":" + $_.ToString() + ":]"} }
@@ -271,7 +283,7 @@ function Print-Error {
271283
}
272284

273285
function Invoke-SlimCall($fnc){
274-
if($fnc -in 'eval','query','get','post','patch','put'){
286+
if('eval','query','get','post','patch','put' -contains $fnc){
275287
$result = Exec-Script -Script $Script__
276288
}
277289
else {
@@ -423,7 +435,7 @@ function Invoke-SlimInstruction(){
423435
}
424436

425437
if($ins[3] -ne "query" -and $ins[3] -ne "table"){
426-
if($ins[3] -in 'get','post','patch','put'){
438+
if('get','post','patch','put' -contains $ins[3]){
427439
Set-RestScript $ins[3] $ins[4]
428440
}
429441
else{
@@ -453,7 +465,7 @@ function Invoke-SlimInstruction(){
453465
}
454466
}
455467
"eval" { $result = ResultTo-String $result }
456-
{$_ -in 'get','post','patch','put'}{ Set-Variable -Name $_ -Value ($result) -Scope Global; $result = ResultTo-List @($result) }
468+
{$_ -match '^(get|post|patch|put)$'}{ Set-Variable -Name $_ -Value ($result) -Scope Global; $result = ResultTo-List @($result) }
457469
}
458470
if ($result -is [String]) {
459471
$result.TrimEnd("`r`n")
@@ -615,18 +627,22 @@ function Run-RemoteServer($ps_server){
615627
}
616628
}
617629

618-
if (!$args.Length) {
619-
Write-Output "No arguments provided!"
620-
return;
621-
}
630+
# if (!$args.Length) {
631+
# Write-Output "No arguments provided!"
632+
# return;
633+
# }
622634

623-
$ps_server = New-Object System.Net.Sockets.TcpListener($args[0])
635+
"Starting SLIM $Mode on Port $Port" |Out-Default
636+
637+
$ps_server = New-Object System.Net.Sockets.TcpListener($Port)
624638
$ps_server.Start()
625639

626-
if(!$args[1]){
640+
if($Mode -eq "runner"){
627641
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
628642
. $scriptPath\client.ps1
629643
Run-SlimServer $ps_server
630644
}
631-
else{ Run-RemoteServer $ps_server }
645+
else{
646+
Run-RemoteServer $ps_server
647+
}
632648
$ps_server.Stop()

0 commit comments

Comments
 (0)