Skip to content

Commit

Permalink
Don't write log messages to stdout (#3159)
Browse files Browse the repository at this point in the history
The "Cloning (...)" message was written to stdout which messed up
markdown generation.
  • Loading branch information
lukaszcz authored Nov 11, 2024
1 parent fc0d5a3 commit 76af212
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/Juvix/Data/Effect/Log.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ runLogIO ::
Sem (Log ': r) a ->
Sem r a
runLogIO sem = do
liftIO (hSetBuffering stdout LineBuffering)
liftIO (hSetBuffering stderr LineBuffering)
interpret
( \case
Log txt -> putStrLn txt
Log txt -> hPutStrLn stderr txt
)
sem

Expand Down
31 changes: 24 additions & 7 deletions tests/smoke/Commands/compile-dependencies-package-juvix.smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ tests:
./HelloWorld
stdout:
contains: Hello from dep
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-success-then-offline
Expand Down Expand Up @@ -131,6 +133,8 @@ tests:
./HelloWorld
stdout:
contains: Hello from dep
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-fetch-new-commits
Expand Down Expand Up @@ -228,6 +232,8 @@ tests:
./HelloWorld
stdout:
contains: This is from the second commit
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-lockfile
Expand Down Expand Up @@ -374,6 +380,8 @@ tests:
./HelloWorld
stdout:
contains: "Hello from dep1\nHello from dep2"
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-uses-generated-lockfile
Expand Down Expand Up @@ -454,6 +462,8 @@ tests:
./HelloWorld
stdout:
contains: Hello from dep
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-uses-generated-lockfile-update
Expand Down Expand Up @@ -552,6 +562,8 @@ tests:
./HelloWorld
stdout:
contains: Hello from commit 2
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-nested-lockfile
Expand Down Expand Up @@ -670,6 +682,8 @@ tests:
./HelloWorld
stdout:
contains: "Hello from dep1\nHello from dep2"
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-update-ref-offline
Expand Down Expand Up @@ -770,6 +784,8 @@ tests:
./HelloWorld
stdout:
contains: This is from the second commit
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-invalid-ref
Expand Down Expand Up @@ -826,10 +842,10 @@ tests:
# compile project
juvix --log-level error compile native HelloWorld.juvix
stdout:
contains: ""
stderr:
contains: invalid-ref
stdout:
contains: Cloning
exit-status: 1

- name: git-dependencies-invalid-url
Expand Down Expand Up @@ -871,10 +887,10 @@ tests:
# compile project
juvix --log-level error compile native HelloWorld.juvix
stdout:
contains: ""
stderr:
contains: Error
stdout:
contains: Cloning
exit-status: 1

- name: git-dependencies-offline
Expand Down Expand Up @@ -992,10 +1008,10 @@ tests:
# compile project
juvix --log-level error compile native HelloWorld.juvix
stdout:
contains: ""
stderr:
contains: juvix clean
stdout:
contains: Cloning
exit-status: 1

- name: git-dependencies-duplicate-names
Expand Down Expand Up @@ -1106,7 +1122,8 @@ tests:
# compile project
juvix --log-level error compile native HelloWorld.juvix
stderr: ""
stdout:
contains: ""
stderr:
contains: Cloning
exit-status: 0
37 changes: 28 additions & 9 deletions tests/smoke/Commands/compile-dependencies.smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ tests:
./HelloWorld
stdout:
contains: Hello from dep
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-success-then-offline
Expand Down Expand Up @@ -127,6 +129,8 @@ tests:
./HelloWorld
stdout:
contains: Hello from dep
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-fetch-new-commits
Expand Down Expand Up @@ -219,6 +223,8 @@ tests:
./HelloWorld
stdout:
contains: This is from the second commit
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-lockfile
Expand Down Expand Up @@ -359,6 +365,8 @@ tests:
./HelloWorld
stdout:
contains: "Hello from dep1\nHello from dep2"
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-uses-generated-lockfile
Expand Down Expand Up @@ -437,6 +445,8 @@ tests:
./HelloWorld
stdout:
contains: Hello from dep
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-uses-generated-lockfile-update
Expand Down Expand Up @@ -530,6 +540,8 @@ tests:
./HelloWorld
stdout:
contains: Hello from commit 2
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-nested-lockfile
Expand Down Expand Up @@ -641,6 +653,8 @@ tests:
./HelloWorld
stdout:
contains: "Hello from dep1\nHello from dep2"
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-update-ref-offline
Expand Down Expand Up @@ -736,6 +750,8 @@ tests:
./HelloWorld
stdout:
contains: This is from the second commit
stderr:
contains: ""
exit-status: 0

- name: git-dependencies-invalid-ref
Expand Down Expand Up @@ -790,10 +806,10 @@ tests:
# compile project
juvix --log-level error compile native HelloWorld.juvix
stdout:
contains: ""
stderr:
contains: invalid-ref
stdout:
contains: Cloning
exit-status: 1

- name: git-dependencies-invalid-url
Expand Down Expand Up @@ -833,10 +849,10 @@ tests:
# compile project
juvix --log-level error compile native HelloWorld.juvix
stdout:
contains: ""
stderr:
contains: Error
stdout:
contains: Cloning
exit-status: 1

- name: git-dependencies-offline
Expand Down Expand Up @@ -876,9 +892,10 @@ tests:
# compile project
juvix --log-level error --offline compile native HelloWorld.juvix
stdout:
contains: ""
stderr:
contains: Failed to obtain remote dependencies
stdout:
matches:
# compile should not attempt to clone the dependency
regex: |-
Expand Down Expand Up @@ -950,10 +967,10 @@ tests:
# compile project
juvix --log-level error compile native HelloWorld.juvix
stdout:
contains: ""
stderr:
contains: juvix clean
stdout:
contains: Cloning
exit-status: 1

- name: git-dependencies-duplicate-names
Expand Down Expand Up @@ -1077,7 +1094,8 @@ tests:
juvix --log-level error compile native HelloWorld.juvix
./HelloWorld
stderr: ""
stderr:
contains: ""
stdout:
matches:
regex: "Hello from dep\n(.*?)Hello from commit2"
Expand Down Expand Up @@ -1145,7 +1163,8 @@ tests:
# compile project
juvix --log-level error compile native HelloWorld.juvix
stderr: ""
stdout:
contains: ""
stderr:
contains: Cloning
exit-status: 0
6 changes: 3 additions & 3 deletions tests/smoke/Commands/typecheck.smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tests:
- juvix
- typecheck
stderr:
equals: "Well done! It type checks\n"
contains: "Well done! It type checks\n"
exit-status: 0

- name: flag-help-shows-juvix-file-for-autocompletion
Expand All @@ -25,7 +25,7 @@ tests:
args:
- positive/Internal/Simple.juvix
stderr:
equals: "Well done! It type checks\n"
contains: "Well done! It type checks\n"
exit-status: 0

- name: flag-only-errors
Expand Down Expand Up @@ -82,7 +82,7 @@ tests:
echo 'module foo;' > foo.juvix
juvix typecheck foo.juvix
stderr:
equals: "Well done! It type checks\n"
contains: "Well done! It type checks\n"
exit-status: 0

- name: typecheck-package-description
Expand Down
10 changes: 5 additions & 5 deletions tests/smoke/Commands/version-help-doctor.smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tests:
regex: |-
^(\d+)((\.{1}\d+)*)(\.{0})$
- name: cli-flag-help
- name: cli-flag-help
command:
- juvix
- --help
Expand All @@ -35,7 +35,7 @@ tests:
- doctor
- --offline
exit-status: 0
stdout: |
stderr: |
> Checking for clang...
> Checking clang version...
> Checking for wasm-ld...
Expand All @@ -52,7 +52,7 @@ tests:
unset JUVIX_LLVM_DIST_PATH
juvix doctor --verbose --offline
exit-status: 0
stdout:
stderr:
matches:
regex: |-
Found clang(.*?)using system PATH
Expand All @@ -66,7 +66,7 @@ tests:
export JUVIX_LLVM_DIST_PATH=${CLANG_PATH%$'/bin/clang'}
juvix doctor --verbose --offline
exit-status: 0
stdout:
stderr:
matches:
regex: |-
Found clang(.*?)using JUVIX_LLVM_DIST_PATH
Expand All @@ -79,7 +79,7 @@ tests:
export JUVIX_LLVM_DIST_PATH=/tmp
juvix doctor --verbose --offline
exit-status: 0
stdout:
stderr:
matches:
regex: |-
Found clang(.*?)using system PATH

0 comments on commit 76af212

Please sign in to comment.