Commit 2dc6d26f authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

Added tests

parent b56961d9
Loading
Loading
Loading
Loading

ci_cd/.gitlab-ci.yml

0 → 100644
+12 −0
Original line number Diff line number Diff line
stages:
  problem2
  problem3
  problem4

include:
  - local: 'ci_cd/problem2.yml'   # hw3, problem 1
  - local: 'ci_cd/problem3.yml'   # hw3, problem 2
  - local: 'ci_cd/problem4.yml'   # hw3, problem 2

default:
  timeout: 5m

ci_cd/problem2.yml

0 → 100644
+70 −0
Original line number Diff line number Diff line
prebuild_problem_2:
  stage: problem2
  script:
    - |
      # Check if problem2.cpp exists
      if [ ! -f "problem2.cpp" ]; then
        echo "problem2.cpp does not exist";
        exit 1;
      fi
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem2"'
  tags: [shell]

prebuild_problem_2_SKIP:
  stage: problem2
  script:
    - echo "SKIPPING problem 2 checks because the branch name is not 'problem2'"
  rules:
    - if: '$CI_COMMIT_REF_NAME != "problem2"'
  tags: [shell]

compile_problem_2:
  stage: problem2
  script:
    - echo "Compiling problem2.cpp"
    - g++ -c problem2.cpp
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem2"'
  tags: [c++-17]

lint_problem_2:
  stage: problem2
  script:
    - echo "Static code check of problem2.cpp"
    - cppcheck --std=c++17 --check-config --enable=all --inconclusive --error-exitcode=1 problem2.cpp
  allow_failure: false
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem2"'
  tags: [cppcheck]

test_problem_2:
  stage: problem2
  script:
    - echo "Testing problem 2";
    - git clone https://agile.bu.edu/gitlab/configs/ec327/hw-configs/hw2.git base_2
    - cp problem2.cpp base_2/tests
    - cd base_2/tests
    - make problem2
    - ./problem2
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem2"'
  tags: [c++-17]

#internal_testing_problem_2:
#  stage: problem2
#  script:
#    - echo "Internal testing problem 2";
#    - git clone https://trachten-gitlab:${INTERNAL_HW_TESTS}@agile.bu.edu/gitlab/ec327/ec327-staff/hw-tests/homework-three-internal.git
#    - cp -f problem2.cpp homework-three-internal/internal_tests/
#    - cd homework-three-internal/internal_tests/
#    - make internalTestProblem2
#    - ./internalTestProblem2 > /dev/null 2>&1
#    - RESULT=$(cat output.txt | tail -n 1)
#    - curl "https://agile.bu.edu/ec327_scripts/bestScores.pl?key=$MAGIC_KEY&name=$GITLAB_USER_LOGIN&score=$RESULT"
#  rules:
#    - if: '$CI_COMMIT_REF_NAME == "problem2"'
#  after_script:
#    - cat homework-two-internal/internal_tests/output.txt
#  tags: [c++-17]
#  timeout: 12m

ci_cd/problem3.yml

0 → 100644
+52 −0
Original line number Diff line number Diff line
prebuild_problem_3:
  stage: problem3
  script:
    - |
      # Check if problem3.cpp exists
      if [ ! -f "problem3.cpp" ]; then
        echo "problem3.cpp does not exist";
        exit 1;
      fi
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem3"'
  tags: [shell]

prebuild_problem_3_SKIP:
  stage: problem3
  script:
    - echo "SKIPPING problem 3 checks because the branch name is not 'problem3'"
  rules:
    - if: '$CI_COMMIT_REF_NAME != "problem3"'
  tags: [shell]

compile_problem_3:
  stage: problem3
  script:
    - echo "Compiling problem3.cpp"
    - g++ -c problem3.cpp
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem3"'
  tags: [c++-17]

lint_problem_3:
  stage: problem3
  script:
    - echo "Static code check of problem3.cpp"
    - cppcheck --std=c++17 --check-config --enable=all --inconclusive --error-exitcode=1 problem3.cpp
  allow_failure: false
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem3"'
  tags: [cppcheck]

test_problem_3:
  stage: problem3
  script:
    - echo "Testing problem 3";
    - git clone https://agile.bu.edu/gitlab/configs/ec337/hw-configs/hw3.git base_3
    - cp problem3.cpp base_3/tests
    - cd base_3/tests
    - make problem3
    - ./problem3
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem3"'
  tags: [c++-17]

ci_cd/problem4.yml

0 → 100644
+52 −0
Original line number Diff line number Diff line
prebuild_problem_4:
  stage: problem4
  script:
    - |
      # Check if problem4.cpp exists
      if [ ! -f "problem4.cpp" ]; then
        echo "problem4.cpp does not exist";
        exit 1;
      fi
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem4"'
  tags: [shell]

prebuild_problem_4_SKIP:
  stage: problem4
  script:
    - echo "SKIPPING problem 4 checks because the branch name is not 'problem4'"
  rules:
    - if: '$CI_COMMIT_REF_NAME != "problem4"'
  tags: [shell]

compile_problem_4:
  stage: problem4
  script:
    - echo "Compiling problem4.cpp"
    - g++ -c problem4.cpp
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem4"'
  tags: [c++-17]

lint_problem_4:
  stage: problem4
  script:
    - echo "Static code check of problem4.cpp"
    - cppcheck --std=c++17 --check-config --enable=all --inconclusive --error-exitcode=1 problem4.cpp
  allow_failure: false
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem4"'
  tags: [cppcheck]

test_problem_4:
  stage: problem4
  script:
    - echo "Testing problem 4";
    - git clone https://agile.bu.edu/gitlab/configs/ec447/hw-configs/hw4.git base_4
    - cp problem4.cpp base_4/tests
    - cd base_4/tests
    - make problem4
    - ./problem4
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem4"'
  tags: [c++-17]

tests/Makefile

0 → 100644
+37 −0
Original line number Diff line number Diff line
# Makefile, generated with support of ChatGPT

# Compiler and flags
CXX = g++
CXXFLAGS = -Wall -std=c++17

# Source files
PROBLEM2_SRCS = testProblem2.cpp problem2.cpp
PROBLEM3_SRCS = testProblem3.cpp problem3.cpp
SRCS = $(PROBLEM2_SRCS) $(PROBLEM3_SRCS)

# Object files
PROBLEM2_OBJS = testProblem2.o problem2.o
PROBLEM3_OBJS = testProblem3.o problem3.o
OBJS = $(PROBLEM2_OBJS) $(PROBLEM3_OBJS)

# Executable names
PROBLEM2_EXEC = problem2
PROBLEM3_EXEC = problem3

# Default target to build the executable
all: $(PROBLEM2_EXEC) $(PROBLEM3_EXEC)

# Rule to build the executable from object files
$(PROBLEM2_EXEC): $(PROBLEM2_OBJS) Makefile
	$(CXX) $(CXXFLAGS) -o $(PROBLEM2_EXEC) $(PROBLEM2_OBJS)

$(PROBLEM3_EXEC): $(PROBLEM3_OBJS) Makefile
	$(CXX) $(CXXFLAGS) -o $(PROBLEM3_EXEC) $(PROBLEM3_OBJS)

# Rules to build object files from source files, with dependency on the Common.h header
%.o: %.cpp %.h Makefile
	$(CXX) $(CXXFLAGS) -c $< -o $@

# Clean target to remove compiled files
clean:
	rm -f $(OBJS) $(EXEC)
Loading