Fork me on GitHub
#clojure
<
2021-06-02
>
kenny00:06:17

Pretty sure that’s a result of defspec, not circleci.

dpsutton00:06:52

FAIL in (defspec-failure) (file.clj:10)
expected: {:result true}
  actual: {:shrunk {:total-nodes-visited 1, :depth 0, :pass? false, :result false, :result-data nil, :time-shrinking-ms 0, :smallest [-1]}, :failed-after-ms 2, :num-tests 2, :seed 1622595497912, :fail [-1], :result false, :result-data nil, :failing-size 1, :pass? false, :test-var "defspec-failure"}

FAIL in (deftest-failure) (file.clj:8)
expected: (= 1 2)
  actual: (not (= 1 2))
there's a lot more context that would be helpful.

javahippie07:06:17

I believe your only chance would be to transfer that context into the test results xml file somehow? How is the test failure represented in that?

ChillPillzKillzBillz06:06:39

Maybe this is a repeat question... I am a newbie and I have just stumbled upon spec in Clojure. I was wondering if spec can somehow be used to replicate regular expressions? e.g. say we have a sentence pattern like "Sam is a good boy"... We want the sentence to be parsed by an expression parser to extract words like this: "<name> is a <adjective> boy". We can do this in regular expression. I was just wondering if somebody has tried this using spec?

tatut07:06:40

you should look into #instaparse for parsing text into syntax trees

ChillPillzKillzBillz07:06:54

I just joined this channel... do you need me to repost my question here? I am sorry I didn't follow...

delaguardo07:06:06

It is not designed for that but for something simple patterns it is generally possible https://blog.michielborkent.nl/2017/10/10/parsing-a-circuit-with-clojure-spec/

ChillPillzKillzBillz11:06:28

This is really interesting... many thanks, I'll look it up!!

ChillPillzKillzBillz14:06:24

wow this is really cool reefersleep!! Many thanks!

ChillPillzKillzBillz16:06:30

