Skip to content

Commit

Permalink
[xharness] Remove a lot of legacy code. (#21419)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne authored Oct 16, 2024
1 parent 9013ae4 commit 23dffef
Show file tree
Hide file tree
Showing 64 changed files with 92 additions and 2,379 deletions.
14 changes: 2 additions & 12 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,9 @@ logdev:
build-test-libraries:
@$(MAKE) -C $(TOP)/tests/test-libraries

.stamp-xharness-configure: $(XHARNESS_EXECUTABLE)
$(Q_GEN) $(DOTNET) $< $(XHARNESS_VERBOSITY) --configure --autoconf --rootdir $(CURDIR)
$(Q) touch $@
xharness: $(XHARNESS_EXECUTABLE)

all-local:: .stamp-xharness-configure
all-local:: xharness

$(TOP)/tools/common/SdkVersions.cs: $(TOP)/tools/common/SdkVersions.in.cs
@$(MAKE) -C $(TOP)/tools/mtouch ../common/SdkVersions.cs
Expand Down Expand Up @@ -348,13 +346,5 @@ package-test-libraries.zip:
$(Q) $(MAKE) all -C test-libraries/custom-type-assembly build-assembly
$(Q_GEN) rm -f "$@" "$@.tmp"
$(Q_GEN) cd $(TOP) && zip -9r --symlinks $(abspath $@).tmp ./tests/test-libraries
$(Q_GEN) cd $(TOP) && find tests -regex '.*/generated-projects/.*[c|f]sproj' -exec zip -9r --symlinks $(abspath $@).tmp {} +
$(Q_GEN) cd $(TOP) && find tests -regex '.*/generated-projects/.*sln' -exec zip -9r --symlinks $(abspath $@).tmp {} +
$(Q_GEN) cd $(TOP) && find tests -regex 'tests/test-libraries/custom-type-assembly/.libs/.*dll' -exec zip -9r --symlinks $(abspath $@).tmp {} +
$(Q_GEN) cd $(TOP) && git ls-files -o -- 'tests/*/Info-*plist' | zip -9r --symlinks $(abspath $@).tmp -@
ifdef INCLUDE_XAMARIN_LEGACY
ifdef INCLUDE_IOS
$(Q_GEN) cd $(TOP) && zip -9r --symlinks $(abspath $@).tmp ./tools/mtouch/simlauncher*-sgen*
endif
endif
$(Q) mv "$@".tmp "$@"
1 change: 0 additions & 1 deletion tests/package-mac-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export MD_APPLE_SDK_ROOT="$(dirname "$(dirname "$XCODE_DEVELOPER_ROOT")")"
export RootTestsDirectory="$(pwd)"

make
make .stamp-xharness-configure

TEST_SUITE_DEPENDENCIES+=(bindings-test)
TEST_SUITE_DEPENDENCIES+=(EmbeddedResources)
Expand Down
45 changes: 8 additions & 37 deletions tests/xharness/AppRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public class AppRunner {
readonly string buildConfiguration;

string deviceName;
string companionDeviceName;
ISimulatorDevice simulator;
ISimulatorDevice companionSimulator;

bool ensureCleanSimulatorState = true;
bool EnsureCleanSimulatorState {
Expand Down Expand Up @@ -80,9 +78,7 @@ public AppRunner (IMlaunchProcessManager processManager,
string projectFilePath,
string buildConfiguration,
ISimulatorDevice simulator = null,
ISimulatorDevice companionSimulator = null,
string deviceName = null,
string companionDeviceName = null,
bool ensureCleanSimulatorState = false,
double timeoutMultiplier = 1,
string variation = null,
Expand All @@ -102,10 +98,8 @@ public AppRunner (IMlaunchProcessManager processManager,
this.Logs = logs ?? throw new ArgumentNullException (nameof (logs));
this.timeoutMultiplier = timeoutMultiplier;
this.deviceName = deviceName;
this.companionDeviceName = companionDeviceName;
this.ensureCleanSimulatorState = ensureCleanSimulatorState;
this.simulator = simulator;
this.companionSimulator = companionSimulator;
this.buildTask = buildTask;
this.target = target;
this.variation = variation;
Expand All @@ -129,7 +123,7 @@ async Task<bool> FindSimulatorAsync ()

var sims = simulatorsLoaderFactory.CreateLoader ();
await sims.LoadDevices (Logs.Create ($"simulator-list-{Harness.Helpers.Timestamp}.log", "Simulator list"), false, false);
(simulator, companionSimulator) = await sims.FindSimulators (target.GetTargetOs (false), MainLog);
(simulator, _) = await sims.FindSimulators (target.GetTargetOs (false), MainLog);

return simulator is not null;
}
Expand All @@ -149,9 +143,6 @@ async Task FindDevice ()
var device = await devs.FindDevice (runMode, MainLog, false, false);

deviceName = device?.Name;

if (runMode == RunMode.WatchOS)
companionDeviceName = (await devs.FindCompanionDevice (MainLog, device)).Name;
}

public async Task<ProcessExecutionResult> InstallAsync (CancellationToken cancellation_token)
Expand All @@ -172,14 +163,10 @@ public async Task<ProcessExecutionResult> InstallAsync (CancellationToken cancel
args.Add (new VerbosityArgument ());

args.Add (new InstallAppOnDeviceArgument (AppInformation.AppPath));
args.Add (new DeviceNameArgument (companionDeviceName ?? deviceName));

if (runMode == RunMode.WatchOS) {
args.Add (new DeviceArgument ("ios,watchos"));
}
args.Add (new DeviceNameArgument (deviceName));

var totalSize = Directory.GetFiles (AppInformation.AppPath, "*", SearchOption.AllDirectories).Select ((v) => new FileInfo (v).Length).Sum ();
MainLog.WriteLine ($"Installing '{AppInformation.AppPath}' to '{companionDeviceName ?? deviceName}'. Size: {totalSize} bytes = {totalSize / 1024.0 / 1024.0:N2} MB");
MainLog.WriteLine ($"Installing '{AppInformation.AppPath}' to '{deviceName}'. Size: {totalSize} bytes = {totalSize / 1024.0 / 1024.0:N2} MB");

return await processManager.ExecuteCommandAsync (args, MainLog, TimeSpan.FromHours (1), cancellationToken: cancellation_token);
}
Expand All @@ -197,7 +184,7 @@ public async Task<ProcessExecutionResult> UninstallAsync ()
args.Add (new VerbosityArgument ());

args.Add (new UninstallAppFromDeviceArgument (AppInformation.BundleIdentifier));
args.Add (new DeviceNameArgument (companionDeviceName ?? deviceName));
args.Add (new DeviceNameArgument (deviceName));

return await processManager.ExecuteCommandAsync (args, MainLog, TimeSpan.FromMinutes (1));
}
Expand Down Expand Up @@ -302,16 +289,7 @@ public async Task<int> RunAsync ()
args.AddRange (harness.EnvironmentVariables.Select (kvp => new SetEnvVariableArgument (kvp.Key, kvp.Value)));

if (IsExtension) {
switch (AppInformation.Extension) {
case Extension.TodayExtension:
args.Add (isSimulator
? (MlaunchArgument) new LaunchSimulatorExtensionArgument (AppInformation.LaunchAppPath, AppInformation.BundleIdentifier)
: new LaunchDeviceExtensionArgument (AppInformation.LaunchAppPath, AppInformation.BundleIdentifier));
break;
case Extension.WatchKit2:
default:
throw new NotImplementedException ();
}
throw new NotImplementedException ("Extensions aren't supported in xharness at the moment (no .NET extension tests yet)");
} else {
args.Add (isSimulator
? (MlaunchArgument) new LaunchSimulatorAppArgument (AppInformation.LaunchAppPath)
Expand All @@ -329,14 +307,12 @@ public async Task<int> RunAsync ()
args.Add (new SetStdoutArgument (stdout_log));
args.Add (new SetStderrArgument (stderr_log));

var simulators = new [] { simulator, companionSimulator }.Where (s => s is not null);
var simulators = new [] { simulator };
var systemLogs = new List<ICaptureLog> ();
foreach (var sim in simulators) {
// Upload the system log
MainLog.WriteLine ("System log for the '{1}' simulator is: {0}", sim.SystemLog, sim.Name);
bool isCompanion = sim != simulator;

var logDescription = isCompanion ? LogType.CompanionSystemLog.ToString () : LogType.SystemLog.ToString ();
var logDescription = LogType.SystemLog.ToString ();
var log = captureLogFactory.Create (
Path.Combine (Logs.Directory, sim.Name + ".log"),
sim.SystemLog,
Expand Down Expand Up @@ -393,12 +369,7 @@ public async Task<int> RunAsync ()
} else {
MainLog.WriteLine ("*** Executing {0}/{1} on device '{2}' ***", AppInformation.AppName, runMode, deviceName);

if (runMode == RunMode.WatchOS) {
args.Add (new AttachNativeDebuggerArgument ()); // this prevents the watch from backgrounding the app.
} else {
args.Add (new WaitForExitArgument ());
}

args.Add (new WaitForExitArgument ());
args.Add (new DeviceNameArgument (deviceName));

var deviceSystemLog = Logs.Create ($"device-{deviceName}-{Harness.Helpers.Timestamp}.log", "Device log");
Expand Down
Loading

5 comments on commit 23dffef

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.