Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:59:24+00:00 2026-06-10T22:59:24+00:00

I’m testing some audio behavior and I need the user to judge if things

  • 0

I’m testing some audio behavior and I need the user to judge if things pass or fail. I’d like to ask the user for a response within a leiningen test. But, there is something happening to read-line that prevents this.

This is some example test code after creating a new clojure project with “lein new foo” and editing the foo/test/foo/core_test.clj file:

(ns foo.core-test
  (:use clojure.test
        foo.core))

(deftest a-test
  (testing "FIXME, what a fail."
    (let [_ (println "enter something")
          yn (read-line)]
      (println yn)
      (is (= yn "y")))))

and this is what happens in a “lein test”

lein test foo.core-test
enter something
hi
there
what
is 
going on?
^C

only control-C stops the (read-line) call.

I’m using Clojure 1.4.0 and Leiningen 2.0.0-preview7 on Java 1.6.0_35 Java HotSpot(TM) 64-Bit Server VM

Any ideas on how to get read-line to work inside a test?

I should also note that (read-line) does work fine inside “lein repl” for me…

> lein repl
nREPL server started on port 54398
REPL-y 0.1.0-beta8
Clojure 1.4.0
    Exit: Control+D or (exit) or (quit)
Commands: (user/help)
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
          (user/sourcery function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
Examples from clojuredocs.org: [clojuredocs or cdoc]
          (user/clojuredocs name-here)
          (user/clojuredocs "ns-here" "name-here")

user=> (println (read-line))
       hi
hi
nil
user=> (read-line)
       ho
"ho"

UPDATE:

I’m going to give @DaoWen the win on this. Reading the links & googling around, stdin is just b0rken on leiningen. With enough hoop-jumping, perhaps I could figure this out, but the suggestion of a dialog box seems like the best path forward. Dropping some test code here just for completeness in case this helps others.

(ns foo.core-test
  (:use clojure.test
        foo.core))

(import 'javax.swing.JOptionPane)

(defn ask-yn
  "return 0 on pass, 1 on fail"
  [prompt]
  (JOptionPane/showConfirmDialog nil prompt "User Input" JOptionPane/YES_NO_OPTION))

(deftest a-test
  (testing "a-test"
    (let [yn (ask-yn "did a-test pass?")]
      (is (= yn 0)))))

(deftest b-test
  (testing "b-test"
    (let [yn (ask-yn "did b-test pass?")]
      (is (= yn 0)))))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:59:25+00:00Added an answer on June 10, 2026 at 10:59 pm

    I know this doesn’t fix your read-line issue, but maybe you can get around it by just using a JOptionPane instead. If I were a user listening to several sound files I’d rather just click Yes or No rather than having to type one of the two.

    (import 'javax.swing.JOptionPane)
    (JOptionPane/showConfirmDialog nil "Did the test pass?" "User Input" JOptionPane/YES_NO_OPTION)
    

    Update:

    I thought I’d seen something like this before:

    Why does read-line not return after hitting ENTER (seems like a hang) using lein run, but works with lein repl?

    It looks like you should try running lein trampoline test instead of just lein test in order to resolve the stdin issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.