mirror of
https://github.com/aantron/better-enums.git
synced 2025-12-06 08:46:42 +08:00
Made the test script use only the system compiler by default and extended some
support to VC++. The unit test is currently not being run on VC++ due to a problem with CxxTest, Cygwin, and paths. However, the examples are being compiled and having their output checked, and the multiple translation unit test is being run. Running "(cd test ; ./test.py)" should now run tests only using the default compiler, on a Unix-like system. test.py --all runs tests on the full array of compilers that I have installed and symlinked on my development machines.
This commit is contained in:
parent
ccc7858f14
commit
3a316e6f79
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
*.pyc
|
||||
*.obj
|
||||
*.exe
|
||||
scratch/
|
||||
doc/html/
|
||||
|
||||
@ -46,7 +46,7 @@ Simply add `enum.h` to your project.
|
||||
- Explicit choice of underlying representation type.
|
||||
- Header-only.
|
||||
- No dependencies besides the standard library.
|
||||
- Tested on gcc 4.3 to 5.1, clang 3.3 to 3.6, and VS2013.
|
||||
- Tested on gcc 4.3 to 5.1, clang 3.3 to 3.6, and VS2013, VS2015.
|
||||
|
||||
## Contact
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ tested with clang++ and g++, and Visual C++:
|
||||
|
||||
- clang++ 3.3 to 3.6
|
||||
- g++ 4.3 to 5.1
|
||||
- Visual C++ 2013
|
||||
- Visual C++ 2013 Update 4, Visual C++ 2015 RC
|
||||
|
||||
In principle, Better Enums can be used with any compiler that supports either
|
||||
|
||||
@ -22,7 +22,10 @@ demos and tutorials, and a multiple translation unit linking test.
|
||||
### Tested configurations
|
||||
|
||||
~~~comment
|
||||
vc2015 /EHsc
|
||||
vc2015 /EHsc /DBETTER_ENUMS_STRICT_CONVERSION
|
||||
vc2013 /EHsc
|
||||
vc2013 /EHsc /DBETTER_ENUMS_STRICT_CONVERSION
|
||||
clang++36 -std=c++11
|
||||
clang++36 -std=c++11 -DBETTER_ENUMS_STRICT_CONVERSION
|
||||
clang++36 -std=c++11 -DBETTER_ENUMS_CONSTEXPR_TO_STRING
|
||||
|
||||
2
enum.h
2
enum.h
@ -290,7 +290,7 @@ _ENUM_CONSTEXPR inline char _select(const char *from, std::size_t from_length,
|
||||
|
||||
_ENUM_CONSTEXPR inline char _toLowercaseAscii(char c)
|
||||
{
|
||||
return c >= 0x41 && c <= 0x5A ? (char) (c + 0x20) : c;
|
||||
return c >= 0x41 && c <= 0x5A ? (char)(c + 0x20) : c;
|
||||
}
|
||||
|
||||
_ENUM_CONSTEXPR inline bool _namesMatch(const char *stringizedName,
|
||||
|
||||
@ -21,7 +21,7 @@ all : $(BINARIES)
|
||||
|
||||
.PHONY : clean
|
||||
clean :
|
||||
rm -rf *.exe
|
||||
rm -rf *.exe *.obj
|
||||
|
||||
.PHONY : run
|
||||
run : all
|
||||
|
||||
@ -5,7 +5,7 @@ platform :
|
||||
|
||||
.PHONY : clean
|
||||
clean :
|
||||
rm -rf platform
|
||||
rm -rf platform *.obj
|
||||
|
||||
.PHONY : default
|
||||
default : run
|
||||
|
||||
60
test/test.py
60
test/test.py
@ -3,6 +3,7 @@
|
||||
import glob
|
||||
import os
|
||||
import os.path
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
@ -15,6 +16,7 @@ CXXTEST_SOURCE = "cxxtest/tests.h"
|
||||
CXXTEST_GENERATED = "cxxtest/tests.cc"
|
||||
|
||||
quiet = True
|
||||
windows = False
|
||||
|
||||
|
||||
|
||||
@ -68,10 +70,12 @@ class Configuration(object):
|
||||
|
||||
def elaborate(self, include, output, source):
|
||||
command = self._command
|
||||
if command.startswith("clang") or command.startswith("g++"):
|
||||
if re.match("clang|[gc]\+\+", command) != None:
|
||||
return "%s -I%s -Wall -o %s %s" % (command, include, output, source)
|
||||
elif re.match("vc|cl", command) != None:
|
||||
return "%s /I%s /Fe%s %s" % (command, include, output, source)
|
||||
else:
|
||||
raise Error("unrecognized compiler in '%s'" % command)
|
||||
raise Exception("unrecognized compiler in '%s'" % command)
|
||||
|
||||
def make_directories(self):
|
||||
base = self.directory()
|
||||
@ -111,15 +115,23 @@ class Configuration(object):
|
||||
run(command, True)
|
||||
|
||||
output = run(binary)
|
||||
output = re.sub("\r\n", "\n", output)
|
||||
if output != expected_example_outputs[title]:
|
||||
print output
|
||||
print "output does not match expected output"
|
||||
sys.exit(1)
|
||||
|
||||
cxxtest_binary = os.path.join(base, "cxxtest", "tests.exe")
|
||||
command = self.elaborate("..", cxxtest_binary, CXXTEST_GENERATED)
|
||||
run(command, True)
|
||||
run(cxxtest_binary)
|
||||
# This is currently not done on because on Cygwin, cxxtest tries to use
|
||||
# a Cygwin path to include tests.h. That path is in Unix format, which
|
||||
# does not resolve to a valid path when handled by VC++. A workaround is
|
||||
# to detect Cygwin and rewrite the path, but I am saving that for an
|
||||
# improved version of test.py, since there are many things that need to
|
||||
# be rewritten for this script to stay maintainable.
|
||||
if not windows:
|
||||
cxxtest_binary = os.path.join(base, "cxxtest", "tests.exe")
|
||||
command = self.elaborate("..", cxxtest_binary, CXXTEST_GENERATED)
|
||||
run(command, True)
|
||||
run(cxxtest_binary)
|
||||
|
||||
link_sources = glob.glob("link/*.cc")
|
||||
link_binary = os.path.join(base, "link", "link.exe")
|
||||
@ -199,7 +211,15 @@ def gnu_pre_enum_class(command):
|
||||
Configuration(command + "-c++98", command + " -std=c++98", skip_cxx98)
|
||||
]
|
||||
|
||||
CONFIGURATIONS = \
|
||||
def vc(command):
|
||||
return [
|
||||
Configuration(command, command + " /EHsc", skip_cxx98),
|
||||
Configuration(command + "-strict-conversion",
|
||||
command + " /EHsc /DBETTER_ENUMS_STRICT_CONVERSION",
|
||||
skip_cxx98)
|
||||
]
|
||||
|
||||
unix_configurations = \
|
||||
modern_gnu("clang++36") + \
|
||||
modern_gnu("clang++35") + \
|
||||
modern_gnu("clang++34") + \
|
||||
@ -213,15 +233,39 @@ CONFIGURATIONS = \
|
||||
gnu_pre_constexpr("g++44") + \
|
||||
gnu_pre_enum_class("g++43")
|
||||
|
||||
windows_configurations = vc("vc2015") + vc("vc2013")
|
||||
|
||||
unix_default = Configuration("default", "c++ --std=c++11")
|
||||
|
||||
windows_default = Configuration("default", "cl /EHsc")
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
global quiet
|
||||
global windows
|
||||
|
||||
load_expected_outputs()
|
||||
|
||||
run("cxxtestgen --error-printer -o %s %s" %
|
||||
(CXXTEST_GENERATED, CXXTEST_SOURCE))
|
||||
|
||||
for configuration in CONFIGURATIONS:
|
||||
if re.search("Windows|CYGWIN", platform.system()) != None:
|
||||
full = windows_configurations
|
||||
default = windows_default
|
||||
windows = True
|
||||
else:
|
||||
full = unix_configurations
|
||||
default = unix_default
|
||||
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "--all":
|
||||
configurations = full
|
||||
quiet = True
|
||||
else:
|
||||
configurations = [default]
|
||||
quiet = False
|
||||
|
||||
for configuration in configurations:
|
||||
configuration.make_all()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user