Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding --dry-run option #29

Closed
xonixx opened this issue Aug 10, 2021 · 7 comments
Closed

Consider adding --dry-run option #29

xonixx opened this issue Aug 10, 2021 · 7 comments
Assignees
Labels
Milestone

Comments

@xonixx
Copy link
Owner

xonixx commented Aug 10, 2021

No description provided.

@xonixx xonixx self-assigned this Aug 10, 2021
@xonixx xonixx added the idea label Sep 23, 2021
@08d2
Copy link

08d2 commented Feb 7, 2022

I'd really appreciate having this flag.

@xonixx
Copy link
Owner Author

xonixx commented Feb 7, 2022

Could you please elaborate your use-case a bit?

It might appear that -d,--resolved list resolved dependencies to reach given goals option can be sort of relevant here and be of some help.

$ ./makesure -d tests/7_options.tush 
Resolved goals to reach for 'tests/7_options.tush':
  tush_installed
  debug
  prepared4tests
  tests/7_options.tush
$ ./makesure -d tested_awks 
Resolved goals to reach for 'tested_awks':
  tush_installed
  debug
  prepared4tests
  tests/0_basic.tush
  tests/1_goals.tush
  tests/2_mydir.tush
  tests/3_loop.tush
  tests/4_trace.tush
  tests/5_shell.tush
  tests/6_reached_if.tush
  tests/7_options.tush
  tests/8_timing.tush
  tests/9_prelude.tush
  tests/10_define.tush
  tests/11_goal_glob.tush
  tests/12_errors.tush
  tests/13_doc.tush
  tests/14_private.tush
  tests/15_lib.tush
  tests/16_define_validation.tush
  tests/17_empty_prelude.tush
  tests/18_vars_priority.tush
  tests/19_optimize_goals.tush
  tests/20_list_goals.tush
  tests/21_parsing.tush
  tests/22_nat_order.tush
  tests/23_bash_glob.tush
  tests/24_define_everywhere.tush
  tests/200_update.tush
  'tests/*.tush'
  tested
  installed_bwk
  tested_bwk
  tested_mawk
  installed_mawk134
  tested_mawk134
  installed_gawk51
  tested_gawk51
  installed_gawk511
  tested_gawk511
  installed_goawk
  tested_goawk
  tested_awks

@08d2
Copy link

08d2 commented Feb 7, 2022

My understanding is that --resolved prints the dependency graph of the given target(s). I'm after something that would also evaluate the @reached_if directives of each goal in that graph, in order to print the specific goals which would be executed. Ideally --dry-run would do something like echo each expression in the to-be-executed goals, too.

@08d2
Copy link

08d2 commented Feb 7, 2022

More abstractly, the user need here is a way to build confidence that a Makesurefile is doing what it should be doing. Being able to see precisely how the tool interprets the input and produces output — without actually executing the output — is a great way to build confidence.

@xonixx
Copy link
Owner Author

xonixx commented Feb 8, 2022

That's the thing. --resolved prints the dependency graph taking into account the @reached_if directives!
And, it prints the goals in the order they will be fulfilled.

@goal aaa
@reached_if true
@depends_on ccc
  echo 'aaa'

@goal bbb
@depends_on ccc
  echo 'bbb'

@goal ccc
  echo 'ccc'
$ ./makesure --resolved aaa
Resolved goals to reach for 'aaa':
  aaa

$ ./makesure --resolved bbb
Resolved goals to reach for 'bbb':
  ccc
  bbb

@08d2
Copy link

08d2 commented Feb 8, 2022

So given

@goal a
@reached_if [ -f a.txt ]
@depends_on b c
	touch a.txt

@goal b
@reached_if [ -f b.txt ]
	touch b.txt

@goal c
@reached_if [ -f c.txt ]
	touch c.txt

then

$ rm -f a.txt b.txt c.txt ; makesure --resolved a
Resolved goals to reach for 'a':
  b
  c
  a
$ # good!

$ rm -f a.txt b.txt c.txt ; touch c.txt ; makesure --resolved a
Resolved goals to reach for 'a':
  b
  c
  a
$ # bad! I should not see 'c' in this output, as it is already resolved, I just want to see 'b' and 'a'

$ rm -f a.txt b.txt c.txt ; touch b.txt ; makesure --resolved a
Resolved goals to reach for 'a':
  b
  c
  a
$ # bad! I should not see 'b' in this output, as it is already resolved, I just want to see 'c' and 'a'

$ rm -f a.txt b.txt c.txt ; touch b.txt c.txt ; makesure --resolved a
Resolved goals to reach for 'a':
  b
  c
  a
$ # bad! I should not see 'b' or 'c' in this output, as they are already resolved, I just want to see 'a'

$ rm -f a.txt b.txt c.txt ; touch a.txt ; makesure --resolved a
Resolved goals to reach for 'a':
  a
$ # bad! since 'a' is resolved, I should not see anything

xonixx added a commit that referenced this issue Feb 9, 2022
xonixx added a commit that referenced this issue Feb 9, 2022
xonixx added a commit that referenced this issue Feb 9, 2022
@xonixx xonixx added this to the 0.9.18 milestone Feb 9, 2022
@xonixx
Copy link
Owner Author

xonixx commented Feb 9, 2022

@08d2 Thank you for your detailed report! I turned it into test and fixed.

@xonixx xonixx mentioned this issue Feb 9, 2022
@xonixx xonixx closed this as completed Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants