You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Feature request]
I think that you should be able to use regex to match which files are watched for changes, and which files get run.
This is basically guard but for python. The syntax for a guardfile is so clean, you just type
guard :<rspec/minitest/testing framework> [, options ] do
watch(<file regex or file name to watch>) [{|m| <file regex or filename or directory to run>}]
end
Where watch is a function that takes a regex search and an optional function that takes the matching string and the regex groups for what files to run.
We could call this function sniff (because sniffer)
My current scent.py file is
from sniffer.api import *
from subprocess import call
from datetime import datetime
import os
watch_paths = ['.', 'test/']
# Define validator for running a specific function before all the tests
@select_runnable('first')
@file_validator
def python_files(filename):
return filename.endswith('.py') and not os.path.basename(filename).startswith('.')
@select_runnable('linked_list_test')
@file_validator
def linked_list_file(filename):
return filename.endswith('linked_list.py')
@select_runnable('hash_table_test')
@file_validator
def hash_table_file(filename):
return filename.endswith('hash_table.py')
@runnable
def linked_list_test(*args):
print("===Linked List Tests===")
command = "nosetests test/test_linked_list.py -v")
return call(command, shell=True) == 0
@runnable
def hash_table_test(*args):
print("===Hash Table Tests===")
command = "nosetests test/test_hash_table.py -v")
return call(command, shell=True) == 0
@runnable
def first(*args):
print(str(datetime.now()))
return True
which is a lot just to say to run specific files based on name. There is a lot of repetition.
I believe the api could be changed to work more like guard, the scent.py file could look like (to do the same thing as above)
from sniffer.api import *
from datetime import datetime
import os
## The default should be to track all subfolders
## Uncomment and sniffer will watch only specific directories
# watch_directories = ["."x, "test/"]
@sniffer_setup
def func_name(sniffer):
# nosetest arguments
sniffer.args = ["-v"]
# run this optional function every time before a test
sniffer.before = print_time
# Watch for and execute any file in test subfolder that are in the form of "test_name.py"
sniffer.sniff(r"^test/test_(.*)\.py$")
# Watch for any file in root directory and execute the relevant test file
sniffer.sniff(r"(.*)\.py", tests_based_on_groups)
def tests_based_on_groups(file_string, groups)
return "test/test_" + groups[0] + ".py"
def print_time():
print(str(datetime.now()))
The text was updated successfully, but these errors were encountered:
[Feature request]
I think that you should be able to use regex to match which files are watched for changes, and which files get run.
This is basically guard but for python. The syntax for a guardfile is so clean, you just type
Where
watch
is a function that takes a regex search and an optional function that takes the matching string and the regex groups for what files to run.We could call this function
sniff
(because sniffer)My current scent.py file is
which is a lot just to say to run specific files based on name. There is a lot of repetition.
I believe the api could be changed to work more like guard, the scent.py file could look like (to do the same thing as above)
The text was updated successfully, but these errors were encountered: