cue-lang / cue

The home of the CUE language! Validate and define text-based and dynamic configuration
https://cuelang.org
Apache License 2.0
5.09k stars 290 forks source link

Placeholder for old PR #200 #200

Closed cueckoo closed 3 years ago

cueckoo commented 3 years ago

Originally raised by @adieu in https://github.com/cuelang/cue/pull/200

cueckoo commented 3 years ago

Original reply by @adieu in https://github.com/cuelang/cue/pull/200#issuecomment-560240855

I'll add a test for this PR.

cueckoo commented 3 years ago

Original reply by @adieu in https://github.com/cuelang/cue/pull/200#issuecomment-561669849

@mpvl This fix https://github.com/cuelang/cue/commit/52b04d409b31e439704de4884388840fec6e2dc7#diff-104bcbf8410c0cd325212e1b0af431aeL90 will cause the Equals check of two list value to fail. Even when they are the same.

Removing the optionals check will let my test case pass. I'm not quite sure why we directly return false here.

cueckoo commented 3 years ago

Original reply by @mpvl in https://github.com/cuelang/cue/pull/200#issuecomment-561890240

@adieu Do you have an example of a specific equals check that fails?

cueckoo commented 3 years ago

Original reply by @mpvl in https://github.com/cuelang/cue/pull/200#issuecomment-561895849

@adieu

@adieu Do you have an example of a specific equals check that fails?

Oh, I see you already did, and very properly at it. :) I see why this is failing, but not adding the optional check breaks other things. I will just have to make subsumption more accurate there.

Note that equality checks for structs are a somewhat dubious notion, though. This is one reason why == is not defined for structs. It should be documented in Equals that equality doesn't always yield accurate results for incomplete composite structures. This is not special to CUE, but to many logical programming languages.

cueckoo commented 3 years ago

Original reply by @mpvl in https://github.com/cuelang/cue/pull/200#issuecomment-561896153

Anyway, at the very least it should return true for structural equality.

cueckoo commented 3 years ago

Original reply by @adieu in https://github.com/cuelang/cue/pull/200#issuecomment-562457315

I've rebased to master using $before and $after. The tests passed.

I found the declarative scripting feature very powerful when I was hacking on the code and thinking about its possible usage patterns. Right now it's just at a very early stage and there are quite a few things we could make improvements to. I made this PR to get https://github.com/adieu/cue-ansible/blob/master/play_tool.cue working so that I could demonstrate it to other people the power of CUE.

How about we get this PR in and discuss the tooling layer design in another issue or slack?

cueckoo commented 3 years ago

Original reply by @mpvl in https://github.com/cuelang/cue/pull/200#issuecomment-562507197

Yeah, the next release should see some big improvements.

By making flags and envs tasks, I don't need any top-level fields anymore. This means that the task struct can go. Instead one would have an arbitrary hierarchy of tasks. This makes one-task commands much easier to specify (removes two levels of hierarchy). And it makes larger tasks more composable.

Then in the next phase of the testing command, I would like add support for testing tools. The data-driven scripting makes it very easy to do injection from within the language itself (just unify the command graph with the test data, and all tasks whose inputs are now concrete can run). It could even be constraint to only run the tasks in the expected result set, and their dependencies, as others would be immaterial. Then a next step could even be to automatically generate test sets from manual runs (especially handy when this involves http calls etc.). Again, it is just data. Anyway, getting ahead of myself. :)

If you like, I can include you on code reviews or cc for these things. I'm submitting on Gerrit myself, so you have to register there for to be able to CC you.

Also, if you would like to work on this area to help speed it along I would be very glad to give you pointers!

Thanks

Marcel