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

add Watchman-enabled functional tests to GitHub Actions CI #436

Merged
merged 5 commits into from
Oct 2, 2020

Conversation

chrisd8088
Copy link
Collaborator

@chrisd8088 chrisd8088 commented Sep 18, 2020

We add Watchman-enabled runs of the functional test suite on all GitHub Actions runners for all three platforms.

The code changes in this PR are primarily the result of needing to work around some inconsistent behaviour from Watchman when running on macOS Catalina, which is used by the Actions macOS runners. As described in facebook/watchman#858, creating a hard link to an existing inode from inside the watched Git working tree may not be reported to Git as a new file if the inode's other, existing "source" path (as passed to link(2)) resides outside the watched directory.

This problem is tickled by our functional test suite because the MoveFileFromOutsideRepoToInsideRepoAndAdd() test relies on the System.IO.File.Move() method, which on Unix/POSIX systems like macOS, actually performs a link(2) call rather than rename(2).

While the underlying problem is outside of Scalar's control, we can work around it by using rename(2) directly to move files in the SystemIORunner test helper class.

This particular intermittent but persistent test failure also exposed another, minor issue in the ValidateGitCommand() utility method, which passed its actual and expected string values to the LinesShouldMatch() method in the reverse order from what was intended, so we swap them here.

Debugging these issues also turned up some minor typos in the error messages output from the run clone command when a repository can not be initialized, so those are fixed here also.

Finally, to enable the functional test suite to run in CI on macOS, we add to the Mac version of the RunFunctionalTests.sh script so that like the Linux and Windows versions it copies the Scalar binary into the functional test binary's build location so it can be located by the functional test program.

@chrisd8088 chrisd8088 force-pushed the actions-watchman branch 3 times, most recently from b1828ae to 604bbcd Compare September 22, 2020 22:17
In commit cbf6f82 in PR microsoft#349 the
ValidateGitCommand() helper function was refactored slightly to use
a new LinesShouldMatch() function; however, the inputs were
accidentally reversed, so here we correct the order of the "expected"
and "actual" string arguments passed to LinesShouldMatch().
On macOS and Linux platforms, we use rename(2) directly when
moving files with the SystemIORunner's MoveFile() method, instead
of using .NET Core's File.Move() method.  The latter actually
implements most file moves using a combination of link(2)
followed by unlink(2) on the source file.

The consequence of using link() instead of rename() is that on
recent versions of macOS, when running with Watchman, file
creation events may not be delivered by Watchman to Git when a
new hard link within the Git working tree is created if that
link points to an existing inode outside of the watched tree.
This in turn causes the MoveFileFromOutsideRepoToInsideRepoAndAdd()
test in GitCommandsTests to fail intermittently.

We can work around the problem by utilizing rename() directly, which
also parallels the behaviour of SystemIORunner's RenameDirectory()
method, added in commit 0a517fa.

See also:

facebook/watchman#858
https://github.com/dotnet/runtime/blob/94515f7bd34aabaab5ba6a1316f4a881cbf2370c/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs#L142-L144
We replicate for the Mac version of RunFunctionalTests.sh the
changes made in commit da2b813
for the Linux version, which permit manual runs of the functional
test suite after rebuilding the binaries by copying them into
the directory where the Scalar.FunctionalTests binary was published,
unless the --test-scalar-on-path option was given to the script.
@chrisd8088 chrisd8088 changed the title [WIP] [DO NOT MERGE] add Watchman to Actions CI add Watchman-enabled functional tests to GitHub Actions CI Sep 30, 2020
@chrisd8088 chrisd8088 marked this pull request as ready for review September 30, 2020 07:49
Copy link
Contributor

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding these fixups and getting these builds running!

@chrisd8088
Copy link
Collaborator Author

Thanks @derrickstolee for the review! It looks like you may need to temporarily disable the required Actions runs so we can merge this, as the PR is waiting on the older no-Watchman Actions jobs and those, of course, aren't running on this PR.

@derrickstolee derrickstolee merged commit 9590ae7 into microsoft:main Oct 2, 2020
@chrisd8088 chrisd8088 deleted the actions-watchman branch October 2, 2020 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants