Made the ./scripts/play.fun script behave mor like ./scripts/run_examples.sh. No internal code logic changes. (0.41.4)
This commit is contained in:
parent
57dda41bf3
commit
d96976c6a9
2 changed files with 25 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(fun VERSION 0.41.3 LANGUAGES C)
|
project(fun VERSION 0.41.4 LANGUAGES C)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
|
|
||||||
|
|
@ -56,12 +56,24 @@ print("Searching for examples in ./examples...")
|
||||||
// Recursive file discovery
|
// Recursive file discovery
|
||||||
// Since we don't have a robust recursive os_list_dir yet,
|
// Since we don't have a robust recursive os_list_dir yet,
|
||||||
// and the original used 'find', we'll use 'find' via system to get the list.
|
// and the original used 'find', we'll use 'find' via system to get the list.
|
||||||
fun get_examples()
|
fun get_examples(subdir)
|
||||||
// We use 'find' to get all .fun files and sort them.
|
// We use 'find' to get all .fun files and sort them.
|
||||||
// We redirect to a temporary file as we don't have a 'proc_capture' that returns an array easily
|
// We redirect to a temporary file as we don't have a 'proc_capture' that returns an array easily
|
||||||
// Actually, os_list_dir uses 'ls -1'. We can use a similar approach or just call find.
|
// Actually, os_list_dir uses 'ls -1'. We can use a similar approach or just call find.
|
||||||
|
|
||||||
cmd = "find examples -name \"*.fun\" | sort > ./tmp/examples_list.txt"
|
base_dir = "examples"
|
||||||
|
cmd = ""
|
||||||
|
if (len(subdir) > 0)
|
||||||
|
target = base_dir + "/" + subdir
|
||||||
|
// Verify directory exists
|
||||||
|
if (system("test -d " + target) != 0)
|
||||||
|
print("Error: examples subdirectory not found: " + subdir)
|
||||||
|
exit(1)
|
||||||
|
cmd = "find " + target + " -name \"*.fun\" | sort > ./tmp/examples_list.txt"
|
||||||
|
else
|
||||||
|
// Only run scripts directly in the ./examples/ directory when no argument is given.
|
||||||
|
cmd = "find " + base_dir + " -maxdepth 1 -name \"*.fun\" | sort > ./tmp/examples_list.txt"
|
||||||
|
|
||||||
system(cmd)
|
system(cmd)
|
||||||
|
|
||||||
list_str = read_file("./tmp/examples_list.txt")
|
list_str = read_file("./tmp/examples_list.txt")
|
||||||
|
|
@ -81,9 +93,17 @@ fun get_examples()
|
||||||
i = i + 1
|
i = i + 1
|
||||||
return examples
|
return examples
|
||||||
|
|
||||||
examples = get_examples()
|
args = parse_args(argv())
|
||||||
|
subdir = ""
|
||||||
|
if (len(args["positionals"]) > 0)
|
||||||
|
subdir = args["positionals"][0]
|
||||||
|
|
||||||
|
examples = get_examples(subdir)
|
||||||
if (len(examples) == 0)
|
if (len(examples) == 0)
|
||||||
print("No examples found in ./examples")
|
if (len(subdir) > 0)
|
||||||
|
print("No examples found in ./examples/" + subdir)
|
||||||
|
else
|
||||||
|
print("No examples found in ./examples")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
failed_examples = []
|
failed_examples = []
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue