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

Refactor & overhaul moonc and watchers #380

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Shados
Copy link

@Shados Shados commented Feb 18, 2019

I've tried to split this up across commits to make it a bit easier to follow, but most of the changes are in the last few, as they're fairly heavily intertwined. Intermediate commits do pass the test suites and some brief manual testing.

Main changes/improvements:

  1. The code handling input paths and --output-to has been unified across moonc and the watchers, previously the behaviour differed with/without -w, and various issues have been resolved with --output-to, including:
    1. It now actually works...
    2. The suggestion for rsync-like handling of exclusive/inclusive directory path behaviour made in issue moonc adds directory to output paths #342 is added (and can probably be considered enough to close that issue)
  2. Watch mode will now remove "orphaned" .lua output files, if and when their corresponding .moon source files are deleted
    1. It will not remove .lua files that had no corresponding .moon file to begin with; this prevents it from doing things like inadvertantly removing vendored Lua modules
  3. Both watcher implementations should properly handle the creation of new subdirectories now
  4. Both watcher implementations now have tests
  5. Everything works OK with absolute paths now; I think there were a couple of edge cases before
  6. The implementation of moonc was migrated to Moonscript and broken up into smaller functions, which should hopefully render it more readable -- and also testable, although not yet actually tested

Downsides:

  • Gnarlier tests; the expanded filesystem test stubs/mocks/helpers now also have their own tests. Testception D:
  • +LOC

@Shados
Copy link
Author

Shados commented Feb 18, 2019

Force-pushed to fix some compatibility issues

@Shados Shados force-pushed the overhaul-watchers branch 3 times, most recently from e3bc439 to 596f6fb Compare February 20, 2019 23:21
@Shados
Copy link
Author

Shados commented Feb 20, 2019

Rebased against master again to drop my Correct '--output-to' to being an option rather than a bare flag commit, as another source for that fix was merged.

@leafo
Copy link
Owner

leafo commented Feb 21, 2019

Thanks for the this patch, it's going to take me a bit to go through it, I'll try to get back to you soon. Feel free to bug me on discord too

- By 'path-related', I mean ones that purely manipulate or work on
  paths, with no actual filesystem accesses involved
- A few new functions are also added
Benefits and changes:
- Implemented the rsync-like exclusive/inclusive directory behaviour
  brought up in issue leafo#342
- Unified CLI file/directory input handling across watch and non-watch
  code paths
- Everything works OK with absolute paths now, although I can't
  guarantee that it won't violate some user's expectations -- but the
  behaviour is all consistent
- By converting moonc to Moonscript and breaking it up into smaller
  functions, it should be easier to read, and its component parts could
  also now be covered by the Busted tests
- Also replaces the existing test filesystem stubs/mocks with some more
  expansive ones, in preparation for increasing test coverage
- Essentially rewrote both SleepWatcher and InotifyWatcher
- Added test suites for both, including an expanded set of filesystem
  stubs in order to test them in isolation from the underlying
  filesystem
    - The filesystem stubs have their own tests, kek

Improvements as a result of these changes:
- Watch mode will remove "orphaned" .lua output files if/when their
  corresponding .moon input files are deleted
    - But it will not remove .lua files that have no corresponding .moon
      file to begin with, in order to avoid e.g. removing vendored Lua
      modules
- Both Watcher types will properly handle creation of new subdirectories
    - There *shouldn't* be any problematic races with this, although
      inotify's lack of recursive directory watching makes it difficult
      to know for sure
- More of the code is tested, and more of the code now *could* be tested
  (but isn't yet)
- Some bugs were fixed

Downsides:
- Somewhat gnarlier tests
- Moar lines of code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants