Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase facebook/buck 10/2020 #9

Merged
merged 38 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1c31c5b
Respect user input if abi_generation_mode is explicitly provided in j…
davidhao3300 Jun 25, 2020
da5384f
Automate publishing docs on CirclrCI (#2486)
Jun 29, 2020
3283f1c
Fixed git push access denied issue (#2487)
Jun 29, 2020
0aeb8be
handle bundling resources of static frameworks (Originally by rmaz) (…
Unknoob Jul 10, 2020
0299f0f
Add support for java 11 builds in jitpack (#2499)
kageiit Jul 20, 2020
888cae1
Fixed Unable to resolve dependency jdk8 (= 8.0.172) (#2492)
Jul 22, 2020
c29414a
CircleCI fix (#2495)
Jul 22, 2020
992456c
Added python3 to interpreter names (#2497)
Jul 22, 2020
c381e7c
Fixes for rust tests (#2503)
Jul 30, 2020
c30a8be
Add support for ANDROID_SDK_ROOT environment variable (#2507)
Jul 30, 2020
290308e
Fix for #2498 (#2504)
surapuramakhil Jul 30, 2020
c12ddfe
Set max store size bytes correctly so it is used by AbstractAsynchron…
raviagarwal7 Aug 3, 2020
7486182
CI rust test fixes (#2511)
Aug 5, 2020
d62d9b2
Fixed a phthon installation bug on CircleCI (#2509)
Aug 5, 2020
cac7c76
add Easynvest to buck showcases (#2514)
Lcsmarcal Aug 6, 2020
427f770
Make Python3 the first choice of python interpreter (#2512)
Aug 6, 2020
39a6610
Fixed a python3 compatible issue (#2517)
Aug 12, 2020
ff103fc
Added application_region and application_language properties to xcode…
Lcsmarcal Aug 12, 2020
d1717fd
Added Android NDK tests (#2515)
Aug 13, 2020
a68ef0d
Saifulriza (#2523)
saifulriza Aug 17, 2020
1c601fd
Add full kotlin configurations to kotlin rule (v2) (#2526)
tyvsmith Aug 25, 2020
d9d41a5
Fixing paths that fail during project generation (#2527)
tyvsmith Aug 25, 2020
ffa062a
(Rebase) Add snapshot_images_diff_path to apple_test (#2528)
Lcsmarcal Aug 25, 2020
7273a9d
Fixes for Windows tests (#2529)
Aug 28, 2020
6ce4daa
Added Flavors to docs (#2522)
Aug 28, 2020
2c78fcb
Added a kotlin tutorial for android (#2525)
Aug 31, 2020
6a45969
Prepare release v2020.09.01 (#2532)
Sep 1, 2020
b12b77f
Added dependency to pulbishing docs (#2534)
Sep 2, 2020
ff7c4cd
Fixed CircleCI tests (#2531)
Sep 2, 2020
cd9fbc8
Upgraded ruby syntax in replease process (#2533)
Sep 2, 2020
ffd2df6
Skip flaky tests on Windows platform (#2536)
Sep 9, 2020
682b0aa
Increased a timeout in Winddows test. (#2544)
Sep 22, 2020
2ab66a9
Fixed dlang installation error (#2543)
Sep 22, 2020
e5f9062
Install python2 from archive. (#2542)
Sep 22, 2020
a103d9b
Fixed a link (#2539)
Sep 22, 2020
ae8e8fc
Added a rust tutorial (#2540)
Oct 6, 2020
32440f9
Add support for async worker processes (#2547)
mikekap Oct 13, 2020
7b8881b
Merge branch 'facebook_master' into rebase-10-2020
Oct 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
(Rebase) Add snapshot_images_diff_path to apple_test (facebook#2528)
* Add snapshot_images_diff_path to apple_test

* Fix some issues found at code review

Co-authored-by: Lucas Marçal <lucas.fernandes@easynvest.com.br>
  • Loading branch information
Lcsmarcal and Lucas Marçal authored Aug 25, 2020
commit ffa062a699a248d49b8239fe013484b45559eba5
44 changes: 26 additions & 18 deletions src/com/facebook/buck/apple/AppleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public class AppleTest extends AbstractBuildRuleWithDeclaredAndExtraDeps
private final Path testLogsPath;

private final Optional<Either<SourcePath, String>> snapshotReferenceImagesPath;
private final Optional<Either<SourcePath, String>> snapshotImagesDiffPath;

private Optional<Long> testRuleTimeoutMs;

Expand Down Expand Up @@ -216,6 +217,7 @@ public ImmutableList<TestCaseSummary> getTestCaseSummaries() {
Optional<Long> testRuleTimeoutMs,
boolean isUiTest,
Optional<Either<SourcePath, String>> snapshotReferenceImagesPath,
Optional<Either<SourcePath, String>> snapshotImagesDiffPath,
Optional<ImmutableMap<String, String>> testSpecificEnvironmentVariables,
boolean useIdb,
Path idbPath) {
Expand Down Expand Up @@ -244,6 +246,7 @@ public ImmutableList<TestCaseSummary> getTestCaseSummaries() {
this.testLogLevel = testLogLevel;
this.isUiTest = isUiTest;
this.snapshotReferenceImagesPath = snapshotReferenceImagesPath;
this.snapshotImagesDiffPath = snapshotImagesDiffPath;
this.testSpecificEnvironmentVariables = testSpecificEnvironmentVariables;
this.useIdb = useIdb;
this.idbPath = idbPath;
Expand Down Expand Up @@ -345,23 +348,8 @@ public Pair<ImmutableList<Step>, ExternalTestRunnerTestSpec> getTestCommand(
destinationSpecifierArg = defaultDestinationSpecifier;
}

Optional<String> snapshotReferenceImagesPath = Optional.empty();
if (this.snapshotReferenceImagesPath.isPresent()) {
if (this.snapshotReferenceImagesPath.get().isLeft()) {
snapshotReferenceImagesPath =
Optional.of(
buildContext
.getSourcePathResolver()
.getAbsolutePath(this.snapshotReferenceImagesPath.get().getLeft())
.toString());
} else if (this.snapshotReferenceImagesPath.get().isRight()) {
snapshotReferenceImagesPath =
Optional.of(
getProjectFilesystem()
.getPathForRelativePath(this.snapshotReferenceImagesPath.get().getRight())
.toString());
}
}
Optional<String> snapshotReferenceImagesPath = getAbsoluteSnapshotTestingArgumentPath(this.snapshotReferenceImagesPath, buildContext);
Optional<String> snapshotImagesDiffPath = getAbsoluteSnapshotTestingArgumentPath(this.snapshotImagesDiffPath, buildContext);

XctoolRunTestsStep xctoolStep =
new XctoolRunTestsStep(
Expand All @@ -384,7 +372,8 @@ public Pair<ImmutableList<Step>, ExternalTestRunnerTestSpec> getTestCommand(
Optional.of(testLogLevelEnvironmentVariable),
Optional.of(testLogLevel),
testRuleTimeoutMs,
snapshotReferenceImagesPath);
snapshotReferenceImagesPath,
snapshotImagesDiffPath);

if (useIdb) {
idbStdoutReader = Optional.of(new AppleTestIdbStdoutReader(testReportingCallback));
Expand Down Expand Up @@ -456,6 +445,25 @@ public Pair<ImmutableList<Step>, ExternalTestRunnerTestSpec> getTestCommand(
return new Pair<>(steps.build(), externalSpec.build());
}

private Optional<String> getAbsoluteSnapshotTestingArgumentPath(
Optional<Either<SourcePath, String>> snapshotTestArgument, BuildContext buildContext) {
if (snapshotTestArgument.isPresent()) {
if (snapshotTestArgument.get().isLeft()) {
return Optional.of(
buildContext
.getSourcePathResolver()
.getAbsolutePath(snapshotTestArgument.get().getLeft())
.toString());
} else if (snapshotTestArgument.get().isRight()) {
return Optional.of(
getProjectFilesystem()
.getPathForRelativePath(snapshotTestArgument.get().getRight())
.toString());
}
}
return Optional.empty();
}

static Optional<Path> extractBundlePathForBundle(
Optional<AppleBundle> bundle, SourcePathResolverAdapter sourcePathResolverAdapter) {
if (!bundle.isPresent()) {
Expand Down
5 changes: 5 additions & 0 deletions src/com/facebook/buck/apple/AppleTestDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ public BuildRule createBuildRule(
AppleDeveloperDirectoryForTestsProvider.class),
args.getIsUiTest(),
args.getSnapshotReferenceImagesPath(),
args.getSnapshotImagesDiffPath(),
appleConfig.useIdb(),
appleConfig.getIdbPath());
}
Expand Down Expand Up @@ -458,6 +459,7 @@ public BuildRule createBuildRule(
.getDefaultTestRuleTimeoutMs()),
args.getIsUiTest(),
args.getSnapshotReferenceImagesPath(),
args.getSnapshotImagesDiffPath(),
args.getEnv(),
appleConfig.useIdb(),
appleConfig.getIdbPath());
Expand Down Expand Up @@ -952,6 +954,9 @@ default boolean getIsUiTest() {
// for use with FBSnapshotTestcase, injects the path as FB_REFERENCE_IMAGE_DIR
Optional<Either<SourcePath, String>> getSnapshotReferenceImagesPath();

// for use with FBSnapshotTestcase, injects the path as IMAGE_DIFF_DIR
Optional<Either<SourcePath, String>> getSnapshotImagesDiffPath();

// Bundle related fields.
ImmutableMap<String, String> getDestinationSpecifier();

Expand Down
19 changes: 19 additions & 0 deletions src/com/facebook/buck/apple/AppleTestX.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public class AppleTestX extends AbstractBuildRuleWithDeclaredAndExtraDeps
AppleDeveloperDirectoryForTestsProvider appleDeveloperDirectoryForTestsProvider,
boolean isUiTest,
Optional<Either<SourcePath, String>> snapshotReferenceImagesPath,
Optional<Either<SourcePath, String>> snapshotImagesDiffPath,
boolean useIdb,
Path idbPath) {
super(buildTarget, projectFilesystem, params);
Expand All @@ -121,6 +122,7 @@ public class AppleTestX extends AbstractBuildRuleWithDeclaredAndExtraDeps
appleDeveloperDirectoryForTestsProvider,
isUiTest,
snapshotReferenceImagesPath,
snapshotImagesDiffPath,
useIdb,
idbPath);

Expand Down Expand Up @@ -248,6 +250,7 @@ private static class AppleConfigs implements AddsToRuleKey {
public static final String DEFAULT_DESTINATION = "default_destination";
public static final String DEVELOPER_DIRECTORY_FOR_TESTS = "developer_directory_for_tests";
public static final String SNAPSHOT_REFERENCE_IMG_PATH = "snapshot_reference_img_path";
public static final String SNAPSHOT_IMAGES_DIFF_PATH = "snapshot_images_diff_path";

private static final String UI_TEST_TARGET_APP = "ui_test_target_app";
private static final String TEST_HOST_APP = "test_host_app";
Expand All @@ -270,6 +273,7 @@ private static class AppleConfigs implements AddsToRuleKey {

@AddToRuleKey private final boolean isUiTest;
private final Optional<Either<SourcePath, String>> snapshotReferenceImagesPath;
private final Optional<Either<SourcePath, String>> snapshotImagesDiffPath;
private final boolean useIdb;
private final Path idbPath;

Expand All @@ -285,6 +289,7 @@ private AppleConfigs(
AppleDeveloperDirectoryForTestsProvider appleDeveloperDirectoryForTestsProvider,
boolean isUiTest,
Optional<Either<SourcePath, String>> snapshotReferenceImagesPath,
Optional<Either<SourcePath, String>> snapshotImagesDiffPath,
boolean useIdb,
Path idbPath) {
this.testHostApp = testHostApp;
Expand All @@ -298,6 +303,7 @@ private AppleConfigs(
this.appleDeveloperDirectoryForTestsProvider = appleDeveloperDirectoryForTestsProvider;
this.isUiTest = isUiTest;
this.snapshotReferenceImagesPath = snapshotReferenceImagesPath;
this.snapshotImagesDiffPath = snapshotImagesDiffPath;
this.useIdb = useIdb;
this.idbPath = idbPath;
}
Expand Down Expand Up @@ -341,6 +347,19 @@ private String asJson(
})
.orElse(""));

generator.writeStringField(
SNAPSHOT_IMAGES_DIFF_PATH,
snapshotImagesDiffPath
.map(
pathOrStr -> {
if (pathOrStr.isLeft()) {
return sourcePathResolver.getAbsolutePath(pathOrStr.getLeft()).toString();
}

return filesystem.getPathForRelativePath(pathOrStr.getRight()).toString();
})
.orElse(""));

generator.writeObjectField(
UI_TEST_TARGET_APP,
AppleTest.extractBundlePathForBundle(uiTestTargetApp, sourcePathResolver)
Expand Down
11 changes: 10 additions & 1 deletion src/com/facebook/buck/apple/XctoolRunTestsStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class XctoolRunTestsStep implements Step {
Executors.newSingleThreadScheduledExecutor();
private static final String XCTOOL_ENV_VARIABLE_PREFIX = "XCTOOL_TEST_ENV_";
private static final String FB_REFERENCE_IMAGE_DIR = "FB_REFERENCE_IMAGE_DIR";
private static final String IMAGE_DIFF_DIR = "IMAGE_DIFF_DIR";

private final ProjectFilesystem filesystem;

Expand All @@ -96,6 +97,7 @@ public interface StdoutReadingCallback {
private final Optional<String> logLevel;
private final Optional<Long> timeoutInMs;
private final Optional<String> snapshotReferenceImagesPath;
private final Optional<String> snapshotImagesDiffPath;
private final Map<Path, Map<Path, Path>> appTestPathsToTestHostAppPathsToTestTargetAppPaths;
private final boolean isUsingXCodeBuildTool;

Expand Down Expand Up @@ -172,7 +174,8 @@ public XctoolRunTestsStep(
Optional<String> logLevelEnvironmentVariable,
Optional<String> logLevel,
Optional<Long> timeoutInMs,
Optional<String> snapshotReferenceImagesPath) {
Optional<String> snapshotReferenceImagesPath,
Optional<String> snapshotImagesDiffPath) {
Preconditions.checkArgument(
!(logicTestBundlePaths.isEmpty()
&& appTestBundleToHostAppPaths.isEmpty()
Expand Down Expand Up @@ -207,6 +210,7 @@ public XctoolRunTestsStep(
this.logLevel = logLevel;
this.timeoutInMs = timeoutInMs;
this.snapshotReferenceImagesPath = snapshotReferenceImagesPath;
this.snapshotImagesDiffPath = snapshotImagesDiffPath;
// Super hacky, but xcodebuildtool is an alternative wrapper
// around xcodebuild and forwarding the -f arguments only makes
// sense in that context.
Expand Down Expand Up @@ -240,6 +244,11 @@ public ImmutableMap<String, String> getEnv(ExecutionContext context) {
XCTOOL_ENV_VARIABLE_PREFIX + FB_REFERENCE_IMAGE_DIR, snapshotReferenceImagesPath.get());
}

if (snapshotImagesDiffPath.isPresent()) {
environment.put(
XCTOOL_ENV_VARIABLE_PREFIX + IMAGE_DIFF_DIR, snapshotImagesDiffPath.get());
}

environment.putAll(this.environmentOverrides);
return ImmutableMap.copyOf(environment);
}
Expand Down
27 changes: 20 additions & 7 deletions test/com/facebook/buck/apple/XctoolRunTestsStepTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void xctoolCommandWithOnlyLogicTests() throws Exception {
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty());
ProcessExecutorParams xctoolParams =
ProcessExecutorParams.builder()
Expand Down Expand Up @@ -128,6 +129,7 @@ public void xctoolCommandWhichFailsPrintsStderrToConsole() throws Exception {
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty());
ProcessExecutorParams xctoolParams =
ProcessExecutorParams.builder()
Expand Down Expand Up @@ -185,6 +187,7 @@ public void xctoolCommandWithOnlyAppTests() throws Exception {
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty());

ProcessExecutorParams xctoolParams =
Expand Down Expand Up @@ -242,6 +245,7 @@ public void xctoolCommandWithOnlyUITests() throws Exception {
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty());

ProcessExecutorParams xctoolParams =
Expand Down Expand Up @@ -297,6 +301,7 @@ public void xctoolCommandWithAppAndLogicTests() throws Exception {
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty());

ProcessExecutorParams xctoolParams =
Expand Down Expand Up @@ -354,6 +359,7 @@ public void xctoolCommandWhichReturnsExitCode1DoesNotFailStep() throws Exception
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty());

ProcessExecutorParams xctoolParams =
Expand Down Expand Up @@ -409,6 +415,7 @@ public void xctoolCommandWhichReturnsExitCode400FailsStep() throws Exception {
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty());

ProcessExecutorParams xctoolParams =
Expand Down Expand Up @@ -463,6 +470,7 @@ public void xctoolCommandWithTestSelectorFiltersTests() throws Exception {
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty());

ProcessExecutorParams xctoolListOnlyParams =
Expand Down Expand Up @@ -554,6 +562,7 @@ public void xctoolCommandWithTestSelectorFailsIfListTestsOnlyFails() throws Exce
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty());

ProcessExecutorParams xctoolListOnlyParams =
Expand Down Expand Up @@ -620,6 +629,7 @@ public void xctoolCommandWithTestSelectorMatchingNothingDoesNotFail() throws Exc
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty());
ProcessExecutorParams xctoolListOnlyParams =
ProcessExecutorParams.builder()
Expand Down Expand Up @@ -682,7 +692,8 @@ public void testDirectoryAndLevelPassedInEnvironment() throws Exception {
Optional.of("TEST_LOG_LEVEL"),
Optional.of("verbose"),
Optional.empty(),
Optional.of("/path/to/snapshotimages"));
Optional.of("/path/to/snapshotimages"),
Optional.of("/path/to/snapshotdiffimages"));
ProcessExecutorParams xctoolParams =
ProcessExecutorParams.builder()
.setCommand(
Expand All @@ -698,12 +709,14 @@ public void testDirectoryAndLevelPassedInEnvironment() throws Exception {
// This is the important part of this test: only if the process is executed
// with a matching environment will the test pass.
.setEnvironment(
ImmutableMap.of(
"DEVELOPER_DIR", "/path/to/developer/dir",
"XCTOOL_TEST_ENV_TEST_LOG_PATH", "/path/to/test-logs",
"XCTOOL_TEST_ENV_TEST_LOG_LEVEL", "verbose",
"XCTOOL_TEST_ENV_FB_REFERENCE_IMAGE_DIR", "/path/to/snapshotimages",
"LLVM_PROFILE_FILE", "/tmp/some.profraw"))
ImmutableMap.<String, String>builder()
.put("DEVELOPER_DIR", "/path/to/developer/dir")
.put("XCTOOL_TEST_ENV_TEST_LOG_PATH", "/path/to/test-logs")
.put("XCTOOL_TEST_ENV_TEST_LOG_LEVEL", "verbose")
.put("XCTOOL_TEST_ENV_FB_REFERENCE_IMAGE_DIR", "/path/to/snapshotimages")
.put("XCTOOL_TEST_ENV_IMAGE_DIFF_DIR", "/path/to/snapshotdiffimages")
.put("LLVM_PROFILE_FILE", "/tmp/some.profraw")
.build())
.setDirectory(projectFilesystem.getRootPath().getPath())
.setRedirectOutput(ProcessBuilder.Redirect.PIPE)
.build();
Expand Down