babashka/test/babashka/udp_test.clj
Bob 35e2cd9d05
make tests run on windows as the default (#235) (#898)
* make tests run on windows as the default

- change from selecting tests to run to selecting tests to skip (remove all :windows tags, add
  :skip-windows tag to tests that don't currently work on windows)
- handfuls of calls to `normalize` and `escape-file-paths` to handle platform differences
- split `task-test` to make most of the tests run on windows, and exclude just a couple of Unix-y tests

* make a binding name clearer

* skip nrepl-server-test on Windows

- test fails on CI, so disabling it for now

* unset bb environment vars after running tests

* unset bb environment var after running release-artifact

BABASHKA_EDN being set can interfere with some tests, so unset it before running the
native tests

* skip uberjar test on Windows

uberjar-test's 'throw on empty classpath' test failing on Windows native
 (but passes on JVM) - skip it for now
2021-06-20 09:23:58 +02:00

25 lines
1,009 B
Clojure

(ns babashka.udp-test
(:require [babashka.test-utils :as tu]
[clojure.test :refer [deftest is]])
(:import [java.io StringWriter]
[java.net DatagramPacket DatagramSocket]))
(set! *warn-on-reflection* true)
(deftest udp-test
(let [server (DatagramSocket. 8125)
sw (StringWriter.)
fut (future
(let [buf (byte-array 1024)
packet (DatagramPacket. buf 1024)
_ (.receive server packet)
non-zero-bytes (filter #(not (zero? %)) (.getData packet))
non-zero-bytes (byte-array non-zero-bytes)]
(binding [*out* sw]
(println (String. non-zero-bytes "UTF-8")))))]
(while (not (realized? fut))
(tu/bb nil
"-e" "(load-file (io/file \"test-resources\" \"babashka\" \"statsd.clj\"))"
"-e" "(require '[statsd-client :as c])"
"-e" "(c/increment :foo)"))
(is (= ":foo:1|c\n" (tu/normalize (str sw))))))