Loading ci_cd/.gitlab-ci.yml +2 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ stages: include: - local: 'ci_cd/problem2.yml' # Planar Subgraph - local: 'ci_cd/problem3a.yml' # Sequencing Simple - local: 'ci_cd/problem3b.yml' # Sequencing Complications default: timeout: 5m ci_cd/problem3a.yml 0 → 100644 +49 −0 Original line number Diff line number Diff line prebuild_problem_3a: stage: prebuild script: - | # Check if source files exist if [ ! -f "sequence.cpp" ]; then echo "sequence.cpp does not exist"; exit 1; fi - git clone https://agile.bu.edu/gitlab/configs/ec330/homeworks/homeworksix.git hw6 artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3a"' tags: [c++-17] compile_problem_3a: stage: compile needs: - job: prebuild_problem_3a artifacts: true script: - ls -l hw6/tests/ - if [ -f "impl/MaxPlanarSubgraph.cpp" ]; then cp impl/MaxPlanarSubgraph.cpp hw6/tests/impl/; fi - cp sequence.cpp hw6/tests/ - cd hw6/tests - make problem3a artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3a"' tags: [c++-17] exec_problem_3a: stage: test needs: - job: compile_problem_3a artifacts: true script: - cd hw6/tests - ./problem3a artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3a"' tags: [c++-17] ci_cd/problem3b.yml 0 → 100644 +49 −0 Original line number Diff line number Diff line prebuild_problem_3b: stage: prebuild script: - | # Check if source files exist if [ ! -f "sequence.cpp" ]; then echo "sequence.cpp does not exist"; exit 1; fi - git clone https://agile.bu.edu/gitlab/configs/ec330/homeworks/homeworksix.git hw6 artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3b"' tags: [c++-17] compile_problem_3b: stage: compile needs: - job: prebuild_problem_3b artifacts: true script: - ls -l hw6/tests/ - if [ -f "impl/MaxPlanarSubgraph.cpp" ]; then cp impl/MaxPlanarSubgraph.cpp hw6/tests/impl/; fi - cp sequence.cpp hw6/tests/ - cd hw6/tests - make problem3b artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3b"' tags: [c++-17] exec_problem_3b: stage: test needs: - job: compile_problem_3b artifacts: true script: - cd hw6/tests - ./problem3b artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3b"' tags: [c++-17] tests/Makefile +16 −4 Original line number Diff line number Diff line Loading @@ -6,23 +6,35 @@ CXXFLAGS = -std=c++17 # Source files PROBLEM2_SRCS = testMaxPlanarSubgraph.cpp impl/MaxPlanarSubgraph.cpp impl/Vertex.cpp SRCS = $(PROBLEM2_SRCS) PROBLEM3A_SRCS = testSequenceA.cpp sequence.cpp PROBLEM3B_SRCS = testSequenceB.cpp sequence.cpp SRCS = $(PROBLEM2_SRCS) $(PROBLEM3A_SRCS) $(PROBLEM3B_SRCS) # Object files PROBLEM2_OBJS = testMaxPlanarSubgraph.o impl/MaxPlanarSubgraph.o impl/Vertex.o OBJS = $(PROBLEM2_OBJS) PROBLEM3A_OBJS = testSequenceA.o sequence.o PROBLEM3B_OBJS = testSequenceB.o sequence.o OBJS = $(PROBLEM2_OBJS) $(PROBLEM3A_OBJS) $(PROBLEM3B_OBJS) # Executable name PROBLEM2_EXEC = problem2 EXECS = $(PROBLEM2_EXEC) PROBLEM3A_EXEC = problem3a PROBLEM3B_EXEC = problem3b EXECS = $(PROBLEM2_EXEC) $(PROBLEM3A_EXEC) $(PROBLEM3B_EXEC) # Default target to build the executable all: $(PROBLEM2_EXEC) all: $(PROBLEM2_EXEC) $(PROBLEM3A_EXEC) $(PROBLEM3B_EXEC) # Rule to build the executable from object files $(PROBLEM2_EXEC): $(PROBLEM2_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(PROBLEM2_EXEC) $(PROBLEM2_OBJS) $(PROBLEM3A_EXEC): $(PROBLEM3A_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(PROBLEM3A_EXEC) $(PROBLEM3A_OBJS) $(PROBLEM3B_EXEC): $(PROBLEM3B_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(PROBLEM3B_EXEC) $(PROBLEM3B_OBJS) # Rules to build object files from source files %.o: %.cpp Makefile $(CXX) $(CXXFLAGS) -c $< -o $@ Loading tests/testSequenceA.cpp 0 → 100644 +65 −0 Original line number Diff line number Diff line // // Problem3a tests developed by Rayan w help from AI // #include <iostream> #include <vector> #include <array> #include <string> using namespace std; string sequence(const vector<array<char,7>>& reads); // helper bool failExample(const char* testName, const string& msg, string expected, string got) { cerr << "[" << testName << " FAILED] " << msg << ": expected " << expected << ", got " << got << "\n"; return false; } bool test_0() { const char* T = "sequence 3a"; { vector<array<char,7>> reads = {{ {'A','B','C','D','E','F','G'} }}; string got = sequence(reads); string expected = "ABCDEFG"; if (got != expected) return failExample(T, "single read", expected, got); } { vector<array<char,7>> reads = {{ {'A','B','C','D','E','F','G'}, {'B','C','D','E','F','G','H'}, {'C','D','E','F','G','H','I'} }}; string got = sequence(reads); string expected = "ABCDEFGHI"; if (got != expected) return failExample(T, "simple overlap chain", expected, got); } return true; } int main() { bool results[] = { test_0() }; bool allPassed = true; for (size_t i = 0; i < std::size(results); i++) { cout << "Test of problem " << to_string(i) << ": " << (results[i] ? "passed" : "failed") << endl; allPassed &= results[i]; } if (allPassed) exit(0); else exit(-1); } No newline at end of file Loading
ci_cd/.gitlab-ci.yml +2 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ stages: include: - local: 'ci_cd/problem2.yml' # Planar Subgraph - local: 'ci_cd/problem3a.yml' # Sequencing Simple - local: 'ci_cd/problem3b.yml' # Sequencing Complications default: timeout: 5m
ci_cd/problem3a.yml 0 → 100644 +49 −0 Original line number Diff line number Diff line prebuild_problem_3a: stage: prebuild script: - | # Check if source files exist if [ ! -f "sequence.cpp" ]; then echo "sequence.cpp does not exist"; exit 1; fi - git clone https://agile.bu.edu/gitlab/configs/ec330/homeworks/homeworksix.git hw6 artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3a"' tags: [c++-17] compile_problem_3a: stage: compile needs: - job: prebuild_problem_3a artifacts: true script: - ls -l hw6/tests/ - if [ -f "impl/MaxPlanarSubgraph.cpp" ]; then cp impl/MaxPlanarSubgraph.cpp hw6/tests/impl/; fi - cp sequence.cpp hw6/tests/ - cd hw6/tests - make problem3a artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3a"' tags: [c++-17] exec_problem_3a: stage: test needs: - job: compile_problem_3a artifacts: true script: - cd hw6/tests - ./problem3a artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3a"' tags: [c++-17]
ci_cd/problem3b.yml 0 → 100644 +49 −0 Original line number Diff line number Diff line prebuild_problem_3b: stage: prebuild script: - | # Check if source files exist if [ ! -f "sequence.cpp" ]; then echo "sequence.cpp does not exist"; exit 1; fi - git clone https://agile.bu.edu/gitlab/configs/ec330/homeworks/homeworksix.git hw6 artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3b"' tags: [c++-17] compile_problem_3b: stage: compile needs: - job: prebuild_problem_3b artifacts: true script: - ls -l hw6/tests/ - if [ -f "impl/MaxPlanarSubgraph.cpp" ]; then cp impl/MaxPlanarSubgraph.cpp hw6/tests/impl/; fi - cp sequence.cpp hw6/tests/ - cd hw6/tests - make problem3b artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3b"' tags: [c++-17] exec_problem_3b: stage: test needs: - job: compile_problem_3b artifacts: true script: - cd hw6/tests - ./problem3b artifacts: paths: - hw6/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3b"' tags: [c++-17]
tests/Makefile +16 −4 Original line number Diff line number Diff line Loading @@ -6,23 +6,35 @@ CXXFLAGS = -std=c++17 # Source files PROBLEM2_SRCS = testMaxPlanarSubgraph.cpp impl/MaxPlanarSubgraph.cpp impl/Vertex.cpp SRCS = $(PROBLEM2_SRCS) PROBLEM3A_SRCS = testSequenceA.cpp sequence.cpp PROBLEM3B_SRCS = testSequenceB.cpp sequence.cpp SRCS = $(PROBLEM2_SRCS) $(PROBLEM3A_SRCS) $(PROBLEM3B_SRCS) # Object files PROBLEM2_OBJS = testMaxPlanarSubgraph.o impl/MaxPlanarSubgraph.o impl/Vertex.o OBJS = $(PROBLEM2_OBJS) PROBLEM3A_OBJS = testSequenceA.o sequence.o PROBLEM3B_OBJS = testSequenceB.o sequence.o OBJS = $(PROBLEM2_OBJS) $(PROBLEM3A_OBJS) $(PROBLEM3B_OBJS) # Executable name PROBLEM2_EXEC = problem2 EXECS = $(PROBLEM2_EXEC) PROBLEM3A_EXEC = problem3a PROBLEM3B_EXEC = problem3b EXECS = $(PROBLEM2_EXEC) $(PROBLEM3A_EXEC) $(PROBLEM3B_EXEC) # Default target to build the executable all: $(PROBLEM2_EXEC) all: $(PROBLEM2_EXEC) $(PROBLEM3A_EXEC) $(PROBLEM3B_EXEC) # Rule to build the executable from object files $(PROBLEM2_EXEC): $(PROBLEM2_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(PROBLEM2_EXEC) $(PROBLEM2_OBJS) $(PROBLEM3A_EXEC): $(PROBLEM3A_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(PROBLEM3A_EXEC) $(PROBLEM3A_OBJS) $(PROBLEM3B_EXEC): $(PROBLEM3B_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(PROBLEM3B_EXEC) $(PROBLEM3B_OBJS) # Rules to build object files from source files %.o: %.cpp Makefile $(CXX) $(CXXFLAGS) -c $< -o $@ Loading
tests/testSequenceA.cpp 0 → 100644 +65 −0 Original line number Diff line number Diff line // // Problem3a tests developed by Rayan w help from AI // #include <iostream> #include <vector> #include <array> #include <string> using namespace std; string sequence(const vector<array<char,7>>& reads); // helper bool failExample(const char* testName, const string& msg, string expected, string got) { cerr << "[" << testName << " FAILED] " << msg << ": expected " << expected << ", got " << got << "\n"; return false; } bool test_0() { const char* T = "sequence 3a"; { vector<array<char,7>> reads = {{ {'A','B','C','D','E','F','G'} }}; string got = sequence(reads); string expected = "ABCDEFG"; if (got != expected) return failExample(T, "single read", expected, got); } { vector<array<char,7>> reads = {{ {'A','B','C','D','E','F','G'}, {'B','C','D','E','F','G','H'}, {'C','D','E','F','G','H','I'} }}; string got = sequence(reads); string expected = "ABCDEFGHI"; if (got != expected) return failExample(T, "simple overlap chain", expected, got); } return true; } int main() { bool results[] = { test_0() }; bool allPassed = true; for (size_t i = 0; i < std::size(results); i++) { cout << "Test of problem " << to_string(i) << ": " << (results[i] ? "passed" : "failed") << endl; allPassed &= results[i]; } if (allPassed) exit(0); else exit(-1); } No newline at end of file