@U0AQ3HP9U: thanks again for the link to lambdaisland/regal!! I started looking thru the example code. This tries to show how to match a pattern which equates 2 word symbols with "=" sign. I am pasting it here again... (def r [:cat         `[:+ [:class [\a \z]]]`         `"="`         `[:+ [:not \=]]])` . When we execute (regal/regex r) we get #"[a-z]+=[^=]+" as the pattern. How do we make a regal schema to create #"([a-z]+)=([^=]+)" instead? Any ideas? Eventually I'd like to run a command like (re-seq #"([a-z]+)=([^=]+)" "foo=bar") and get (["foo=bar" "foo" "bar"]) for output...

ChillPillzKillzBillz16:06:48

I solved it myself... I need to use the :capture keyword!! @U0AQ3HP9U: this is really awesome tool!! Many thanks indeed!!

reefersleep16:06:34

@U022LK3L4JJ great that it fits your use case! By the way, if you are not strictly wanting to do regex parsing, I know that @U4P4NREBY is working on a wrapper for a Java lib that can identify things like adjectives and nouns in sentences, if I remember correctly.

ChillPillzKillzBillz16:06:40

oh yeah that'll be great as well... I am interested in both regular parsing which is a bit more readable/manageable and language parsing... This is great help!! Many Thanks!

borkdude07:06:03

Spec is not intended to be used for text processing

Pratik10:06:04

I am using https://github.com/flatland/clojure-protobuf library for serialization and it strips all the default values/fields not provided while sending it over the wire(which is understandable) but also when deserializing at client side, it doesn’t add those default values or missing fields(with default values) back. I checked https://github.com/golang/protobuf golang library which returns those default values. Does anyone have idea why this library doesn’t return default values?

Nom Nom Mousse14:06:37

Is there a way to create a sorted-map that is sorted by the values?

Nom Nom Mousse14:06:13

I'll find a different way to do what I want.

Nom Nom Mousse15:06:23

I am running an sh job for side effects and I want to be notified when it finishes. However, if it the execution throws an error it never does finish:

user> (future (sh "non-existant-command-fails")) ;; never finishes
How do I get around this problem?

Nom Nom Mousse15:06:01

This does not work either:

(future (try (sh "non-existant-command-fails") (catch Exception ex {:error ex})))

dpsutton15:06:18

what does work mean? @(future (try (/ 1 0) (catch Exception _e {:it :threw}))) returns {:it :threw}.

Nom Nom Mousse15:06:52

Not working: it never finishes. But the above (with @) is blocking. I'd like to dispatch a job and then be notified when it finishes.

quoll15:06:19

When I do:

(def f (future (try (sh "non-existant-command-fails") (catch Exception ex {:error ex}))))
It returns fine for me. Looking at f I get:
#object[clojure.core$future_call$reify__8477 0x652ce654 {:status :ready, :val {:error #error { ......}}}
If I don’t use def and instead deref immediately, it returns instantly with the IOException

🙏 3
quoll15:06:02

Are you doing something different?

Nom Nom Mousse15:06:50

The above works, but if I add a callback function (just println in the below example) the callback is never used:

(def f (future (try (sh "non-existant-command-fails") (println "hoi") (catch Exception ex {:error ex}))))

quoll15:06:21

That’s because the exception was thrown before the print

Nom Nom Mousse15:06:31

That is how I was hoping to be notified of the job being finished (or having errored)

quoll15:06:39

You could use a finally block?

Nom Nom Mousse15:06:43

I see the reason why, I just wonder how to get around it 🙂

Nom Nom Mousse15:06:49

Ah, I'll try 🙏

Rob Haisfield16:06:45

Anyone know any good time zone conversion libraries?

seancorfield16:06:17

Depends what you mean by that — for Clojure, I’d just use Java Time directly for most time/date stuff.

💯 12
James Carr17:06:47

Anyone using Datadog APM with Clojure? Or even more in particular ... using Clojure + open telemetry with Datadog APM?

4
ghadi17:06:21

no, but interested in this topic simple_smile

javahippie17:06:14

There was just another APM question last week, how about creating a channel about the topic?

javahippie17:06:42

Just saw, there is #observability

James Carr18:06:57

lol the other one was me 🙂

🙂 2
kenny20:06:46

We use Datadog APM and report to it via opentacing Java lib. Yeah, I’m getting some déjà vu here.

James Carr14:06:38

@U083D6HK9 what was your experience with stack traces?

James Carr14:06:13

we have a few apps setup and it is working fine, but 500 error responses just show ERR_CODE_2 rather than the stacktrace. A java based app using the same otel gateway has stacktraces visible, so wondering where the issue lies. Have a ticket open with DD on it

phronmophobic20:06:06

Is this expected behavior?

> (Math/abs 30359687764)
30359687764

> (#(Math/abs %) 30359687764)
294916692
> (#(Math/abs ^long %) 30359687764)
30359687764

> ((fn [x] (Math/abs x)) 30359687764)
294916692
>> ((fn [x] (Math/abs ^long x)) 30359687764)
30359687764

Alex Miller (Clojure team)20:06:07

I think this may already be logged (has to do with the coercion/casting path for primitive long vs object Long) but please ask these kinds of things on https://ask.clojure.org

ghadi20:06:18

there are a small cluster of bugs in this area

Alex Miller (Clojure team)20:06:10

there are several questions there that seem like the same thing already

Alex Miller (Clojure team)21:06:07

if you start asking a question on ask.clojure btw, it will suggest similar existing questions

👍 2
phronmophobic21:06:28

Just noticed that it seems like those questions and tickets refer to Java 1.8. My above results are on Java 11

Alex Miller (Clojure team)21:06:30

nothing in this area has changed since Java 1.0 afaik :)

Alex Miller (Clojure team)21:06:26

maybe there have been changes in how Clojure reflection worked against Java that would be relevant, dunno