Ejemplo n.º 1
0
        public void ValidateExercises()
        {
            ReportErrorIfDockerImageSettingsIsWrong();

            if (ReportErrorIfExerciseFolderMissesRequiredFiles())
            {
                return;
            }

            ReportErrorsInRegion();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !EnvironmentVariablesUtils.ExistsOnPath("docker.exe"))
            {
                ReportWarning("Docker not found in PATH");
                return;
            }

            ReportErrorIfSolutionNotBuildingOrNotPassesTests();

            ReportErrorIfWrongAnswerExistsButNotBuildingOrPassesTests();

            if (ex.CheckInitialSolution)
            {
                ReportErrorIfInitialCodeIsSolutionOrVerdictNotOk();
            }
        }
Ejemplo n.º 2
0
        public override void DoExecute()
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Console.WriteLine("You need to run sandboxes/build.sh on non-Windows");
                return;
            }

            var dockerExistsOnPath = EnvironmentVariablesUtils.ExistsOnPath("docker.exe");

            if (!dockerExistsOnPath)
            {
                Console.WriteLine("Docker not found in PATH");
                return;
            }

            var pathToBuildBat = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(BuildDockerContainerOptions)).Location), "sandboxes/build.bat");
            var process        = new Process
            {
                StartInfo =
                {
                    Arguments = "",
                    FileName  = pathToBuildBat,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    WorkingDirectory       = Path.GetDirectoryName(pathToBuildBat)
                }
            };

            process.Start();
            process.OutputDataReceived += (sender, e) => Console.WriteLine(e.Data);
            process.BeginOutputReadLine();

            process.ErrorDataReceived += (sender, e) => Console.WriteLine(e.Data);
            process.BeginErrorReadLine();
            process.WaitForExit();
            process.Close();
        }