Exemple #1
0
        public void BootstrapperInvokesApplicationHostWithInferredAppBase_ProjectFileAsArgument(string flavor, string os, string architecture)
        {
            var runtimeHomeDir = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

            using (var tempSamplesDir = TestUtils.PrepareTemporarySamplesFolder(runtimeHomeDir))
            {
                var testAppPath        = Path.Combine(tempSamplesDir, "HelloWorld");
                var testAppProjectFile = Path.Combine(testAppPath, Project.ProjectFileName);

                string stdOut, stdErr;
                var    exitCode = BootstrapperTestUtils.ExecBootstrapper(
                    runtimeHomeDir,
                    arguments: $"-p {testAppProjectFile} run",
                    stdOut: out stdOut,
                    stdErr: out stdErr,
                    environment: new Dictionary <string, string> {
                    { EnvironmentNames.Trace, null }
                });

                Assert.Equal(0, exitCode);
                Assert.Equal(@"Hello World!
Hello, code!
I
can
customize
the
default
command
", stdOut);
            }
        }
Exemple #2
0
        public void BootstrapperInvokesApplicationHostWithInferredAppBase_ProjectDirAsArgument(string flavor, string os, string architecture)
        {
            using (var runtimeHomeDir = TestUtils.GetRuntimeHomeDir(flavor, os, architecture))
            {
                var    sampleAppRoot = Path.Combine(TestUtils.GetSamplesFolder(), "HelloWorld");
                string stdOut, stdErr;
                var    exitCode = BootstrapperTestUtils.ExecBootstrapper(
                    runtimeHomeDir,
                    arguments: string.Format("{0} run", sampleAppRoot),
                    stdOut: out stdOut,
                    stdErr: out stdErr,
                    environment: new Dictionary <string, string> {
                    { EnvironmentNames.Trace, null }
                });

                Assert.Equal(0, exitCode);
                Assert.Equal(@"Hello World!
Hello, code!
I
can
customize
the
default
command
", stdOut);
            }
        }
Exemple #3
0
        public void BootstrapperInvokesAssemblyWithInferredAppBaseAndLibPathOnCoreClr(string flavor, string os, string architecture)
        {
            using (var runtimeHomeDir = TestUtils.GetRuntimeHomeDir(flavor, os, architecture))
                using (var tempDir = TestUtils.CreateTempDir())
                {
                    var samplesPath   = TestUtils.GetSamplesFolder();
                    var sampleAppRoot = Path.Combine(samplesPath, "HelloWorld");

                    var exitCode = DnuTestUtils.ExecDnu(
                        runtimeHomeDir,
                        subcommand: "build",
                        arguments: string.Format("{0} --configuration=Release --out {1}", sampleAppRoot, tempDir.DirPath));

                    Assert.Equal(0, exitCode);

                    string stdOut, stdErr;
                    exitCode = BootstrapperTestUtils.ExecBootstrapper(
                        runtimeHomeDir,
                        arguments: Path.Combine(tempDir, "Release", "dnxcore50", "HelloWorld.dll"),
                        stdOut: out stdOut,
                        stdErr: out stdErr,
                        environment: new Dictionary <string, string> {
                        { EnvironmentNames.Trace, null }
                    });

                    Assert.Equal(0, exitCode);
                    Assert.Equal(@"Hello World!
Hello, code!
", stdOut);
                }
        }
Exemple #4
0
        public void BootstrapperLaunchesRequestedFramworkVersionIfOptionProvided(string flavor, string os, string architecture, string requestedFramework, string expectedOutput)
        {
            const string projectStructure = @"{
    ""project.json"": {},
    ""project.lock.json"": {},
    ""Program.cs"": {}
}";

            const string projectJson = @"{
    ""dependencies"": {
    },
    ""frameworks"": {
        ""dnx46"": {},
        ""dnx452"": {},
        ""dnx451"": {}
    }
}";
            const string lockFile    = @"{
  ""locked"": false,
  ""version"": 1,
  ""targets"": {
    ""DNX,Version=v4.5.1"": {}
    ""DNX,Version=v4.5.2"": {}
    ""DNX,Version=v4.6"": {}
  },
  ""libraries"": {},
  ""projectFileDependencyGroups"": {
    """": [],
    ""DNX,Version=v4.5.1"": []
    ""DNX,Version=v4.5.2"": []
    ""DNX,Version=v4.6"": []
  }
}";

            var runtimeHomeDir = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

            using (var tempDir = TestUtils.CreateTempDir())
            {
                DirTree.CreateFromJson(projectStructure)
                .WithFileContents("project.json", projectJson)
                .WithFileContents("project.lock.json", lockFile)
                .WithFileContents("Program.cs", ClrVersionTestProgram)
                .WriteTo(tempDir);

                string stdOut;
                string stdErr;
                var    exitCode = BootstrapperTestUtils.ExecBootstrapper(
                    runtimeHomeDir,
                    arguments: $"--framework {requestedFramework} run",
                    stdOut: out stdOut,
                    stdErr: out stdErr,
                    environment: new Dictionary <string, string> {
                    { EnvironmentNames.Trace, null }
                },
                    workingDir: tempDir);
                Assert.Equal(0, exitCode);
                Assert.Equal(expectedOutput, stdOut.Trim());
            }
        }
Exemple #5
0
        public void BootstrapperReturnsZeroExitCodeWhenHelpOptionWasGiven(string flavor, string os, string architecture)
        {
            var runtimeHomeDir = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

            string stdOut, stdErr;
            var    exitCode = BootstrapperTestUtils.ExecBootstrapper(
                runtimeHomeDir,
                arguments: "--help",
                stdOut: out stdOut,
                stdErr: out stdErr);

            Assert.Equal(0, exitCode);
        }
Exemple #6
0
        public void BootstrapperReturnsNonZeroExitCodeWhenNoArgumentWasGiven(string flavor, string os, string architecture)
        {
            var runtimeHomeDir = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

            string stdOut, stdErr;
            var    exitCode = BootstrapperTestUtils.ExecBootstrapper(
                runtimeHomeDir,
                arguments: string.Empty,
                stdOut: out stdOut,
                stdErr: out stdErr);

            Assert.NotEqual(0, exitCode);
        }
Exemple #7
0
        public void BootstrapperShowsVersionAndReturnsZeroExitCodeWhenVersionOptionWasGiven(string flavor, string os, string architecture)
        {
            var runtimeHomeDir = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

            string stdOut, stdErr;
            var    exitCode = BootstrapperTestUtils.ExecBootstrapper(
                runtimeHomeDir,
                arguments: "--version",
                stdOut: out stdOut,
                stdErr: out stdErr);

            Assert.Equal(0, exitCode);
            Assert.Contains(TestUtils.GetRuntimeVersion(), stdOut);
        }
Exemple #8
0
        public void BootstrapperConfiguresAppConfigFile(string flavor, string os, string architecture)
        {
            const string projectStructure = @"{
    ""project.json"": {},
    ""project.lock.json"": {},
    ""app.config"": {},
    ""Program.cs"": {}
}";

            const string projectJson = @" {
    ""frameworks"": {
        ""dnx451"": {
            ""frameworkAssemblies"": {
                ""System.Configuration"": """"
            }
        }
    }
}";
            const string appConfig   = @"<configuration>
  <appSettings>
    <add key=""TheSetting"" value=""TheValue"" />
  </appSettings>
</configuration>";

            var runtimeHomeDir = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

            using (var tempDir = TestUtils.CreateTempDir())
            {
                DirTree.CreateFromJson(projectStructure)
                .WithFileContents("project.json", projectJson)
                .WithFileContents("app.config", appConfig)
                .WithFileContents("Program.cs", AppSettingTestProgram)
                .WriteTo(tempDir);

                string stdOut;
                string stdErr;
                var    exitCode = BootstrapperTestUtils.ExecBootstrapper(
                    runtimeHomeDir,
                    arguments: $"run",
                    stdOut: out stdOut,
                    stdErr: out stdErr,
                    environment: new Dictionary <string, string> {
                    { EnvironmentNames.Trace, null }
                },
                    workingDir: tempDir);
                Assert.Equal(0, exitCode);
                Assert.Equal("TheSetting=TheValue", stdOut.Trim());
            }
        }
Exemple #9
0
        public void BootstrapperInvokesAssemblyWithInferredAppBaseAndLibPathOnClr(string flavor, string os, string architecture)
        {
            var outputFolder   = flavor == "coreclr" ? "dnxcore50" : "dnx451";
            var runtimeHomeDir = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

            using (var tempSamplesDir = TestUtils.PrepareTemporarySamplesFolder(runtimeHomeDir))
                using (var tempDir = TestUtils.CreateTempDir())
                {
                    var sampleAppRoot = Path.Combine(tempSamplesDir, "HelloWorld");

                    string stdOut, stdErr;
                    var    exitCode = DnuTestUtils.ExecDnu(
                        runtimeHomeDir,
                        subcommand: "build",
                        arguments: string.Format("{0} --configuration=Release --out {1}", sampleAppRoot, tempDir),
                        stdOut: out stdOut,
                        stdErr: out stdErr);

                    if (exitCode != 0)
                    {
                        Console.WriteLine(stdOut);
                        Console.WriteLine(stdErr);
                    }

                    exitCode = BootstrapperTestUtils.ExecBootstrapper(
                        runtimeHomeDir,
                        arguments: Path.Combine(tempDir, "Release", outputFolder, "HelloWorld.dll"),
                        stdOut: out stdOut,
                        stdErr: out stdErr,
                        environment: new Dictionary <string, string> {
                        { EnvironmentNames.Trace, null }
                    });

                    Assert.Equal(0, exitCode);
                    Assert.Equal(@"Hello World!
Hello, code!
", stdOut);
                }
        }