1
0
Fork 0
mirror of https://github.com/imjasonh/testscript-rs synced 2026-07-09 01:26:40 +00:00

initial commit

Signed-off-by: Jason Hall <jason@chainguard.dev>
This commit is contained in:
Jason Hall 2025-09-26 18:41:14 -04:00
commit c39114f1a9
64 changed files with 8704 additions and 0 deletions

View file

@ -0,0 +1,19 @@
# Test basic sample-cli functionality
# Test help output
exec ./sample-cli --help
stdout ".*sample CLI tool.*"
# Test version
exec ./sample-cli --version
stdout "sample-cli 1.0"
# Test no command shows info
exec ./sample-cli
stdout ".*demonstration CLI tool.*"
stdout ".*--help.*"
-- test_file.txt --
Hello world
This is line two
Line three here

View file

@ -0,0 +1,34 @@
# Test count functionality
# Count lines in a file
exec ./sample-cli count test_file.txt
stdout "test_file.txt: 3"
# Count words
exec ./sample-cli count --mode words test_file.txt
stdout "test_file.txt: 9"
# Count characters
exec ./sample-cli count --mode chars test_file.txt
stdout "test_file.txt: 44"
# Test multiple files
exec ./sample-cli count file1.txt file2.txt
stdout "file1.txt: 2"
stdout "file2.txt: 1"
# Test error on missing file
! exec ./sample-cli count nonexistent.txt
stderr ".*No such file.*"
-- test_file.txt --
Hello world
This is line two
Line three here
-- file1.txt --
First file
Second line
-- file2.txt --
Single line file

View file

@ -0,0 +1,25 @@
# Test file creation and removal
# Create a file with content
exec ./sample-cli create newfile.txt --content "Hello from CLI"
stdout "Created file: newfile.txt"
exists newfile.txt
exec cat newfile.txt
stdout "Hello from CLI"
# Create empty file
exec ./sample-cli create empty.txt
exists empty.txt
exec ./sample-cli count --mode chars empty.txt
stdout "empty.txt: 0"
# Remove files
exec ./sample-cli remove newfile.txt empty.txt
stdout "Removed: newfile.txt"
stdout "Removed: empty.txt"
! exists newfile.txt
! exists empty.txt
# Try to remove non-existent file
exec ./sample-cli remove nonexistent.txt
stderr "File not found: nonexistent.txt"

View file

@ -0,0 +1,30 @@
# Test grep functionality
# Basic grep
exec ./sample-cli grep "world" test_file.txt
stdout "test_file.txt:1: Hello world"
# Case insensitive grep
exec ./sample-cli grep --ignore-case "HELLO" test_file.txt
stdout "test_file.txt:1: Hello world"
# Multiple files
exec ./sample-cli grep "file" file1.txt file2.txt
stdout "file1.txt:1: First file"
stdout "file2.txt:1: Single line file"
# No matches
exec ./sample-cli grep "xyz" test_file.txt
! stdout "xyz"
-- test_file.txt --
Hello world
This is line two
Line three here
-- file1.txt --
First file
Second line
-- file2.txt --
Single line file

View file

@ -0,0 +1,17 @@
# Test directory listing
# Create some files and directories first
mkdir test_dir
exec ./sample-cli create test_dir/nested_file.txt --content "nested"
# List current directory
exec ./sample-cli list
stdout "FILE.*existing_file.txt"
stdout "DIR.*test_dir"
# List specific directory
exec ./sample-cli list test_dir
stdout "FILE.*nested_file.txt"
-- existing_file.txt --
This file exists

View file

@ -0,0 +1,3 @@
# Simple test that definitely works
exec ./sample-cli --version
stdout "sample-cli 1.0"