Skip to content

Commit 392c60c

Browse files
committed
Merge pull request #371 from dscho/run-scalar-functional-tests-and-fix-built-in-fsmonitor
Fix the built-in FSMonitor, and run Scalar's Functional Tests as part of the automated builds
2 parents 0bdfb29 + e2aaf1a commit 392c60c

File tree

2 files changed

+224
-4
lines changed

2 files changed

+224
-4
lines changed
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
name: Scalar Functional Tests
2+
3+
env:
4+
SCALAR_REPOSITORY: derrickstolee/scalar
5+
SCALAR_REF: test-scalar-in-c
6+
DEBUG_WITH_TMATE: false
7+
SCALAR_TEST_SKIP_VSTS_INFO: true
8+
9+
on:
10+
push:
11+
branches: [ vfs-* ]
12+
pull_request:
13+
branches: [ vfs-* ]
14+
15+
jobs:
16+
scalar:
17+
name: "Scalar Functional Tests"
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
# Order by runtime (in descending order)
23+
os: [windows-2019, macos-10.15, ubuntu-16.04, ubuntu-18.04, ubuntu-20.04]
24+
# Scalar.NET used to be tested using `features: [false, experimental]`
25+
# But currently, Scalar/C ignores `feature.scalar` altogether, so let's
26+
# save some electrons and run only one of them...
27+
features: [ignored]
28+
exclude:
29+
# The built-in FSMonitor is not (yet) supported on Linux
30+
- os: ubuntu-16.04
31+
features: experimental
32+
- os: ubuntu-18.04
33+
features: experimental
34+
- os: ubuntu-20.04
35+
features: experimental
36+
runs-on: ${{ matrix.os }}
37+
38+
env:
39+
BUILD_FRAGMENT: bin/Release/netcoreapp3.1
40+
41+
steps:
42+
- name: Check out Git's source code
43+
uses: actions/checkout@v2
44+
45+
- name: Setup build tools on Windows
46+
if: runner.os == 'Windows'
47+
uses: git-for-windows/setup-git-for-windows-sdk@v1
48+
49+
- name: Provide a minimal `install` on Windows
50+
if: runner.os == 'Windows'
51+
shell: bash
52+
run: |
53+
test -x /usr/bin/install ||
54+
tr % '\t' >/usr/bin/install <<-\EOF
55+
#!/bin/sh
56+
57+
cmd=cp
58+
while test $# != 0
59+
do
60+
%case "$1" in
61+
%-d) cmd="mkdir -p";;
62+
%-m) shift;; # ignore mode
63+
%*) break;;
64+
%esac
65+
%shift
66+
done
67+
68+
exec $cmd "$@"
69+
EOF
70+
71+
- name: Install build dependencies for Git (Linux)
72+
if: runner.os == 'Linux'
73+
run: |
74+
sudo apt-get update
75+
sudo apt-get -q -y install libssl-dev libcurl4-openssl-dev gettext
76+
77+
- name: Build and install Git
78+
shell: bash
79+
env:
80+
NO_TCLTK: Yup
81+
run: |
82+
# We do require a VFS version
83+
def_ver="$(sed -n 's/DEF_VER=\(.*vfs.*\)/\1/p' GIT-VERSION-GEN)"
84+
test -n "$def_ver"
85+
86+
# Ensure that `git version` reflects DEF_VER
87+
case "$(git describe --match "v[0-9]*vfs*" HEAD)" in
88+
${def_ver%%.vfs.*}.vfs.*) ;; # okay, we can use this
89+
*) git -c user.name=ci -c user.email=ci@github tag -m for-testing ${def_ver}.NNN.g$(git rev-parse --short HEAD);;
90+
esac
91+
92+
SUDO=
93+
extra=
94+
case "${{ runner.os }}" in
95+
Windows)
96+
extra=DESTDIR=/c/Progra~1/Git
97+
cygpath -aw "/c/Program Files/Git/cmd" >>$GITHUB_PATH
98+
;;
99+
Linux)
100+
SUDO=sudo
101+
extra=prefix=/usr
102+
;;
103+
macOS)
104+
SUDO=sudo
105+
extra=prefix=/usr/local
106+
;;
107+
esac
108+
109+
$SUDO make -j5 INCLUDE_SCALAR=AbsolutelyYes $extra install
110+
111+
- name: Ensure that we use the built Git and Scalar
112+
shell: bash
113+
run: |
114+
type -p git
115+
git version
116+
case "$(git version)" in *.vfs.*) echo Good;; *) exit 1;; esac
117+
type -p scalar
118+
scalar version
119+
case "$(scalar version 2>&1)" in *.vfs.*) echo Good;; *) exit 1;; esac
120+
121+
- name: Check out Scalar's source code
122+
uses: actions/checkout@v2
123+
with:
124+
fetch-depth: 0 # Indicate full history so Nerdbank.GitVersioning works.
125+
path: scalar
126+
repository: ${{ env.SCALAR_REPOSITORY }}
127+
ref: ${{ env.SCALAR_REF }}
128+
129+
- name: Setup .NET Core
130+
uses: actions/setup-dotnet@v1
131+
with:
132+
dotnet-version: 3.1.302
133+
134+
- name: Install dependencies
135+
run: dotnet restore
136+
working-directory: scalar
137+
env:
138+
DOTNET_NOLOGO: 1
139+
140+
- name: Build
141+
working-directory: scalar
142+
run: dotnet build --configuration Release --no-restore -p:UseAppHost=true # Force generation of executable on macOS.
143+
144+
- name: Setup platform (Linux)
145+
if: runner.os == 'Linux'
146+
run: |
147+
echo "BUILD_PLATFORM=${{ runner.os }}" >>$GITHUB_ENV
148+
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.features }}" >>$GITHUB_ENV
149+
150+
- name: Setup platform (Mac)
151+
if: runner.os == 'macOS'
152+
run: |
153+
echo 'BUILD_PLATFORM=Mac' >>$GITHUB_ENV
154+
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.features }}" >>$GITHUB_ENV
155+
156+
- name: Setup platform (Windows)
157+
if: runner.os == 'Windows'
158+
run: |
159+
echo "BUILD_PLATFORM=${{ runner.os }}" >>$env:GITHUB_ENV
160+
echo 'BUILD_FILE_EXT=.exe' >>$env:GITHUB_ENV
161+
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.features }}" >>$env:GITHUB_ENV
162+
163+
- name: Configure feature.scalar
164+
run: git config --global feature.scalar ${{ matrix.features }}
165+
166+
- id: functional_test
167+
name: Functional test
168+
timeout-minutes: 60
169+
working-directory: scalar
170+
shell: bash
171+
run: |
172+
export GIT_TRACE2_EVENT="$PWD/$TRACE2_BASENAME/Event"
173+
export GIT_TRACE2_PERF="$PWD/$TRACE2_BASENAME/Perf"
174+
export GIT_TRACE2_EVENT_BRIEF=true
175+
export GIT_TRACE2_PERF_BRIEF=true
176+
mkdir -p "$TRACE2_BASENAME"
177+
mkdir -p "$TRACE2_BASENAME/Event"
178+
mkdir -p "$TRACE2_BASENAME/Perf"
179+
git version --build-options
180+
cd ../out
181+
Scalar.FunctionalTests/$BUILD_FRAGMENT/Scalar.FunctionalTests$BUILD_FILE_EXT --test-scalar-on-path --test-git-on-path --timeout=300000 --full-suite
182+
183+
- name: Force-stop FSMonitor daemons and Git processes (Windows)
184+
if: runner.os == 'Windows' && (success() || failure())
185+
shell: bash
186+
run: |
187+
set -x
188+
wmic process get CommandLine,ExecutablePath,HandleCount,Name,ParentProcessID,ProcessID
189+
wmic process where "CommandLine Like '%fsmonitor--daemon %run'" delete
190+
wmic process where "ExecutablePath Like '%git.exe'" delete
191+
192+
- id: trace2_zip_unix
193+
if: runner.os != 'Windows' && ( success() || failure() ) && ( steps.functional_test.conclusion == 'success' || steps.functional_test.conclusion == 'failure' )
194+
name: Zip Trace2 Logs (Unix)
195+
shell: bash
196+
working-directory: scalar
197+
run: zip -q -r $TRACE2_BASENAME.zip $TRACE2_BASENAME/
198+
199+
- id: trace2_zip_windows
200+
if: runner.os == 'Windows' && ( success() || failure() ) && ( steps.functional_test.conclusion == 'success' || steps.functional_test.conclusion == 'failure' )
201+
name: Zip Trace2 Logs (Windows)
202+
working-directory: scalar
203+
run: Compress-Archive -DestinationPath ${{ env.TRACE2_BASENAME }}.zip -Path ${{ env.TRACE2_BASENAME }}
204+
205+
- name: Archive Trace2 Logs
206+
if: ( success() || failure() ) && ( steps.trace2_zip_unix.conclusion == 'success' || steps.trace2_zip_windows.conclusion == 'success' )
207+
uses: actions/upload-artifact@v2
208+
with:
209+
name: ${{ env.TRACE2_BASENAME }}.zip
210+
path: scalar/${{ env.TRACE2_BASENAME }}.zip
211+
retention-days: 3
212+
213+
# The GitHub Action `action-tmate` allows developers to connect to the running agent
214+
# using SSH (it will be a `tmux` session; on Windows agents it will be inside the MSYS2
215+
# environment in `C:\msys64`, therefore it can be slightly tricky to interact with
216+
# Git for Windows, which runs a slightly incompatible MSYS2 runtime).
217+
- name: action-tmate
218+
if: env.DEBUG_WITH_TMATE == 'true' && failure()
219+
uses: mxschmitt/action-tmate@v3
220+
with:
221+
limit-access-to-actor: true

fsmonitor.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,9 @@ void refresh_fsmonitor(struct index_state *istate)
293293
trace_printf_key(&trace_fsmonitor, "refresh fsmonitor");
294294

295295
if (fsm_mode == FSMONITOR_MODE_IPC) {
296-
query_success = !fsmonitor_ipc__send_query(
297-
istate->fsmonitor_last_update ?
298-
istate->fsmonitor_last_update : "builtin:fake",
299-
&query_result);
296+
query_success = istate->fsmonitor_last_update &&
297+
!fsmonitor_ipc__send_query(istate->fsmonitor_last_update,
298+
&query_result);
300299
if (query_success) {
301300
/*
302301
* The response contains a series of nul terminated

0 commit comments

Comments
 (0)