Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CxxTest no longer works on macOS runners #18

Open
3 tasks
rboston628 opened this issue Apr 28, 2024 · 2 comments
Open
3 tasks

CxxTest no longer works on macOS runners #18

rboston628 opened this issue Apr 28, 2024 · 2 comments

Comments

@rboston628
Copy link
Owner

I raised an issue on CxxTest about failing runs on macOS runners. Given their track record of responding in a timely manner to issues, I expect it will never be fixed.

For reasons unknown to me, all tests on github's macOS runners are failing with the following:

2024-04-28T17:24:00.2212820Z cxxtestgen --error-printer -o tests/tests.cpp tests/*.h
2024-04-28T17:24:00.3473980Z /opt/homebrew/lib/python3.12/site-packages/cxxtest/cxxtest_parser.py:43: SyntaxWarning: invalid escape sequence '\s'
2024-04-28T17:24:00.3474770Z   lineCont_re = re.compile('(.*)\\\s*$')
2024-04-28T17:24:00.3475420Z /opt/homebrew/lib/python3.12/site-packages/cxxtest/cxxtest_parser.py:130: SyntaxWarning: invalid escape sequence '\s'
2024-04-28T17:24:00.3484810Z   classdef = '(?:::\s*)?(?:\w+\s*::\s*)*\w+'
2024-04-28T17:24:00.3485540Z /opt/homebrew/lib/python3.12/site-packages/cxxtest/cxxtest_parser.py:131: SyntaxWarning: invalid escape sequence '\s'
2024-04-28T17:24:00.3486290Z   baseclassdef = '(?:public|private|protected)\s+%s' % (classdef,)
2024-04-28T17:24:00.3487220Z /opt/homebrew/lib/python3.12/site-packages/cxxtest/cxxtest_parser.py:134: SyntaxWarning: invalid escape sequence '\s'
2024-04-28T17:24:00.3487910Z   testsuite = '(?:(?:::)?\s*CxxTest\s*::\s*)?TestSuite'
2024-04-28T17:24:00.3488630Z /opt/homebrew/lib/python3.12/site-packages/cxxtest/cxxtest_parser.py:39: SyntaxWarning: "is" with 'int' literal. Did you mean "=="?
2024-04-28T17:24:00.3489260Z   if len(suites) is 0 and not options.root:
2024-04-28T17:24:00.3489970Z /opt/homebrew/lib/python3.12/site-packages/cxxtest/cxxtest_parser.py:236: SyntaxWarning: "is not" with 'int' literal. Did you mean "!="?
2024-04-28T17:24:00.3490620Z   if len(suite['tests']) is not 0:
2024-04-28T17:24:00.3542910Z /opt/homebrew/lib/python3.12/site-packages/cxxtest/cxx_parser.py:2090: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?
2024-04-28T17:24:00.3544460Z   if p.type is "":
2024-04-28T17:24:00.3800500Z g++ --std=c++14 -o tests/tests.out \
2024-04-28T17:24:00.3801120Z 		obj/ThrainUnits.o obj/ThrainMode.o obj/ThrainIO.o obj/ThrainStellar.o \
2024-04-28T17:24:00.3802830Z 		 obj/MODES/Mode.o  obj/STARS/Star.o  obj/STARS/Polytrope.o  obj/STARS/ChandrasekharWD++.o  obj/STARS/MESA.o  obj/STARS/SimpleWD.o  obj/STARS/Isopycnic.o  obj/MODES/NonradialModeDriver.o  obj/MODES/CowlingModeDriver.o tests/tests.cpp -Isrc -Wuninitialized -Weffc++ --pedantic-errors lib/mylib.a
2024-04-28T17:24:00.3994470Z tests/tests.cpp:9:10: fatal error: 'cxxtest/TestListener.h' file not found
2024-04-28T17:24:00.3994920Z #include <cxxtest/TestListener.h>
2024-04-28T17:24:00.3995200Z          ^~~~~~~~~~~~~~~~~~~~~~~~
2024-04-28T17:24:00.6264420Z 1 error generated.
2024-04-28T17:24:00.6278370Z make: *** [tests] Error 1
2024-04-28T17:24:00.6289220Z ##[error]Process completed with exit code 2.

As shown, there are multiple syntax errors inside the python script cxxtest_parser.py using is for comparison of non-None values, and then a failure to find the cxxtest/TestListener.h header file.

Given several other issues that have occurred with CxxTest, I should consider a new testing framework.

  • Catch
  • gtest
  • make my own?
@rboston628
Copy link
Owner Author

I think the simplest solution is to only run the tests on unix, but run the builds on unix, macOS, and windows.

@rboston628
Copy link
Owner Author

I've looked more into Catch. It looks simple enough, and I have done some work figuring out how to integrate it into a makefile build.

Consider this file tree

-|
 |-- src/
 |   |-- model/
 |   |   |-- classA.cpp
 |   |   |-- classB.cpp
 |   |   |-- classA.hpp
 |   |   |-- classB.hpp
 |   |-- main.cpp
 |-- tests/
 |   |-- test_classA.cpp
 |   |-- test_classB.cpp
 |-- makefile

Then the makefile should be

# files to pull headers/source or to wite object code
IDIR=src
SDIR=src
ODIR=obj

# compiler and flags
CC=g++ --std=c++14
CFLAGS=-I$(IDIR) -Wall

## specify the needed files, separated as model and main
_MAIN = main
_MODEL = classA classB


# create path to class header/source
MODELDPS = $(patsubst %, $(IDIR)/model/%.hpp, $(_MODEL))
MODELSRC = $(patsubst %, $(SDIR)/model/%.cpp, $(_MODEL))
MAINSRC  = $(patsubst %, $(SDIR)/%.cpp, $(_MAIN))

# object files
MODELOBJ = $(patsubst %, $(ODIR)/model/%.o, $(_MODEL))
MAINOBJ  = $(patsubst %, $(ODIR)/%.o, $(_MAIN))

# specify code dependencies
MODELDEP = $(MODELDPS) $(MODELSRC)
MAINDEP = $(MAINSRC) $(MODELDEP)


## Main rule for creating the code base
## it will create model and main object files
code: $(MAINOBJ) $(MODELOBJ)
    $(CC) -o $@ $^ $(CFLAGS) 


## Rules for each subsection -- only update if their dependencies change

$(MODELOBJ): $(ODIR)/model/%.o: $(SDIR)/model/%.cpp $(MODELDEP)| obj/model/
    $(CC) -c -o $@ $< $(CFLAGS)


$(MAINOBJ): $(ODIR)/%.o: $(SDIR)/%.cpp $(MAINDEP)| obj/
    $(CC) -c -o $@ $< $(CFLAGS)

## create the tests

TEST = $(patsubst %, ./tests/test_%.cpp, $(_MODEL))

tests: code
    $(CC) -o ./tests/tests.o $(MAINOBJ) $(MODELOBJ) $(TEST) $(CFLAGS) -l catch2
    ./tests/tests.o --success

## this rule creates an obj directory if none exists
obj/:
    mkdir -p obj
obj/model/:
    mkdir -p obj/model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant