public SharedTestState() { TestFixture = PreparePublishedSelfContainedTestProject("LocalizedApp"); }
public static string GetExtractionRootPath(TestProjectFixture fixture) { return(Path.Combine(fixture.TestProject.ProjectDirectory, "extract")); }
public static string GetAppBaseName(TestProjectFixture fixture) { return(Path.GetFileNameWithoutExtension(GetAppName(fixture))); }
public static string GetPublishPath(TestProjectFixture fixture) { return(Path.Combine(fixture.TestProject.ProjectDirectory, "publish")); }
public static string GetDepsJsonPath(TestProjectFixture fixture) { return(Path.Combine(GetPublishPath(fixture), $"{GetAppBaseName(fixture)}.deps.json")); }
public static string GetHostName(TestProjectFixture fixture) { return(Path.GetFileName(fixture.TestProject.AppExe)); }
public static Bundler Bundle(TestProjectFixture fixture, BundleOptions options = BundleOptions.None) { string singleFile; return(BundleApp(fixture, out singleFile, options, copyExcludedFiles: false)); }
public static DirectoryInfo GetExtractionDir(TestProjectFixture fixture, Bundler bundler) { return(new DirectoryInfo(GetExtractionPath(fixture, bundler))); }
public static string[] GetExtractedFiles(TestProjectFixture fixture) { return(new string[] { Path.GetFileName(fixture.TestProject.CoreClrDll) }); }
public SharedTestState() { TestFixture = PreparePublishedSelfContainedTestProject("AppWithWait"); }
public SharedTestState() { if (!OperatingSystem.IsWindows()) { // COM activation is only supported on Windows return; } string comsxsDirectory = BaseDirectory; string regFreeManifestName = $"{ ComLibraryFixture.TestProject.AssemblyName }.X.manifest"; string regFreeManifestPath = Path.Combine(comsxsDirectory, regFreeManifestName); using (var assemblyStream = new FileStream(ComLibraryFixture.TestProject.AppDll, FileMode.Open, FileAccess.Read, FileShare.Delete | FileShare.Read)) using (var peReader = new System.Reflection.PortableExecutable.PEReader(assemblyStream)) { if (peReader.HasMetadata) { MetadataReader reader = peReader.GetMetadataReader(); RegFreeComManifest.CreateManifestFromClsidmap( ComLibraryFixture.TestProject.AssemblyName, Path.GetFileName(ComHostPath), reader.GetAssemblyDefinition().Version.ToString(), ClsidMapPath, regFreeManifestPath, TypeLibraries ); } } string comsxsName = RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("comsxs"); ComSxsPath = Path.Combine(comsxsDirectory, comsxsName); File.Copy( Path.Combine(RepoDirectories.Artifacts, "corehost_test", comsxsName), ComSxsPath); ManagedHostFixture_FrameworkDependent = new TestProjectFixture("ManagedHost", RepoDirectories) .EnsureRestored() .PublishProject(selfContained: false, extraArgs: "/p:RegFreeCom=true"); File.Copy(regFreeManifestPath, Path.Combine(ManagedHostFixture_FrameworkDependent.TestProject.BuiltApp.Location, regFreeManifestName)); ManagedHostFixture_SelfContained = new TestProjectFixture("ManagedHost", RepoDirectories) .EnsureRestored() .PublishProject(selfContained: true, extraArgs: "/p:RegFreeCom=true"); File.Copy(regFreeManifestPath, Path.Combine(ManagedHostFixture_SelfContained.TestProject.BuiltApp.Location, regFreeManifestName)); // Copy the ComLibrary output and comhost to the ComSxS and ManagedHost directories string[] toCopy = { ComLibraryFixture.TestProject.AppDll, ComLibraryFixture.TestProject.DepsJson, ComLibraryFixture.TestProject.RuntimeConfigJson, ComHostPath, }; foreach (string filePath in toCopy) { File.Copy(filePath, Path.Combine(comsxsDirectory, Path.GetFileName(filePath))); File.Copy(filePath, Path.Combine(ManagedHostFixture_FrameworkDependent.TestProject.BuiltApp.Location, Path.GetFileName(filePath))); File.Copy(filePath, Path.Combine(ManagedHostFixture_SelfContained.TestProject.BuiltApp.Location, Path.GetFileName(filePath))); } }
public SharedTestState() { TestFixture = PreparePublishedSelfContainedTestProject("SingleFileApiTests"); }
public GivenThatICareAboutMultilevelSDKLookup() { // From the artifacts dir, it's possible to find where the sharedFrameworkPublish folder is. We need // to locate it because we'll copy its contents into other folders string artifactsDir = Environment.GetEnvironmentVariable("TEST_ARTIFACTS"); string builtDotnet = Path.Combine(artifactsDir, "..", "..", "intermediate", "sharedFrameworkPublish"); // The dotnetMultilevelSDKLookup dir will contain some folders and files that will be // necessary to perform the tests string baseMultilevelDir = Path.Combine(artifactsDir, "dotnetMultilevelSDKLookup"); string multilevelDir = CalculateMultilevelDirectory(baseMultilevelDir); // The three tested locations will be the cwd, the user folder and the exe dir. Both cwd and exe dir // are easily overwritten, so they will be placed inside the multilevel folder. The actual user location will // be used during tests. _currentWorkingDir = Path.Combine(multilevelDir, "cwd"); if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) { _userDir = Environment.GetEnvironmentVariable("USERPROFILE"); } else { _userDir = Environment.GetEnvironmentVariable("HOME"); } _executableDir = Path.Combine(multilevelDir, "exe"); // It's necessary to copy the entire publish folder to the exe dir because // we'll need to build from it. The CopyDirectory method automatically creates the dest dir CopyDirectory(builtDotnet, _executableDir); // SdkBaseDirs contain all available version folders _cwdSdkBaseDir = Path.Combine(_currentWorkingDir, "sdk"); _userSdkBaseDir = Path.Combine(_userDir, ".dotnet", RuntimeEnvironment.RuntimeArchitecture, "sdk"); _exeSdkBaseDir = Path.Combine(_executableDir, "sdk"); // Create directories Directory.CreateDirectory(_cwdSdkBaseDir); Directory.CreateDirectory(_userSdkBaseDir); Directory.CreateDirectory(_exeSdkBaseDir); // Restore and build PortableApp from exe dir RepoDirectories = new RepoDirectoriesProvider(builtDotnet: _executableDir); PreviouslyBuiltAndRestoredPortableTestProjectFixture = new TestProjectFixture("PortableApp", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .BuildProject(); var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture; // Set a dummy framework version (9999.0.0) in the cwd sharedFx location. We will // always pick the framework from cwd to avoid interference with the sharedFxLookup // test folders in the user dir string cwdDummyFxVersion = Path.Combine(_currentWorkingDir, "shared", "Microsoft.NETCore.App", "9999.0.0"); string builtSharedFxDir = fixture.BuiltDotnet.GreatestVersionSharedFxPath; CopyDirectory(builtSharedFxDir, cwdDummyFxVersion); // The actual SDK version can be obtained from the built fixture. We'll use it to // locate the sdkDir from which we can get the files contained in the version folder string sdkBaseDir = Path.Combine(fixture.SdkDotnet.BinPath, "sdk"); var sdkVersionDirs = Directory.EnumerateDirectories(sdkBaseDir); string greatestVersionSdk = sdkVersionDirs .OrderByDescending(p => p.ToLower()) .First(); _sdkDir = Path.Combine(sdkBaseDir, greatestVersionSdk); // Trace messages used to identify from which folder the SDK was picked _cwdSelectedMessage = $"Using dotnet SDK dll=[{_cwdSdkBaseDir}"; _userSelectedMessage = $"Using dotnet SDK dll=[{_userSdkBaseDir}"; _exeSelectedMessage = $"Using dotnet SDK dll=[{_exeSdkBaseDir}"; }
public static DirectoryInfo GetExtractionRootDir(TestProjectFixture fixture) { return(Directory.CreateDirectory(GetExtractionRootPath(fixture))); }
public static string[] GetExtractedFiles(TestProjectFixture fixture) { string appBaseName = GetAppBaseName(fixture); return(new string[] { $"{appBaseName}.dll" }); }
public static string GetExtractionPath(TestProjectFixture fixture, Bundler bundler) { return(Path.Combine(GetExtractionRootPath(fixture), GetAppBaseName(fixture), bundler.BundleManifest.BundleID)); }
public SharedTestState() { RepoDirectories = new RepoDirectoriesProvider(); // Entry point projects PortableAppFixture = new TestProjectFixture("PortableApp", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); PortableAppWithExceptionFixture = new TestProjectFixture("PortableAppWithException", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); // Entry point with missing reference assembly PortableAppWithMissingRefFixture = new TestProjectFixture("PortableAppWithMissingRef", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); // Correct startup hooks StartupHookFixture = new TestProjectFixture("StartupHook", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); StartupHookWithOverloadFixture = new TestProjectFixture("StartupHookWithOverload", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); // Missing startup hook type (no StartupHook type defined) StartupHookWithoutStartupHookTypeFixture = new TestProjectFixture("StartupHookWithoutStartupHookType", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); // Missing startup hook method (no Initialize method defined) StartupHookWithoutInitializeMethodFixture = new TestProjectFixture("StartupHookWithoutInitializeMethod", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); // Invalid startup hook assembly StartupHookStartupHookInvalidAssemblyFixture = new TestProjectFixture("StartupHookFake", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); // Invalid startup hooks (incorrect signatures) StartupHookWithNonPublicMethodFixture = new TestProjectFixture("StartupHookWithNonPublicMethod", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); StartupHookWithInstanceMethodFixture = new TestProjectFixture("StartupHookWithInstanceMethod", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); StartupHookWithParameterFixture = new TestProjectFixture("StartupHookWithParameter", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); StartupHookWithReturnTypeFixture = new TestProjectFixture("StartupHookWithReturnType", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); StartupHookWithMultipleIncorrectSignaturesFixture = new TestProjectFixture("StartupHookWithMultipleIncorrectSignatures", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); // Valid startup hooks with incorrect behavior StartupHookWithDependencyFixture = new TestProjectFixture("StartupHookWithDependency", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); // Startup hook with an assembly resolver StartupHookWithAssemblyResolver = new TestProjectFixture("StartupHookWithAssemblyResolver", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .PublishProject(); }
public static string GetAppPath(TestProjectFixture fixture) { return(Path.Combine(GetPublishPath(fixture), GetAppName(fixture))); }
public SharedTestState() { TestFixture30 = CreatePublishedFixture("netcoreapp3.0", "3.0.0"); TestFixture31 = CreatePublishedFixture("netcoreapp3.1", "3.1.0"); }
public static string GetPublishedSingleFilePath(TestProjectFixture fixture) { return(GetHostPath(fixture)); }
public GivenThatICareAboutMultilevelSharedFxLookup() { // From the artifacts dir, it's possible to find where the sharedFrameworkPublish folder is. We need // to locate it because we'll copy its contents into other folders string artifactsDir = Environment.GetEnvironmentVariable("TEST_ARTIFACTS"); _builtDotnet = Path.Combine(artifactsDir, "sharedFrameworkPublish"); // The dotnetMultilevelSharedFxLookup dir will contain some folders and files that will be // necessary to perform the tests string baseMultilevelDir = Path.Combine(artifactsDir, "dotnetMultilevelSharedFxLookup"); _multilevelDir = SharedFramework.CalculateUniqueTestDirectory(baseMultilevelDir); // The three tested locations will be the cwd, the user folder and the exe dir. Both cwd and exe dir // are easily overwritten, so they will be placed inside the multilevel folder. The actual user location will // be used during tests _currentWorkingDir = Path.Combine(_multilevelDir, "cwd"); _userDir = Path.Combine(_multilevelDir, "user"); _exeDir = Path.Combine(_multilevelDir, "exe"); _regDir = Path.Combine(_multilevelDir, "reg"); RepoDirectories = new RepoDirectoriesProvider(builtDotnet: _exeDir); // SharedFxBaseDirs contain all available version folders _cwdSharedFxBaseDir = Path.Combine(_currentWorkingDir, "shared", "Microsoft.NETCore.App"); _userSharedFxBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "shared", "Microsoft.NETCore.App"); _exeSharedFxBaseDir = Path.Combine(_exeDir, "shared", "Microsoft.NETCore.App"); _regSharedFxBaseDir = Path.Combine(_regDir, "shared", "Microsoft.NETCore.App"); _cwdSharedUberFxBaseDir = Path.Combine(_currentWorkingDir, "shared", "Microsoft.UberFramework"); _userSharedUberFxBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "shared", "Microsoft.UberFramework"); _exeSharedUberFxBaseDir = Path.Combine(_exeDir, "shared", "Microsoft.UberFramework"); _regSharedUberFxBaseDir = Path.Combine(_regDir, "shared", "Microsoft.UberFramework"); // Create directories. It's necessary to copy the entire publish folder to the exe dir because // we'll need to build from it. The CopyDirectory method automatically creates the dest dir Directory.CreateDirectory(_cwdSharedFxBaseDir); Directory.CreateDirectory(_userSharedFxBaseDir); Directory.CreateDirectory(_regSharedFxBaseDir); Directory.CreateDirectory(_cwdSharedUberFxBaseDir); Directory.CreateDirectory(_userSharedUberFxBaseDir); Directory.CreateDirectory(_regSharedUberFxBaseDir); SharedFramework.CopyDirectory(_builtDotnet, _exeDir); //Copy dotnet to self-registered directory File.Copy(Path.Combine(_builtDotnet, $"dotnet{Constants.ExeSuffix}"), Path.Combine(_regDir, $"dotnet{Constants.ExeSuffix}"), true); // Restore and build SharedFxLookupPortableApp from exe dir PreviouslyBuiltAndRestoredPortableTestProjectFixture = new TestProjectFixture("SharedFxLookupPortableApp", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .BuildProject(); var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture; // The actual framework version can be obtained from the built fixture. We'll use it to // locate the builtSharedFxDir from which we can get the files contained in the version folder string greatestVersionSharedFxPath = fixture.BuiltDotnet.GreatestVersionSharedFxPath; _sharedFxVersion = (new DirectoryInfo(greatestVersionSharedFxPath)).Name; _builtSharedFxDir = Path.Combine(_builtDotnet, "shared", "Microsoft.NETCore.App", _sharedFxVersion); _builtSharedUberFxDir = Path.Combine(_builtDotnet, "shared", "Microsoft.UberFramework", _sharedFxVersion); SharedFramework.CreateUberFrameworkArtifacts(_builtSharedFxDir, _builtSharedUberFxDir, SystemCollectionsImmutableAssemblyVersion, SystemCollectionsImmutableFileVersion); // Trace messages used to identify from which folder the framework was picked _hostPolicyDllName = Path.GetFileName(fixture.TestProject.HostPolicyDll); _cwdSelectedMessage = $"The expected {_hostPolicyDllName} directory is [{_cwdSharedFxBaseDir}"; _userSelectedMessage = $"The expected {_hostPolicyDllName} directory is [{_userSharedFxBaseDir}"; _exeSelectedMessage = $"The expected {_hostPolicyDllName} directory is [{_exeSharedFxBaseDir}"; _regSelectedMessage = $"The expected {_hostPolicyDllName} directory is [{_regSharedFxBaseDir}"; _cwdFoundUberFxMessage = $"Chose FX version [{_cwdSharedUberFxBaseDir}"; _userFoundUberFxMessage = $"Chose FX version [{_userSharedUberFxBaseDir}"; _exeFoundUberFxMessage = $"Chose FX version [{_exeSharedUberFxBaseDir}"; _regFoundUberFxMessage = $"Chose FX version [{_regSharedUberFxBaseDir}"; }
public static string GetAppName(TestProjectFixture fixture) { return(Path.GetFileName(fixture.TestProject.AppDll)); }
public SharedTestState() { TestFixture = PreparePublishedSelfContainedTestProject("StandaloneApp"); }
public static string[] GetBundledFiles(TestProjectFixture fixture) { string appBaseName = GetAppBaseName(fixture); return(new string[] { $"{appBaseName}.dll", $"{appBaseName}.deps.json", $"{appBaseName}.runtimeconfig.json" }); }
public static DirectoryInfo GetBundleDir(TestProjectFixture fixture) { return(Directory.CreateDirectory(Path.Combine(fixture.TestProject.ProjectDirectory, "bundle"))); }
public GivenThatICareAboutMultilevelSDKLookup() { // From the artifacts dir, it's possible to find where the sharedFrameworkPublish folder is. We need // to locate it because we'll copy its contents into other folders string artifactsDir = Environment.GetEnvironmentVariable("TEST_ARTIFACTS"); string builtDotnet = Path.Combine(artifactsDir, "sharedFrameworkPublish"); // The dotnetMultilevelSDKLookup dir will contain some folders and files that will be // necessary to perform the tests string baseMultilevelDir = Path.Combine(artifactsDir, "dotnetMultilevelSDKLookup"); string multilevelDir = CalculateMultilevelDirectory(baseMultilevelDir); // The three tested locations will be the cwd, the user folder and the exe dir. cwd and user are no longer supported. // All dirs will be placed inside the multilevel folder _currentWorkingDir = Path.Combine(multilevelDir, "cwd"); _userDir = Path.Combine(multilevelDir, "user"); _executableDir = Path.Combine(multilevelDir, "exe"); // It's necessary to copy the entire publish folder to the exe dir because // we'll need to build from it. The CopyDirectory method automatically creates the dest dir CopyDirectory(builtDotnet, _executableDir); RepoDirectories = new RepoDirectoriesProvider(builtDotnet: _executableDir); // SdkBaseDirs contain all available version folders _cwdSdkBaseDir = Path.Combine(_currentWorkingDir, "sdk"); _userSdkBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "sdk"); _exeSdkBaseDir = Path.Combine(_executableDir, "sdk"); // Create directories Directory.CreateDirectory(_cwdSdkBaseDir); Directory.CreateDirectory(_userSdkBaseDir); Directory.CreateDirectory(_exeSdkBaseDir); // Restore and build PortableApp from exe dir PreviouslyBuiltAndRestoredPortableTestProjectFixture = new TestProjectFixture("PortableApp", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .BuildProject(); var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture; // Set a dummy framework version (9999.0.0) in the exe sharedFx location. We will // always pick the framework from this to avoid interference with the sharedFxLookup string exeDirDummyFxVersion = Path.Combine(_executableDir, "shared", "Microsoft.NETCore.App", "9999.0.0"); string builtSharedFxDir = fixture.BuiltDotnet.GreatestVersionSharedFxPath; CopyDirectory(builtSharedFxDir, exeDirDummyFxVersion); // The actual SDK version can be obtained from the built fixture. We'll use it to // locate the sdkDir from which we can get the files contained in the version folder string sdkBaseDir = Path.Combine(fixture.SdkDotnet.BinPath, "sdk"); var sdkVersionDirs = Directory.EnumerateDirectories(sdkBaseDir) .Select(p => Path.GetFileName(p)); string greatestVersionSdk = sdkVersionDirs .Where(p => !string.Equals(p, "NuGetFallbackFolder", StringComparison.OrdinalIgnoreCase)) .OrderByDescending(p => p.ToLower()) .First(); _sdkDir = Path.Combine(sdkBaseDir, greatestVersionSdk); // Trace messages used to identify from which folder the SDK was picked _cwdSelectedMessage = $"Using dotnet SDK dll=[{_cwdSdkBaseDir}"; _userSelectedMessage = $"Using dotnet SDK dll=[{_userSdkBaseDir}"; _exeSelectedMessage = $"Using dotnet SDK dll=[{_exeSdkBaseDir}"; }
public SharedTestState() { TestFixture = PreparePublishedSelfContainedTestProject("BundleProbeTester"); }