示例#1
0
        private void InitializeScriptObjects()
        {
            AffeCompiler compiler = new AffeCompiler(typeof(ScriptHost));

            ScriptingEnvironment.InstallBase(compiler);
            ScriptingEnvironment.InstallMath(compiler);

            this.mScriptHost = new ScriptHost();

            this.mInitScript.Compiler     = compiler;
            this.mInitScript.TargetObject = this.mScriptHost;

            this.mFrameScript.Compiler     = compiler;
            this.mFrameScript.TargetObject = this.mScriptHost;

            this.mBeatScript.Compiler     = compiler;
            this.mBeatScript.TargetObject = this.mScriptHost;

            this.mVertexScript.Compiler     = compiler;
            this.mVertexScript.TargetObject = this.mScriptHost;

            this.mNeedInit    = true;
            this.mStaticDirty = true;

            this.mInitScript.MadeDirty   += this.OnInitMadeDirty;
            this.mFrameScript.MadeDirty  += this.OnOtherMadeDirty;
            this.mVertexScript.MadeDirty += this.OnOtherMadeDirty;

            this.CreatePointDataArray();
        }
 public void BeforeTest(ITest testDetails)
 {
     if (ScriptingEnvironment.IsRunningOnMono() && (Environment.GetEnvironmentVariable("TEAMCITY_BUILDCONF_NAME")?.Contains("FreeBSD") ?? false))
     {
         Assert.Ignore($"This test does not run on FreeBSD");
     }
 }
示例#3
0
        public override void Start()
        {
            Logger.Info("Initialising scripting environment...");

            ScriptingEnvironment.Init();

            Logger.Info("Initialising game world... ");

            _serverId = GetValueOrDefault("GameServerId", 1).Value <int>();

            var dbServerAddress = GetValueOrDefault("DatabaseServerAddress", "127.0.0.1");
            var dbServerPort    = GetValueOrDefault("DatabaseServerPort", 30820);

            // The client instance
            _dbClient = new OriginClient(IPAddress.Parse(dbServerAddress.Value <string>()), dbServerPort.Value <int>());

            // Connect to the db server
            if (!_dbClient.Connect())
            {
                Logger.Error("Failed to connect to database server!");
                return;
            }

            Logger.Info("Successfully connected to the database server!");

            _pulseHandler = new GamePulseHandler();

            _pulseHandler.Start();

            var socketServer = new SocketServer();

            var serverPort = GetValueOrDefault("GameServerPort", 30810);

            socketServer.Initialise(serverPort.Value <int>());
        }
示例#4
0
        public static string FindExecutable()
        {
            if (!ScriptingEnvironment.IsNet45OrNewer())
            {
                throw new CommandException("FSharp scripts require requires .NET framework 4.5");
            }

            var myPath = typeof(FSharpEngine).Assembly.Location;
            var parent = Path.GetDirectoryName(myPath);

            var attemptOne = Path.GetFullPath(Path.Combine(parent, "FSharp", "fsi.exe"));

            if (File.Exists(attemptOne))
            {
                return(attemptOne);
            }

            var attemptTwo = Path.GetFullPath(Path.Combine("..", "..", "packages", "FSharp.Compiler.Tools.4.0.0.1", "tools", "fsi.exe"));

            if (File.Exists(attemptTwo))
            {
                return(attemptTwo);
            }

            throw new CommandException(string.Format("fsi.exe was not found at either '{0}' or '{1}'", attemptOne, attemptTwo));
        }
示例#5
0
 public void BeforeTest(ITest testDetails)
 {
     if (ScriptingEnvironment.IsRunningOnMono() && (ScriptingEnvironment.GetMonoVersion() < new Version(major, minor, build)))
     {
         Assert.Ignore($"Requires Mono {major}.{minor}.{build} or above");
     }
 }
示例#6
0
 private void tabCode_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (tabCode.SelectedTab == tabPageInterpretor)
     {
         try
         {
             env = new ScriptingEnvironment(textCode.Text, new ScriptingEnvironment());
             textLaunch.Select();
         }
         catch (ScriptingException ex)
         {
             if (ex.Start != -1)
             {
                 textCode.Select(ex.Start, ex.Length);
                 textCode.ScrollToCaret();
             }
             tabCode.SelectedTab = tabPageEditor;
             textCode.Select();
             callback.ShowError(ex.Message);
         }
         catch (Exception ex)
         {
             callback.ShowError(ex.Message);
             tabCode.SelectedTab = tabPageEditor;
         }
     }
 }
 public void BeforeTest(ITest testDetails)
 {
     if (!ScriptingEnvironment.IsNet45OrNewer())
     {
         Assert.Ignore("Requires .NET 4.5");
     }
 }
