Skip to content

Commit

Permalink
Test setting symlink type via CYGWIN env var
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-turney committed Nov 26, 2022
1 parent 49f298a commit d3ac917
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 6 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
with:
install-dir: "${{ matrix.install-dir }}"

- name: Check working directory
- name: Check install directory
run: |
if [[ "$(cygpath -aw /)" == '${{ matrix.install-dir }}' ]]; then
echo "Installed in $(cygpath -aw /)"
Expand All @@ -133,6 +133,31 @@ jobs:
env:
SHELLOPTS: igncr

symlink-test:
runs-on: windows-latest
name: 'Check symlink type control'

strategy:
matrix:
include:
- symlink-type: native
- symlink-type: sys
- symlink-type: wsl

env:
CYGWIN: winsymlinks:${{ matrix.symlink-type }}

steps:
- run: git config --global core.autocrlf input

- uses: actions/checkout@v2

- name: Install Cygwin
uses: ./

- name: Check symlink
run: bash tests/symlink.sh

time-machine:
runs-on: windows-latest
strategy:
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@ or,
Symlinks
--------

Unfortunately, Cygwin's `setup` doesn't (currently) honour
`CYGWIN=winsymlinks:native` or offer an option to control the kind of symlinks
created, so some executables (e.g. `python`) are created as Cygwin-style
symlinks. Since CMD and PowerShell don't understand those symlinks, you cannot
run those executables directly in a `run:` in your workflow. Execute them via
Cygwin's `setup` creates Cygwin-style symlinks by default, and some
executables (e.g. `python`) are symlinks.

Since CMD and PowerShell don't understand those symlinks, you cannot run
those executables directly in a `run:` in your workflow. Execute them via
`bash` or `env` instead.

Alternatively, putting e.g. `CYGWIN=winsymlinks:native` into the workflow's
environment works, since setup now honours that.

Mirrors and signatures
----------------------

Expand Down
27 changes: 27 additions & 0 deletions tests/symlink.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/bash

TEST_FILE="/usr/bin/apropos"
echo "cygpath -w ${TEST_FILE} returns $(cygpath -w ${TEST_FILE})"
# don't convert using cygpath -w, as that canonicalizes symlinks ?!?
TEST_FILE_W="C:\cygwin\bin\apropos"

# check the symlink we're going to do checks on exists
if [ ! -L ${TEST_FILE} ]; then
echo "This test assumes ${TEST_FILE} exists and is a symlink"
exit 1
fi

# check the symlink was created in the way expected
case ${CYGWIN} in
*sys*)
cmd /c "dir /AS ${TEST_FILE_W}" | grep "21"
;;

*native*)
cmd /c "dir /AL ${TEST_FILE_W}" | grep "<SYMLINK>"
;;

*wsl*)
fsutil reparsepoint query ${TEST_FILE_W} | grep "0xa000001d"
;;
esac

0 comments on commit d3ac917

Please sign in to comment.