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

Watch mode #119

Open
pirj opened this issue Jul 11, 2019 · 1 comment
Open

Watch mode #119

pirj opened this issue Jul 11, 2019 · 1 comment
Labels
feature request an issue that asks for a feature which is not supported yet help wanted

Comments

@pirj
Copy link
Contributor

pirj commented Jul 11, 2019

Add a --watch that would run tests as Crystalball finds the changes in the source code.

  • Use guard (or similar)
  • Lookup needs to be faster
  • Only run fast specs
  • Support --fail-fast
  • Have a predictor for a single file
    • Right now it only works with the git diff
@pirj pirj added feature request an issue that asks for a feature which is not supported yet help wanted labels Jul 11, 2019
@pocheptsov
Copy link

It's a very useful feature and will be great to have official support. My current setup is using a shell script which is committing any Guard detected changes to temp git branch.
Will be great to abstract out GitRepo and SourceDiff so changed files may be provided from the different input sources like crystalball command arguments.

# Gemfile
group :test do
  gem 'crystalball'
  gem 'guard-rspec'
end
# Guardfile
group :spec do
  require 'guard/compat/plugin'

  SPEC_DIRS = ENV.fetch('SPEC_DIRS', 'spec').split

  Guard::Compat::UI.info("spec_paths are #{SPEC_DIRS}")
  common_options = {
    all_on_start: true,
    spec_paths: SPEC_DIRS
  }

  crystalball_options = common_options.merge(
    cmd: 'bundle exec crystalball',
    run_all: { cmd: 'CRYSTALBALL=true bundle exec rspec' },
    failed_mode: :focus
  )

  git_options = common_options.merge(
    cmd: './script/commit_changes.sh', 
    run_all: { cmd: './script/reset_temp_branch.sh' }
  )

  guard :rspec, git_options do
    ...
  end

  guard :rspec, crystalball_options do
    ...
  end
end
# config/crystalball.yml
diff_from: 'origin/temp-crystalball'
# script/commit_changes.sh
#!/bin/bash

# fetch last parameter
shift $(($# - 1))
CHANGESET="$1"

pushd ../temp-crystalball
git reset --hard master
git add $CHANGESET
git commit -m "commit file $CHANGESET"
git push -f origin temp-crystalball
popd

git fetch origin

# simulate RSpec output
cat <<-CONTENT >../tmp/rspec_guard_result
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="rspec" tests="0" skipped="0" failures="0" errors="0" time="0.000580" timestamp="2019-08-21T19:08:55+00:00" hostname="989952f29f49">
<properties>
<property name="seed" value="52324"/>
</properties>
</testsuite>
CONTENT

Related to #101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request an issue that asks for a feature which is not supported yet help wanted
Projects
None yet
Development

No branches or pull requests

2 participants