Ejemplo n.º 1
0
        public TestProjectFixture(
            string testProjectName,
            RepoDirectoriesProvider repoDirectoriesProvider,
            string framework    = null,
            string assemblyName = null)
        {
            ValidateRequiredDirectories(repoDirectoriesProvider);

            RepoDirProvider = repoDirectoriesProvider;

            Framework = framework ?? RepoDirProvider.GetTestContextVariable("MNA_TFM");

            SdkDotnet  = new DotNetCli(repoDirectoriesProvider.DotnetSDK);
            CurrentRid = repoDirectoriesProvider.TargetRID;

            BuiltDotnet = new DotNetCli(repoDirectoriesProvider.BuiltDotnet);

            _assemblyName = assemblyName;

            var sourceTestProjectPath = Path.Combine(repoDirectoriesProvider.TestAssetsFolder, "TestProjects", testProjectName);

            _sourceTestProject = new TestProject(
                sourceTestProjectPath,
                assemblyName: _assemblyName);

            TestProject = CopyTestProject(_sourceTestProject);
        }
Ejemplo n.º 2
0
        public TestProjectFixture(TestProjectFixture fixtureToCopy)
        {
            _testProjectName            = fixtureToCopy._testProjectName;
            _exeExtension               = fixtureToCopy._exeExtension;
            _sharedLibraryExtension     = fixtureToCopy._sharedLibraryExtension;
            _sharedLibraryPrefix        = fixtureToCopy._sharedLibraryPrefix;
            _repoDirectoriesProvider    = fixtureToCopy._repoDirectoriesProvider;
            _testProjectSourceDirectory = fixtureToCopy._testProjectSourceDirectory;
            _testArtifactDirectory      = fixtureToCopy._testArtifactDirectory;
            _sdkDotnet         = fixtureToCopy._sdkDotnet;
            _currentRid        = fixtureToCopy._currentRid;
            _builtDotnet       = fixtureToCopy._builtDotnet;
            _sourceTestProject = fixtureToCopy._sourceTestProject;
            _framework         = fixtureToCopy._framework;
            _assemblyName      = fixtureToCopy._assemblyName;

            _testProject = CopyTestProject(
                fixtureToCopy.TestProject,
                _testArtifactDirectory,
                _exeExtension,
                _sharedLibraryExtension,
                _sharedLibraryPrefix,
                _assemblyName);

            fixtureToCopy._copiedTestProjects.Add(_testProject);
        }
Ejemplo n.º 3
0
        private void ValidateRequiredDirectories(RepoDirectoriesProvider repoDirectoriesProvider)
        {
            if (!Directory.Exists(repoDirectoriesProvider.BuiltDotnet))
            {
                throw new Exception($"Unable to find built host and sharedfx, please ensure the build has been run: {repoDirectoriesProvider.BuiltDotnet}");
            }

            if (!Directory.Exists(repoDirectoriesProvider.CorehostPackages))
            {
                throw new Exception($"Unable to find host packages directory, please ensure the build has been run: {repoDirectoriesProvider.CorehostPackages}");
            }
        }
Ejemplo n.º 4
0
        public TestProjectFixture(TestProjectFixture fixtureToCopy)
        {
            RepoDirProvider    = fixtureToCopy.RepoDirProvider;
            SdkDotnet          = fixtureToCopy.SdkDotnet;
            CurrentRid         = fixtureToCopy.CurrentRid;
            BuiltDotnet        = fixtureToCopy.BuiltDotnet;
            _sourceTestProject = fixtureToCopy._sourceTestProject;
            Framework          = fixtureToCopy.Framework;
            _assemblyName      = fixtureToCopy._assemblyName;

            TestProject = CopyTestProject(fixtureToCopy.TestProject);
        }
Ejemplo n.º 5
0
        public TestProjectFixture(
            string testProjectName,
            RepoDirectoriesProvider repoDirectoriesProvider,
            string exeExtension               = null,
            string sharedLibraryExtension     = null,
            string sharedLibraryPrefix        = null,
            string testProjectSourceDirectory = null,
            string testArtifactDirectory      = null,
            string dotnetInstallPath          = null,
            string currentRid            = null,
            string builtDotnetOutputPath = null,
            string framework             = null,
            string assemblyName          = null)
        {
            ValidateRequiredDirectories(repoDirectoriesProvider);

            _testProjectName = testProjectName;
            _framework       = framework ?? Environment.GetEnvironmentVariable("MNA_TFM");

            _exeExtension           = exeExtension ?? RuntimeInformationExtensions.GetExeExtensionForCurrentOSPlatform();
            _sharedLibraryExtension = sharedLibraryExtension
                                      ?? RuntimeInformationExtensions.GetSharedLibraryExtensionForCurrentPlatform();
            _sharedLibraryPrefix = sharedLibraryPrefix
                                   ?? RuntimeInformationExtensions.GetSharedLibraryPrefixForCurrentPlatform();

            _repoDirectoriesProvider = repoDirectoriesProvider;

            _testProjectSourceDirectory = testProjectSourceDirectory
                                          ?? Path.Combine(repoDirectoriesProvider.RepoRoot, "src", "test", "Assets", "TestProjects");
            _testArtifactDirectory = _testArtifactDirectory
                                     ?? Environment.GetEnvironmentVariable(s_testArtifactDirectoryEnvironmentVariable)
                                     ?? Path.Combine(AppContext.BaseDirectory, s_testArtifactDirectoryEnvironmentVariable);

            _sdkDotnet  = new DotNetCli(dotnetInstallPath ?? repoDirectoriesProvider.DotnetSDK);
            _currentRid = currentRid ?? repoDirectoriesProvider.TargetRID;

            _builtDotnet = new DotNetCli(repoDirectoriesProvider.BuiltDotnet);

            _assemblyName = assemblyName;

            InitializeTestProject(
                _testProjectName,
                _testProjectSourceDirectory,
                _testArtifactDirectory,
                _exeExtension,
                _sharedLibraryExtension,
                _sharedLibraryPrefix,
                _assemblyName);
        }
Ejemplo n.º 6
0
        public DotNetBuilder(string basePath, string builtDotnet, string name)
        {
            _path = name == null ? basePath : Path.Combine(basePath, name);
            Directory.CreateDirectory(_path);

            _repoDirectories = new RepoDirectoriesProvider(builtDotnet: _path);

            // Prepare the dotnet installation mock

            // ./dotnet.exe - used as a convenient way to load and invoke hostfxr. May change in the future to use test-specific executable
            var builtDotNetCli = new DotNetCli(builtDotnet);

            File.Copy(
                builtDotNetCli.DotnetExecutablePath,
                Path.Combine(_path, RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("dotnet")),
                true);

            // ./host/fxr/<version>/hostfxr.dll - this is the component being tested
            SharedFramework.CopyDirectory(
                builtDotNetCli.GreatestVersionHostFxrPath,
                Path.Combine(_path, "host", "fxr", Path.GetFileName(builtDotNetCli.GreatestVersionHostFxrPath)));
        }