Esempio n. 1
0
        public static void Run(AbsoluteDirectoryPath root, FuseRunner fuseRunner)
        {
            var projectDir = root / "GeneratedTestData" / "SystemTest1";
            var project    = projectDir / new FileName("SystemTest1.unoproj");
            var mainView   = projectDir / new FileName("MainView.ux");
            var dataDir    = projectDir / "build" / "Local" / "Designer" / "fs_data";
            var timeout    = TimeSpan.FromMinutes(3);

            Console.WriteLine("Setting up project");
            IOHelpers.DeleteAndCopyDirectory(root / "Projects" / "SystemTest1", projectDir);

            try
            {
                Console.WriteLine("Starting preview");
                fuseRunner.Preview(project, Optional.None());
                IOHelpers.WaitForFileToExist(dataDir / new FileName("output1"), timeout);
                Console.WriteLine("Replacing text");
                IOHelpers.ReplaceTextInFile(mainView, "output1", "output2");
                IOHelpers.WaitForFileToExist(dataDir / new FileName("output2"), timeout);
            }
            catch (Exception e)
            {
                throw new TestFailure(e.Message);
            }
            finally
            {
                ScreenCapture.Shoot("PreviewTestBeforeKill.png");
                fuseRunner.KillOrThrow();
            }
        }
Esempio n. 2
0
        public static void Run(AbsoluteDirectoryPath root, FuseRunner fuseRunner)
        {
            var exitCode = fuseRunner.Run("install -s android", Optional.None())
                           .WaitOrThrow(TimeSpan.FromMinutes(1))
                           .ExitCode;
            const int isInstalled     = 0;
            const int isNotInstalled  = 100;
            const int updateAvailable = 200;

            if (exitCode != isInstalled && exitCode != isNotInstalled && exitCode != updateAvailable)
            {
                throw new TestFailure("Unexpected exit code " + exitCode);
            }
        }
Esempio n. 3
0
 private static TestResult Run(Test t, AbsoluteDirectoryPath root, FuseRunner fuseRunner)
 {
     try
     {
         t.Run(root, fuseRunner);
         Console.WriteLine(t.Name + " Passed");
         return(new TestResult(t, Result.Passed));
     }
     catch (Exception e)
     {
         Console.Error.WriteLine(e.Message);
         Console.WriteLine(t.Name + " Failed");
         return(new TestResult(t, Result.Failed));
     }
 }
Esempio n. 4
0
        public static void Run(AbsoluteDirectoryPath root, FuseRunner fuseRunner)
        {
            var projectDir = root / "GeneratedTestData" / "AutomaticTestApp" / "App";
            var project    = projectDir / new FileName("App.unoproj");
            var timeout    = TimeSpan.FromMinutes(3);

            Console.WriteLine("Setting up project");
            IOHelpers.DeleteAndCopyDirectory(root / "Stuff" / "AutomatictestApp" / "App", projectDir);

            var testAppError = false;

            try
            {
                var wait = new ManualResetEvent(false);

                Console.WriteLine("Starting preview");
                fuseRunner.Preview(project, Optional.Some <Action <string> >(
                                       s =>
                {
                    if (s.Contains("TEST_APP_MSG:OK"))
                    {
                        wait.Set();
                    }
                    if (s.Contains("TEST_APP_MSG:ERROR"))
                    {
                        testAppError = true;
                        wait.Set();
                    }
                }));
                if (!wait.WaitOne(timeout))
                {
                    throw new TestFailure("Test timed out after " + timeout);
                }
                if (testAppError)
                {
                    throw new TestFailure("Test app failed");
                }
            }
            catch (Exception e)
            {
                throw new TestFailure(e.Message);
            }
            finally
            {
                ScreenCapture.Shoot("AutomaticTestApp-before-kill.png");
                fuseRunner.KillOrThrow();
            }
        }
Esempio n. 5
0
        public static void Run(AbsoluteDirectoryPath root, FuseRunner fuseRunner)
        {
            var shell   = new Shell();
            var testDir = root / "GeneratedTestData" / "FuseCreate";
            var appDir  = testDir / "appname";

            shell.DeleteIfExistsAndCreateDirectory(testDir);
            using (TestHelpers.ChangeWorkingDirectory(testDir))
            {
                fuseRunner.Run("create app appname", Optional.None())
                .WaitOrThrow(TimeSpan.FromSeconds(10))
                .AssertExitCode(0);
                IOHelpers.AssertExists(shell, appDir / new FileName("MainView.ux"));
                IOHelpers.AssertExists(shell, appDir / new FileName("appname.unoproj"));
            }
        }
