Skip to content

Commit

Permalink
Buildifier linting, deterministic array order
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxiao0228 committed Nov 14, 2019
1 parent 4282122 commit c8e526e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
4 changes: 1 addition & 3 deletions bp/src/BPConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ - (nonnull id)copyWithZone:(nullable NSZone *)zone {
c.environment = [self.environment copy];
c.testBundlePath = [self.testBundlePath copy];
c.testHost = [self.testHost copy];
c.uiTargetAppPath = [self.uiTargetAppPath copy];

return c;
}

Expand Down Expand Up @@ -526,7 +524,7 @@ - (BOOL)loadTestPlan:(NSString *)file withError:(NSError **)errPtr{

NSMutableDictionary<NSString *, BPTestPlan*> *tests = [[NSMutableDictionary alloc] init];
NSDictionary *testOptions = [configDict objectForKey:@"tests"];
for (NSString *key in testOptions) {
for (NSString *key in [[testOptions allKeys] sortedArrayUsingSelector:@selector(compare:)]) {
NSDictionary *planDictionary = [testOptions objectForKey:key];
BPTestPlan *plan = [[BPTestPlan alloc] init];
plan.testHost = [planDictionary objectForKey:@"test_host"];
Expand Down
32 changes: 18 additions & 14 deletions bptestrunner/bluepill_batch_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ def _bluepill_batch_test_impl(ctx):
runfiles = [ctx.file._bp_exec, ctx.file._bluepill_exec]
test_bundle_paths = []
test_host_paths = []

# test environments
test_env = ctx.configuration.test_env

# gather files
test_plans = {}
for test_target in ctx.attr.test_targets:
Expand All @@ -27,29 +29,31 @@ def _bluepill_batch_test_impl(ctx):

#test_plan
test_plan = struct(
test_host=test_host.basename.rstrip(
'.' + test_host.extension) + '.app',
environment=test_env,
arguments=test_env,
test_bundle_path=bundle_info.bundle_name + bundle_info.bundle_extension)
test_host = test_host.basename.rstrip(
"." + test_host.extension,
) + ".app",
environment = test_env,
arguments = test_env,
test_bundle_path = bundle_info.bundle_name + bundle_info.bundle_extension,
)
test_plans[test_target.label.name] = test_plan

# Write test plan json.
test_plan_file = ctx.actions.declare_file(ctx.attr.name + "_test_plan.json")
ctx.actions.write(
output = test_plan_file,
content = struct(tests=test_plans).to_json()
content = struct(tests = test_plans).to_json(),
)
runfiles.append(test_plan_file)

# Write the shell script.
substitutions = {
"test_bundle_paths": ' '.join(test_bundle_paths),
"test_host_paths":' '.join(test_host_paths),
"test_bundle_paths": " ".join(test_bundle_paths),
"test_host_paths": " ".join(test_host_paths),
"bp_test_plan": test_plan_file.basename,
"bp_path": ctx.executable._bp_exec.short_path,
"bluepill_path": ctx.executable._bluepill_exec.short_path,
"target_name": ctx.attr.name
"target_name": ctx.attr.name,
}
if ctx.attr.config_file:
runfiles += [ctx.file.config_file]
Expand All @@ -60,14 +64,14 @@ def _bluepill_batch_test_impl(ctx):
ctx.actions.expand_template(
template = ctx.file._test_runner_template,
output = ctx.outputs.test_runner,
substitutions = substitutions
substitutions = substitutions,
)
return [
DefaultInfo(
runfiles = ctx.runfiles(
files = runfiles,
),
executable = ctx.outputs.test_runner
executable = ctx.outputs.test_runner,
),
]

Expand Down Expand Up @@ -100,15 +104,15 @@ as possible between simulators.
),
allow_single_file = True,
executable = True,
cfg = "host"
cfg = "host",
),
"_bluepill_exec": attr.label(
default = Label(
"@bptestrunner//bluepill:bluepill",
),
allow_single_file = True,
executable = True,
cfg = "host"
cfg = "host",
),
"_xcode_config": attr.label(
default = configuration_field(
Expand Down Expand Up @@ -139,4 +143,4 @@ test plan json file, bluepill config file if specified, xctest bundles, test hos
This rule WILL disregard the bluepill output folder configuration if it's set in the
config json file. Instead it will copy all the outputs to ./bazel-testlogs/$TARGET_NAME/test.outputs/
""",
)
)

0 comments on commit c8e526e

Please sign in to comment.