Skip to content

Commit 86164a3

Browse files
committed
#35: Ok making LRS argument setting editable, and copying replay result file as the comparison result file.
1 parent 38cdde7 commit 86164a3

File tree

7 files changed

+56
-22
lines changed

7 files changed

+56
-22
lines changed

Solution/LanguageServer.Robot.Monitor/App.config

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ SET LSP_EXE={2}\TypeCobol.LanguageServer.exe
6565
DEL %PATH_TEST%\Results\%TEST_NAME%.rlsp 2> nul
6666

6767
SET result=KO
68-
%LSR_EXE% -c -so "-td" -s %LSP_EXE% -script %PATH_TEST%\%TEST_NAME%.tlsp 1> nul 2> nul
68+
%LSR_EXE% -c -s %LSP_EXE% -script %PATH_TEST%\%TEST_NAME%.tlsp 1> nul 2> nul
6969
FC %PATH_TEST%\%TEST_NAME%.rlsp %PATH_TEST%\Results\%TEST_NAME%.rlsp 1> nul 2> nul
7070
if %ERRORLEVEL%==0 set result=OK
7171
echo %PATH_TEST%\%TEST_NAME%.tlsp %result%
7272
exit %ERRORLEVEL%
7373
</value>
7474
</setting>
7575
<setting name="LSRReplayArguments" serializeAs="String">
76-
<value>-c -so "-td" -s {0}\TypeCobol.LanguageServer.exe -script {1}</value>
76+
<value>-c -s {0}\TypeCobol.LanguageServer.exe -script {1}</value>
7777
</setting>
7878
<setting name="LSRExe" serializeAs="String">
7979
<value>LanguageServerRobot.exe</value>

Solution/LanguageServer.Robot.Monitor/Controller/LanguageServerRobotMonitor.cs

+32-10
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ private bool ReplayScenario(string scenario_path, Script scenario, out Result sc
736736
Exception exc = null;
737737
if (Util.ReadResultFile(resultFile, out result, out exc))
738738
{//Here Dispaly a dialog box with the result.
739-
scenarioResult = result;
739+
scenarioResult = result;
740740
if (bPromt)
741741
{
742742
JObject jobject = JObject.FromObject(result);
@@ -809,14 +809,31 @@ private void CreateTestFiles(Script scenario, String scenarioFile)
809809
Result result = null;
810810
if (ReplayScenario(scenarioFile, scenario, out result, false))
811811
{
812-
JObject jobject = JObject.FromObject(result);
813-
using (
814-
FileStream stream =
815-
System.IO.File.Create(Path.Combine(fi.DirectoryName, basename + Util.RESULT_FILE_EXTENSION )))
812+
bool bSaved = false;
813+
try
816814
{
817-
string text = jobject.ToString();
818-
byte[] bytes = Encoding.UTF8.GetBytes(text);
819-
stream.Write(bytes, 0, bytes.Length);
815+
string result_dir = null;
816+
bool bExist = Util.EnsureResultDirectoryExists(scenarioFile, out result_dir);
817+
string resultFile = System.IO.Path.Combine(result_dir, Util.GetResultFileName(scenarioFile));
818+
if (bExist)
819+
{
820+
File.Copy(resultFile, Path.Combine(fi.DirectoryName, basename + Util.RESULT_FILE_EXTENSION));
821+
bSaved = true;
822+
}
823+
}
824+
catch (Exception e)
825+
{
826+
Console.WriteLine(e);
827+
}
828+
if (!bSaved)
829+
{
830+
using (
831+
FileStream stream =
832+
System.IO.File.Create(Path.Combine(fi.DirectoryName, basename + Util.RESULT_FILE_EXTENSION))
833+
)
834+
{
835+
result.Write(stream);
836+
}
820837
}
821838
}
822839
}
@@ -1019,10 +1036,15 @@ private void RunScenarioController()
10191036
}
10201037
}
10211038

1039+
/// <summary>
1040+
/// Handler when a LSP message is receice, it can be a client or a server message.
1041+
/// This can be a base point for filtering any message, regardless the target document.
1042+
/// </summary>
1043+
/// <param name="sender"></param>
1044+
/// <param name="e"></param>
10221045
private void Consumer_LspMessageHandler(object sender, Common.Model.Message.LspMessage e)
10231046
{
1024-
//RunScenarioController();
1025-
Log.LogWriter.WriteLine(e.Message);
1047+
//Log.LogWriter.WriteLine(e.Message);
10261048
}
10271049

10281050
public bool CanExecute(object parameter)

Solution/LanguageServer.Robot.Monitor/Controller/SettingsController.cs

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ private bool ValidateView()
103103
Model.ServerPath = View.ServerPath.Text;
104104
Model.LSRPath = View.LSRPath.Text;
105105
Model.ScriptRepositoryPath = View.ScriptRepository.Text;
106+
Model.LSRReplayArguments = View.LSRReplayArguments.Text;
106107
Model.BatchTemplate = View.BatchTemplate.Text;
107108
return true;
108109
}

Solution/LanguageServer.Robot.Monitor/Model/SettingsModel.cs

+13-4
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,22 @@ public string BatchTemplate
4949
get; set;
5050
}
5151