Esempio n. 6
0
        public static void Run(AbsoluteDirectoryPath root, FuseRunner fuseRunner)
        {
            var shell      = new Shell();
            var projectDir = root / "GeneratedTestData" / "FuseBuild";
            var project    = projectDir / new FileName("SystemTest1.unoproj");

            Console.WriteLine("Setting up project");
            IOHelpers.DeleteAndCopyDirectory(root / "Projects" / "SystemTest1", projectDir);


            Console.WriteLine("Starting build");
            fuseRunner.Run("build " + project.NativePath, Optional.None())
            .WaitOrThrow(TimeSpan.FromMinutes(3))
            .AssertExitCode(0);
            IOHelpers.AssertExists(shell, projectDir / "build");
        }
Esempio n. 7
0
        public static void Run(AbsoluteDirectoryPath root, FuseRunner fuseRunner)
        {
            var shell      = new Shell();
            var projectDir = root / "GeneratedTestData" / "FuseImport";

            Console.WriteLine("Setting up project");
            IOHelpers.DeleteAndCopyDirectory(root / "Projects" / "SketchImportApp", projectDir);

            Console.WriteLine("Starting import");
            using (TestHelpers.ChangeWorkingDirectory(projectDir))
            {
                fuseRunner.Run("import Foo.sketch", Optional.None())
                .WaitOrThrow(TimeSpan.FromMinutes(1))
                .AssertExitCode(0);
                IOHelpers.AssertExists(shell, projectDir / "SketchSymbols" / new FileName("Sketch.Fuse.ux"));
            }
        }
Esempio n. 8
0
        public static int Main(string[] args)
        {
            var tests = new List <Test>
            {
                new Test("preview", PreviewTest.Run),
                new Test("auto-test-app", AutomaticTestApp.Run),
                new Test("create", FuseCreate.Run),
                new Test("build", FuseBuild.Run),
                new Test("install-android", FuseInstallAndroid.Run),
            };

            if (Platform.OperatingSystem == OS.Mac)
            {
                tests.Add(new Test("import", FuseImport.Run));
            }

            if (args.Contains("--help"))
            {
                Console.WriteLine("USAGE: SystemTest.exe --fuse=<path to fuse.exe> [--skip=<test1>,<test2>...]");
                Console.WriteLine();
                Console.WriteLine("Known tests:");
                foreach (var test in tests)
                {
                    Console.WriteLine("  " + test.Name);
                }
                return(0);
            }
            var argList  = args.ToList();
            var shell    = new Shell();
            var fusePath = argList
                           .TryParse("fuse")
                           .SelectMany(p => ResolveAbsolutePath(shell, p));

            if (!fusePath.HasValue)
            {
                Console.WriteLine("Please specify '--fuse=<path to fuse.exe>'");
                return(1);
            }

            var skip = argList.TryParse("skip").SelectMany(s => s.Split(","));

            var fuseRunner = new FuseRunner(fusePath.Value);
            var root       = AbsoluteDirectoryPath.Parse(Directory.GetCurrentDirectory());

            var results = tests.Select(
                t =>
            {
                Console.WriteLine();
                if (skip.Contains(t.Name))
                {
                    Console.WriteLine("Skipping test:" + t.Name);
                    return(new TestResult(t, Result.Skipped));
                }
                else
                {
                    Console.WriteLine("Running test: " + t.Name);
                    return(Run(t, root, fuseRunner));
                }
            }).ToImmutableList();

            Console.WriteLine();
            Console.WriteLine("Test results");
            var fmt = "{0,-" + tests.Select(t => t.Name.Length).Max() + "} : {1}";

            foreach (var testResult in results)
            {
                Console.WriteLine(fmt, testResult.Test.Name, testResult.Result);
            }
            Console.WriteLine();
            return(results.Count(r => r.Result == Result.Failed) > 0 ? 1 : 0);
        }