Skip to content

Commit

Permalink
Fix buffering functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
tbidne committed Mar 13, 2024
1 parent 307e9d2 commit 08f1058
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 31 deletions.
49 changes: 25 additions & 24 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- fix-tests

pull_request:
branches:
Expand Down Expand Up @@ -37,33 +38,33 @@ jobs:
- name: Compile
run: cabal build lib:shrun

- name: Unit Tests
run: cabal test unit --test-options '--hedgehog-tests 100000'
# - name: Unit Tests
# run: cabal test unit --test-options '--hedgehog-tests 100000'

- name: Integration Tests
run: cabal test integration
# - name: Integration Tests
# run: cabal test integration

- name: Functional Tests
run: cabal test functional

- name: Benchmarks
if: ${{ matrix.os == 'ubuntu-latest' }}
id: bench
run: |
cabal bench --benchmark-options '
--csv benchmarks/${{ matrix.os }}_${{ matrix.ghc }}_ci.csv
--svg benchmarks/${{ matrix.os }}_${{ matrix.ghc }}_ci.svg
--baseline benchmarks/baseline_${{ matrix.os }}_${{ matrix.ghc }}_ci.csv
--fail-if-slower 50
--fail-if-faster 50'
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.bench.conclusion == 'failure' }}
with:
name: build-artifacts
path: |
benchmarks/${{ matrix.os }}_${{ matrix.ghc }}_ci.csv
benchmarks/${{ matrix.os }}_${{ matrix.ghc }}_ci.svg
run: cabal test functional --test-options '-p Buffering'

# - name: Benchmarks
# if: ${{ matrix.os == 'ubuntu-latest' }}
# id: bench
# run: |
# cabal bench --benchmark-options '
# --csv benchmarks/${{ matrix.os }}_${{ matrix.ghc }}_ci.csv
# --svg benchmarks/${{ matrix.os }}_${{ matrix.ghc }}_ci.svg
# --baseline benchmarks/baseline_${{ matrix.os }}_${{ matrix.ghc }}_ci.csv
# --fail-if-slower 50
# --fail-if-faster 50'

# - uses: actions/upload-artifact@v3
# if: ${{ failure() && steps.bench.conclusion == 'failure' }}
# with:
# name: build-artifacts
# path: |
# benchmarks/${{ matrix.os }}_${{ matrix.ghc }}_ci.csv
# benchmarks/${{ matrix.os }}_${{ matrix.ghc }}_ci.svg
nix:
strategy:
fail-fast: false
Expand Down
22 changes: 15 additions & 7 deletions test/functional/Functional/Buffering.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,35 @@ logsNoBuffer =

assertLogsEq expecteds results
where
-- NOTE: [Bash brace loop interpolation]
--
-- The bash loop brace syntax "for i in {0..3}" does not seem to
-- interpolate correctly with nix or on CI. The brace is interpreted
-- literally i.e. {0..3}. The manual listing of indices appears to work,
-- however
args =
[ "--cmd-log",
"--cmd-log-strip-control=all",
"for i in {0..3}; do echo $i; sleep 1.5; done"
"--cmd-name-trunc=15",
"--no-config",
"for i in 0 1 2 3; do echo \"$i\"; sleep 1.5; done"
]

-- To test that the logs are correctly streamed, we check that actual
-- order of logs against the timing logs. This is a bit hacky, but the
-- sleep of 1.5 makes this fairly reliable.
expecteds =
[ withCommandPrefix "for i in {0...." "Starting...",
withCommandPrefix "for i in {0...." "0",
[ withCommandPrefix "for i in 0 1..." "Starting...",
withCommandPrefix "for i in 0 1..." "0",
withTimerPrefix "1 second",
withCommandPrefix "for i in {0...." "1",
withCommandPrefix "for i in 0 1..." "1",
withTimerPrefix "2 seconds",
withCommandPrefix "for i in {0...." "2",
withCommandPrefix "for i in 0 1..." "2",
withTimerPrefix "3 seconds",
withTimerPrefix "4 seconds",
withCommandPrefix "for i in {0...." "3",
withCommandPrefix "for i in 0 1..." "3",
withTimerPrefix "5 seconds",
withSuccessPrefix "for i in {0...." <> "6 seconds",
withSuccessPrefix "for i in 0 1..." <> "6 seconds",
withFinishedPrefix "6 seconds"
]

Expand Down

0 comments on commit 08f1058

Please sign in to comment.