52+
public string LSRReplayArguments
53+
{
54+
get; set;
55+
}
56+
5257
/// <summary>
5358
/// Read Default Values
5459
/// </summary>
5560
public void ReadFromDefault()
5661
{
57-
ServerPath = Properties.Resources.DefaultServerPath;
58-
LSRPath = Properties.Resources.DefaultLSRPath;
59-
ScriptRepositoryPath = Properties.Resources.DefaultScriptRepositoryPath;
60-
BatchTemplate = Properties.Resources.DefaultBatchTemplate;
62+
Properties.Settings.Default.Reset();
63+
ReadFromSettings();
64+
//ServerPath = Properties.Resources.DefaultServerPath;
65+
//LSRPath = Properties.Resources.DefaultLSRPath;
66+
//ScriptRepositoryPath = Properties.Resources.DefaultScriptRepositoryPath;
67+
//BatchTemplate = Properties.Resources.DefaultBatchTemplate;
6168
}
6269
/// <summary>
6370
/// Read the model from application setting values
@@ -67,6 +74,7 @@ public void ReadFromSettings()
6774
ServerPath = Properties.Settings.Default.ServerPath;
6875
LSRPath = Properties.Settings.Default.LSRPath;
6976
ScriptRepositoryPath = Properties.Settings.Default.ScriptPath;
77+
LSRReplayArguments = Properties.Settings.Default.LSRReplayArguments;
7078
BatchTemplate = Properties.Settings.Default.BatchTemplate;
7179
}
7280

@@ -78,6 +86,7 @@ public void WriteToSettings()
7886
Properties.Settings.Default.ServerPath = ServerPath;
7987
Properties.Settings.Default.LSRPath = LSRPath;
8088
Properties.Settings.Default.ScriptPath = ScriptRepositoryPath;
89+
Properties.Settings.Default.LSRReplayArguments = LSRReplayArguments;
8190
Properties.Settings.Default.BatchTemplate = BatchTemplate;
8291
Properties.Settings.Default.Save();
8392
}

Solution/LanguageServer.Robot.Monitor/Properties/Settings.Designer.cs

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Solution/LanguageServer.Robot.Monitor/Properties/Settings.settings

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ SET LSP_EXE={2}\TypeCobol.LanguageServer.exe
2222
DEL %PATH_TEST%\Results\%TEST_NAME%.rlsp 2&gt; nul
2323

2424
SET result=KO
25-
%LSR_EXE% -c -so "-td" -s %LSP_EXE% -script %PATH_TEST%\%TEST_NAME%.tlsp 1&gt; nul 2&gt; nul
25+
%LSR_EXE% -c -s %LSP_EXE% -script %PATH_TEST%\%TEST_NAME%.tlsp 1&gt; nul 2&gt; nul
2626
FC %PATH_TEST%\%TEST_NAME%.rlsp %PATH_TEST%\Results\%TEST_NAME%.rlsp 1&gt; nul 2&gt; nul
2727
if %ERRORLEVEL%==0 set result=OK
2828
echo %PATH_TEST%\%TEST_NAME%.tlsp %result%
2929
exit %ERRORLEVEL%
3030
</Value>
3131
</Setting>
3232
<Setting Name="LSRReplayArguments" Type="System.String" Scope="User">
33-
<Value Profile="(Default)">-c -so "-td" -s {0}\TypeCobol.LanguageServer.exe -script {1}</Value>
33+
<Value Profile="(Default)">-c -s {0}\TypeCobol.LanguageServer.exe -script {1}</Value>
3434
</Setting>
3535
<Setting Name="LSRExe" Type="System.String" Scope="User">
3636
<Value Profile="(Default)">LanguageServerRobot.exe</Value>

Solution/LanguageServer.Robot.Monitor/View/SettingsView.xaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
<Label Grid.Column="0" Content="Script Repository path:" HorizontalAlignment="Left" Margin="0,60,0,0" VerticalAlignment="Top" Height="26" Width="130"/>
2424
<TextBox Grid.Column="1" Name="ScriptRepository" HorizontalAlignment="Stretch" Height="23" Margin="1,63,0,0" TextWrapping="Wrap" Text="{Binding ScriptRepositoryPath, Mode=TwoWay}" VerticalAlignment="Top" Width="Auto"/>
2525
<Button Name="BrowseScriptPath" Content="..." Grid.Column="2" HorizontalAlignment="Stretch" Margin="0,63,-7,0" VerticalAlignment="Top" Width="Auto" Height="23" Click="BrowseScriptPath_OnClick"/>
26-
<Label Grid.Column="0" Content="Batch Template:" HorizontalAlignment="Left" Margin="0,100,0,0" VerticalAlignment="Top" Height="26" Width="95"/>
27-
<TextBlock Grid.Column="1" Name="BatchTemplate" HorizontalAlignment="Stretch" Margin="0,105,0,0" TextWrapping="Wrap" Text="{Binding BatchTemplate, Mode=TwoWay}" VerticalAlignment="Top" Height="285" Width="Auto"/>
26+
<Label Grid.Column="0" Content="LSR Replay arguments:" HorizontalAlignment="Left" Margin="1,95,0,0" VerticalAlignment="Top" Height="26" Width="130"/>
27+
<TextBox Grid.Column="1" Name="LSRReplayArguments" HorizontalAlignment="Stretch" Height="23" Margin="1,96,0,0" TextWrapping="Wrap" Text="{Binding LSRReplayArguments, Mode=TwoWay}" VerticalAlignment="Top" Width="Auto"/>
28+
<Label Grid.Column="0" Content="Batch Template:" HorizontalAlignment="Left" Margin="0,127,0,0" VerticalAlignment="Top" Height="26" Width="95"/>
29+
<TextBox Grid.Column="1" Name="BatchTemplate" HorizontalAlignment="Stretch" Margin="0,136,0,0" TextWrapping="Wrap" Text="{Binding BatchTemplate, Mode=TwoWay}" VerticalAlignment="Top" Height="254" Width="Auto"/>
2830
</Grid>
2931
</UserControl>

0 commit comments

Comments
 (0)