Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Maikel 🇪🇺 🇪🇸
@maikel@vmst.io  ·  activity timestamp 4 months ago

This is how I do test-driven development in Elixir. This function is saved in .config/fish/functions so it preloads whenever I open the terminal. Fish shell is the one I've been using forever.

Then I can do either

onchange test/indie/domains_test.exs

OR

onchange test/indie/domains_test.exs --only dnssec

If I want to run specific tags only.

#Elixir#FishShell

function onchange
    if test (count $argv) -lt 1
        echo "Usage: onchange <file> [--only tag ...]"
        return 1
    end

    set file $argv[1]
    set args $argv[2..-1]

    echo "📡 Watching $file for changes..."

    while true
        inotifywait -e close_write,moved_to,create $file > /dev/null
        echo "🔁 Change detected! Running test_trace $file $args..."
        test_trace $file $args
    end
end
function onchange if test (count $argv) -lt 1 echo "Usage: onchange <file> [--only tag ...]" return 1 end set file $argv[1] set args $argv[2..-1] echo "📡 Watching $file for changes..." while true inotifywait -e close_write,moved_to,create $file > /dev/null echo "🔁 Change detected! Running test_trace $file $args..." test_trace $file $args end end
function onchange if test (count $argv) -lt 1 echo "Usage: onchange <file> [--only tag ...]" return 1 end set file $argv[1] set args $argv[2..-1] echo "📡 Watching $file for changes..." while true inotifywait -e close_write,moved_to,create $file > /dev/null echo "🔁 Change detected! Running test_trace $file $args..." test_trace $file $args end end
  • Copy link
  • Flag this post
  • Block
maco
@maco@wandering.shop replied  ·  activity timestamp 4 months ago
@maikel I use the testing stuff in VS Code, when ElixirLS isn’t crashing on me. When it is, I use the terminal at the bottom of VS Code to run “mix test file/path.exs:line”

I hate how crashy it is. Yesterday I was using grep in a separate terminal because search wasn’t working in VS Code due to I guess the indexer crashing.

This shit used to work when I started doing Elixir in 2020.

  • Copy link
  • Flag this comment
  • Block
dch :flantifa: :flan_hacker:
@dch@bsd.network replied  ·  activity timestamp 4 months ago
@maikel even easier, I don't have a fish thing for it

fd .ex\? | entr -s 'mix test --trace --stale --listen-on-stdin'

https://github.com/sharkdp/fd
https://github.com/eradman/entr

#MyElixirStatus#UNIX

  • Copy link
  • Flag this comment
  • Block
Maikel 🇪🇺 🇪🇸
@maikel@vmst.io replied  ·  activity timestamp 4 months ago

how do you do it @katafrakt, I want to see other people's processes.

  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login