microsoft / scalar

Scalar: A set of tools and extensions for Git to allow very large monorepos to run on Git without a virtualization layer
MIT License
1.39k stars 63 forks source link

Linux: functional test and XDG configuration support #422

Closed chrisd8088 closed 4 years ago

chrisd8088 commented 4 years ago

This PR adds functional test scripts for Linux, adjusts a number of Mac-specific syscall wrappers and FileSystemRunners to be either POSIX-generic or have Linux-specific equivalents, makes some minor updates to align Linux packaging details with other platforms, and refactors the setup of the cache, config, and data directories on POSIX platforms to support (in the Linux case only) the XDG Base Directory Specification.

It should be possible to review either commit-by-commit or as a single set of changes; the former might be slightly easier, though.


The (partial) support for the XDG specification comprises the majority of the changes in this PR, and is motivated by the fact that the functional tests depend on the value returned by GetDataRootForScalarImplementation() in LinuxPlatform.Shared.cs, and we currently return the value of either a custom environment variable or a default of /var/run/scalar, which may not be accessible to a non-root user and thus cause the tests to fail. While we could return a simple $HOME/.scalar response, following the XDG specification allows us to make parallel changes so that on Linux we utilize the relevant locations for all three types of files, which by default will be:

Although our implementation is not 100% complete (yet), it does permit runs of the functional test suite on Linux, and moreover allows for runs which avoid polluting these locations by defining the relevant $XDG_{CACHE,CONFIG,DATA}_HOME environment variables.

What remains to be done, if desired, is described in a comment in LinuxPlatform.cs as well as the description for commit 9e859dfd28e5e0478fa1a7de9dbfe865129062b9:

Note that on Linux we do not yet create missing directories with
a 0700 mode, as specified by the XDG standard, and we also do not
check system-wide locations from either the $XDG_{CONFIG,DATA}_DIRS
environment variables or the defaults for them.  The latter
might require more extensive refactoring to distinguish cases
in which user-specific data or configurations are to be written,
as these should possibly not be written to system-wide files.

We also slightly refactor the CloneTests.CloneWithDefaultLocalCacheLocation() functional test, which runs on POSIX platforms only, so as to ensure it passes on Linux regardless of whether the $XDG_CACHE_HOME environment variable is set or not. This change depends on the introduction of a ScalarTestConfig.DefaultLocalCacheRoot accessor which returns the appropriate cache path on each platform.

chrisd8088 commented 4 years ago

I broke this off from #431 because I didn't want to have too many notes in each PR's description; they're fairly long as it is independently. And this one was already getting a bit long in the tooth, what with the XDG work. Anyway, that was my thinking on that ... mostly so the merge commit notes don't have to be too long.