Skip to content

Commit 2b62307

Browse files
committed
update
1 parent 211a07b commit 2b62307

File tree

18 files changed

+682
-102
lines changed

18 files changed

+682
-102
lines changed

.DS_Store

-6 KB
Binary file not shown.

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build-and-test:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Install dependencies
13+
run: |
14+
sudo apt-get update
15+
sudo apt-get install -y make gcc
16+
17+
- name: Build project
18+
run: make
19+
20+
- name: Run tests
21+
run: make test
22+
23+
- name: Clean up
24+
run: make fclean

.gitignore

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Executables
2+
pipex
3+
*.out
4+
5+
# Object files
6+
*.o
7+
source/*.o
8+
9+
# Test files
10+
test_*
11+
*_test
12+
*_bonus
13+
14+
# Input/Output test files
15+
file1
16+
file2
17+
file3
18+
input.txt
19+
output.txt
20+
result.txt
21+
count.txt
22+
fruits.txt
23+
access.log
24+
uppercase.txt
25+
here_doc
26+
27+
# Temporary files
28+
*.tmp
29+
*.swp
30+
*.swo
31+
*~
32+
33+
# IDE files
34+
.vscode/
35+
.idea/
36+
*.code-workspace
37+
38+
# OS generated files
39+
.DS_Store
40+
.DS_Store?
41+
._*
42+
.Spotlight-V100
43+
.Trashes
44+
ehthumbs.db
45+
Thumbs.db
46+
47+
# Log files
48+
*.log
49+
50+
# Backup files
51+
*.bak
52+
*.backup

.vscode/settings.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Miguel Gonzalez
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 77 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,97 @@
11
NAME = pipex
2+
LIB = libft
23

4+
# Source files
35
SRC = source/main.c source/pipex.c source/path.c source/child.c
4-
56
OBJ = $(SRC:.c=.o)
6-
#-fsanitize=address
7-
FLAGS = -Wall -Wextra -Werror
87

9-
LIB = libft
8+
# Compiler flags
9+
CFLAGS = -Wall -Wextra -Werror
10+
DEBUG_FLAGS = -g3 -fsanitize=address
11+
12+
# Test files
13+
TEST_DIR = tests
14+
BASIC_TEST = basic_test.sh
15+
MULTI_TEST = multi_pipe_test.sh
16+
HERE_DOC_TEST = here_doc_test.sh
1017

11-
all: ${NAME}
18+
# Colors for output
19+
GREEN = \033[0;32m
20+
YELLOW = \033[1;33m
21+
RED = \033[0;31m
22+
NC = \033[0m # No Color
1223

13-
${NAME}: ${OBJ}
14-
make -C $(LIB)
15-
@gcc $(FLAGS) $(OBJ) -o $(NAME) $(LIB)/libft.a
24+
.PHONY: all clean fclean re debug test help
1625

17-
#$(OBJ): $(SRC)
18-
# @gcc $(FLAGS) -c $(SRC)
26+
# Default target
27+
all: $(NAME)
1928

20-
exe: all
21-
@./$(NAME) file1 "ls" "cat -e" file2
22-
< file1 ls | cat -e > file3
23-
cmp file2 file3
29+
# Main executable
30+
$(NAME): $(OBJ)
31+
@make -C $(LIB) > /dev/null 2>&1
32+
@gcc $(CFLAGS) $(OBJ) -o $(NAME) $(LIB)/libft.a
33+
@echo "$(GREEN)$(NC) $(NAME) compiled successfully!"
2434

25-
#cmd << LIMITER | cmd1 >> file
35+
# Object files
36+
source/%.o: source/%.c
37+
@gcc $(CFLAGS) -c $< -o $@
2638

27-
exe2: all
28-
@./$(NAME) file1 "ls" "wc -l" "cat -e" "cat -e" "cat -e" file2
29-
< file1 ls | wc -l | cat -e | cat -e | cat -e > file3
30-
cmp file2 file3
39+
# Debug version with sanitizers
40+
debug: CFLAGS += $(DEBUG_FLAGS)
41+
debug: fclean $(NAME)
42+
@echo "$(YELLOW)$(NC) Debug build with address sanitizer enabled"
3143

44+
# Clean object files
3245
clean:
3346
@rm -rf $(OBJ)
34-
@make -C $(LIB) clean
47+
@make -C $(LIB) clean > /dev/null 2>&1
48+
@echo "$(YELLOW)🧹$(NC) Object files cleaned"
3549

50+
# Clean everything including executable
3651
fclean: clean
3752
@rm -rf $(NAME)
38-
@make -C $(LIB) fclean
53+
@rm -rf $(TEST_DIR)
54+
@echo "$(YELLOW)🧹$(NC) All files cleaned"
3955

56+
# Rebuild everything
4057
re: fclean all
4158

42-
.PHONY: clean fclean all re
59+
# Test the program
60+
test: $(NAME)
61+
@chmod +x $(TEST_DIR)/$(BASIC_TEST)
62+
@chmod +x $(TEST_DIR)/$(MULTI_TEST)
63+
@chmod +x $(TEST_DIR)/$(HERE_DOC_TEST)
64+
@echo "$(GREEN)🧪$(NC) Running tests..."
65+
@$(TEST_DIR)/$(BASIC_TEST)
66+
@$(TEST_DIR)/$(MULTI_TEST)
67+
@$(TEST_DIR)/$(HERE_DOC_TEST)
68+
@echo "$(GREEN)$(NC) All tests completed!"
69+
70+
# Create test directory and scripts
71+
$(TEST_DIR):
72+
@mkdir -p $(TEST_DIR)
73+
74+
# Create test files
75+
test-files: $(TEST_DIR)
76+
@echo "Creating test files..."
77+
@echo "Hello World\nThis is a test file\n42 is awesome" > $(TEST_DIR)/input.txt
78+
@echo -e "apple\nbanana\nApple\ncherry\nbanana\nApple" > $(TEST_DIR)/fruits.txt
79+
@echo "This is line 1\nThis is line 2" > $(TEST_DIR)/multiline.txt
80+
81+
# Help target
82+
help:
83+
@echo "$(GREEN)Pipex Build System$(NC)"
84+
@echo ""
85+
@echo "Available targets:"
86+
@echo " $(YELLOW)make$(NC) - Build the main executable"
87+
@echo " $(YELLOW)make debug$(NC) - Build with debug flags and sanitizers"
88+
@echo " $(YELLOW)make clean$(NC) - Remove object files"
89+
@echo " $(YELLOW)make fclean$(NC) - Remove all generated files"
90+
@echo " $(YELLOW)make re$(NC) - Rebuild everything"
91+
@echo " $(YELLOW)make test$(NC) - Run test suite"
92+
@echo " $(YELLOW)make help$(NC) - Show this help message"
93+
@echo ""
94+
@echo "Usage examples:"
95+
@echo " ./pipex input.txt \"cat\" \"wc -l\" output.txt"
96+
@echo " ./pipex here_doc EOF \"cat\" \"tr 'a-z' 'A-Z'\" output.txt"
97+
@echo " ./pipex input.txt \"grep error\" \"sort\" \"uniq -c\" output.txt"

0 commit comments

Comments
 (0)