示例#8
0
 public void BeforeTest(ITest testDetails)
 {
     if (!ScriptingEnvironment.IsNetFramework())
     {
         Assert.Ignore("Requires .NET Framework");
     }
 }
示例#9
0
 public void BeforeTest(TestDetails testDetails)
 {
     if (ScriptingEnvironment.IsRunningOnMono() && (ScriptingEnvironment.GetMonoVersion() < new Version(4, 0, 0)))
     {
         Assert.Ignore("Requires Mono 4");
     }
 }
示例#10
0
 public void ApplyToTest(Test test)
 {
     if (ScriptingEnvironment.IsRunningOnMono() && (Environment.GetEnvironmentVariable("TEAMCITY_BUILDCONF_NAME")?.Contains("FreeBSD") ?? false))
     {
         test.RunState = RunState.Skipped;
         test.Properties.Set(PropertyNames.SkipReason, "This test does not run on FreeBSD");
     }
 }
示例#11
0
        private ScriptingEnvironment Parse(string code)
        {
            ScriptingEnvironment environment = new ScriptingEnvironment(code, new ScriptingEnvironment());

            environment.DefineValue("add", ScriptingValue.CreateFunction(Add, 2));
            environment.DefineValue("sub", ScriptingValue.CreateFunction(Sub, 2));
            return(environment);
        }
示例#12
0
 public void ApplyToTest(Test test)
 {
     if (ScriptingEnvironment.SafelyGetPowerShellVersion().Major < 5)
     {
         test.RunState = RunState.Skipped;
         test.Properties.Set(PropertyNames.SkipReason, "This test requires PowerShell 5 or newer.");
     }
 }
 public void ApplyToTest(Test test)
 {
     if (!ScriptingEnvironment.IsNetFramework())
     {
         test.RunState = RunState.Skipped;
         test.Properties.Set(PropertyNames.SkipReason, "Requires dotnet Framework");
     }
 }
示例#14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Void call() throws Exception
                public Void call()
                {
                    ScriptingEngines scriptingEngines = outerInstance.outerInstance.processEngineConfiguration.ScriptingEngines;
                    ScriptEngine     scriptEngine     = scriptingEngines.getScriptEngineForLanguage(SCRIPT_LANGUAGE);

                    SourceExecutableScript script = outerInstance.outerInstance.createScript(SCRIPT_LANGUAGE, SCRIPT);

                    ScriptingEnvironment scriptingEnvironment = outerInstance.outerInstance.processEngineConfiguration.ScriptingEnvironment;

                    scriptingEnvironment.execute(script, null, null, scriptEngine);

                    return(null);
                }
        public void ApplyToTest(Test test)
        {
            if (ScriptingEnvironment.IsRunningOnMono() && (Environment.GetEnvironmentVariable("TEAMCITY_BUILDCONF_NAME")?.Contains("FreeBSD") ?? false))
            {
                var skipReason = "This test does not run on FreeBSD";
                if (!string.IsNullOrWhiteSpace(reason))
                {
                    skipReason += $" because {reason}";
                }

                test.RunState = RunState.Skipped;
                test.Properties.Set(PropertyNames.SkipReason, skipReason);
            }
        }
示例#16
0
        [RequiresMonoVersion423OrAbove] //Bug in mono < 4.2.3 https://bugzilla.xamarin.com/show_bug.cgi?id=19426
        public void ShouldInvokeDeployFailedOnError()
        {
            Variables.Set("ShouldFail", "yes");
            var result = DeployPackage();

            if (ScriptingEnvironment.IsRunningOnMono())
            {
                result.AssertOutput("I have failed! DeployFailed.sh");
            }
            else
            {
                result.AssertOutput("I have failed! DeployFailed.ps1");
            }
            result.AssertOutput("I have failed! DeployFailed.fsx");
            result.AssertOutput("I have failed! DeployFailed.csx");
        }
示例#17
0
        public static string FindExecutable()
        {
            if (!ScriptingEnvironment.IsNet45OrNewer())
            {
                throw new CommandException("ScriptCS scripts require the Roslyn CTP, which requires .NET framework 4.5");
            }

            var myPath     = typeof(ScriptCSScriptEngine).Assembly.Location;
            var parent     = Path.GetDirectoryName(myPath);
            var executable = Path.GetFullPath(Path.Combine(parent, "ScriptCS", "scriptcs.exe"));

            if (File.Exists(executable))
            {
                return(executable);
            }

            throw new CommandException(string.Format("ScriptCS.exe was not found at '{0}'", executable));
        }
示例#18
0
        public static string FindExecutable()
        {
            if (!ScriptingEnvironment.IsNet45OrNewer())
            {
                throw new CommandException("FSharp scripts require requires .NET framework 4.5");
            }

            var myPath     = typeof(FSharpExecutor).Assembly.Location;
            var parent     = Path.GetDirectoryName(myPath);
            var executable = Path.GetFullPath(Path.Combine(parent, "FSharp", "fsi.exe"));

            if (File.Exists(executable))
            {
                return(executable);
            }

            throw new CommandException(string.Format("fsi.exe was not found at '{0}'", executable));
        }
示例#19
0
        static string GetPsDebugCommand(IVariables variables)
        {
            //https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/set-psdebug?view=powershell-6
            var traceArg     = variables[PowerShellVariables.PSDebug.Trace];
            var traceCommand = "-Trace 0";

            int.TryParse(traceArg, out var traceArgAsInt);
            bool.TryParse(traceArg, out var traceArgAsBool);
            if (traceArgAsInt > 0 || traceArgAsBool)
            {
                var powerShellVersion = ScriptingEnvironment.SafelyGetPowerShellVersion();

                if (powerShellVersion.Major < 5 && powerShellVersion.Major > 0)
                {
                    Log.Warn($"{PowerShellVariables.PSDebug.Trace} is enabled, but PowerShell tracing is only supported with PowerShell versions 5 and above. This server is currently running PowerShell version {powerShellVersion}.");
                }
                else
                {
                    Log.Warn($"{PowerShellVariables.PSDebug.Trace} is enabled. This should only be used for debugging, and then disabled again for normal deployments.");
                    if (traceArgAsInt > 0)
                    {
                        traceCommand = $"-Trace {traceArgAsInt}";
                    }
                    if (traceArgAsBool)
                    {
                        traceCommand = $"-Trace 2";
                    }
                }
            }

            var strictArg     = variables[PowerShellVariables.PSDebug.Strict];
            var strictCommand = "";

            if (bool.TryParse(strictArg, out var strictArgAsBool) && strictArgAsBool)
            {
                Log.Info($"{PowerShellVariables.PSDebug.Strict} is enabled, putting PowerShell into strict mode where variables must be assigned a value before being referenced in a script. If a variable is referenced before a value is assigned, an exception will be thrown. This feature is experimental.");
                strictCommand = " -Strict";
            }

            return($"Set-PSDebug {traceCommand}{strictCommand};");
        }
示例#20
0
        public void PowerShell4DoesntSupport(string variableValue)
        {
            //this may cause an `Inconclusive: Outcome value 0 is not understood` error in Rider
            //known bug - https://youtrack.jetbrains.com/issue/RSRP-465549
            if (ScriptingEnvironment.SafelyGetPowerShellVersion().Major != 4)
            {
                Assert.Inconclusive("This test requires PowerShell 4");
            }

            using (var scriptFile = new TemporaryFile(Path.ChangeExtension(Path.GetTempFileName(), "ps1")))
            {
                File.WriteAllText(scriptFile.FilePath, "Write-Host $mysecrect");
                var calamariVariableDictionary = GetVariables();
                calamariVariableDictionary.Set("Octopus.Action.PowerShell.PSDebug.Trace", variableValue);

                var result = ExecuteScript(new PowerShellScriptExecutor(), scriptFile.FilePath, calamariVariableDictionary);

                result.AssertOutput("KingKong");
                result.AssertOutput("Octopus.Action.PowerShell.PSDebug.Trace is enabled, but PowerShell tracing is only supported with PowerShell versions 5 and above. This server is currently running PowerShell version 4.0.");
            }
        }
示例#21
0
        protected internal virtual object ExecuteScript(ExecutableScript script)
        {
            ScriptingEnvironment scriptingEnvironment = processEngineConfiguration.ScriptingEnvironment;

            return(processEngineConfiguration.CommandExecutorTxRequired.Execute(new CommandAnonymousInnerClass(this, script, scriptingEnvironment)));
        }
示例#22
0
 public CommandAnonymousInnerClass(ScriptCompilationTest outerInstance, ExecutableScript script, ScriptingEnvironment scriptingEnvironment)
 {
     this.outerInstance        = outerInstance;
     this.script               = script;
     this.scriptingEnvironment = scriptingEnvironment;
 }