diff --git a/Dockerfile b/Dockerfile index 1e3b381..89800f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,33 @@ FROM ubuntu:latest -LABEL title="C++ Analysis" -LABEL version=0.2 -ENV CXXFLAGS=-std=c++17 +LABEL title="CPP Container" +LABEL version=0.1 +ENV GTEST_REPO=/googletest +ENV GTEST_DIR=${GTEST_REPO}/googletest ENV WORKDIR=/usr/src WORKDIR /usr/src +# Set Docker arguments +ARG DEBIAN_FRONTEND=noninteractive + # Install dependencies RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive \ - apt-get install -y -f \ - dos2unix \ + apt-get install -y \ build-essential \ g++ \ cmake \ git-all \ - pmccabe \ - cccc + dos2unix -# Get source and make sure it uses unix line feed (no carriage return) -COPY . ./ -RUN dos2unix * +# Setup GoogleTest +RUN git clone --depth=1 https://github.com/google/googletest ${GTEST_REPO} +RUN mkdir ${GTEST_REPO}/build && cd ${GTEST_REPO}/build \ + && cmake .. -DBUILD_GMOCK=OFF && make && cd ${WORKDIR} -# Load repo into image +# Copy repo source into container COPY . ${WORKDIR} -# Run static analysis -CMD pmccabe *.cpp -v && \ - cccc --lang=c++ --outdir=report *.cpp +# Assure Unix linefeed for all files +RUN find . -type f -print0 | xargs -0 dos2unix -- + +# Build project +CMD sh -c ${WORKDIR}/test_runner.sh \ No newline at end of file diff --git a/README.md b/README.md index 2b9d6b3..abeadc2 100644 --- a/README.md +++ b/README.md @@ -24,17 +24,17 @@ The game will randomly-select a 5-letter word and you have unlimited guesses to To use the project development environment, build the docker image using: ``` -docker build -t cpp-analysis . +docker build -t cpp-container . ``` To run static analysis in the dev container: ``` -docker run -it cpp-analysis +docker run -it cpp-container ``` To bind file changes between the host and container: ``` -docker run -v "$(pwd)":/usr/src -it cpp-analysis +docker run -v "$(pwd)":/usr/src -it cpp-container ``` \ No newline at end of file diff --git a/dictionary.cpp b/dictionary.cpp index 0c53ba4..0544216 100644 --- a/dictionary.cpp +++ b/dictionary.cpp @@ -6,7 +6,7 @@ // initiate word dictionary from file .wordler.data and store them as a // list of upper case letters dictionary::dictionary(){ - dictionary_file = ".wordler.data" // default file + dictionary_file = ".wordler.data"; // default file load_dictionary(dictionary_file); } diff --git a/test_runner.sh b/test_runner.sh new file mode 100755 index 0000000..d940e15 --- /dev/null +++ b/test_runner.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +apt-get -y install pmccabe +pmccabe -v *.cpp +make clean && make \ No newline at end of file