mirror of
https://github.com/bensuperpc/dockcross.git
synced 2024-11-12 22:21:32 +01:00
browser-asmjs: Add CircleCI testing.
This commit is contained in:
parent
f647f8991b
commit
5420fc0543
@ -7,6 +7,7 @@ dependencies:
|
|||||||
- docker info
|
- docker info
|
||||||
- docker pull thewtex/cross-compiler-base
|
- docker pull thewtex/cross-compiler-base
|
||||||
- docker pull thewtex/cross-compiler-android-arm
|
- docker pull thewtex/cross-compiler-android-arm
|
||||||
|
- docker pull thewtex/cross-compiler-browser-asmjs
|
||||||
|
|
||||||
test:
|
test:
|
||||||
override:
|
override:
|
||||||
@ -14,6 +15,8 @@ test:
|
|||||||
- docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-base python /usr/src/test/run.py --emulator 'sh -c'
|
- docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-base python /usr/src/test/run.py --emulator 'sh -c'
|
||||||
- make android-arm
|
- make android-arm
|
||||||
- docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-android-arm python /usr/src/test/run.py
|
- docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-android-arm python /usr/src/test/run.py
|
||||||
|
- make browser-asmjs
|
||||||
|
- docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-browser-asmjs python /usr/src/test/run.py --emulator /usr/bin/node --exe-suffix ".js"
|
||||||
|
|
||||||
deployment:
|
deployment:
|
||||||
hub:
|
hub:
|
||||||
|
37
test/run.py
37
test/run.py
@ -35,7 +35,8 @@ def test_none_build_system(build_dir, language, source, linker_flags):
|
|||||||
return subprocess.call(build_cmd)
|
return subprocess.call(build_cmd)
|
||||||
|
|
||||||
|
|
||||||
def test_cmake_build_system(build_dir, language, source, emulator, linker_flags):
|
def test_cmake_build_system(build_dir, language, source, emulator, linker_flags,
|
||||||
|
exe_suffix):
|
||||||
shutil.copy(source, build_dir)
|
shutil.copy(source, build_dir)
|
||||||
print('Building ' + source + ' with CMake...')
|
print('Building ' + source + ' with CMake...')
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ def test_cmake_build_system(build_dir, language, source, emulator, linker_flags)
|
|||||||
fp.write('add_executable(a.out ' + os.path.basename(source) + ')\n')
|
fp.write('add_executable(a.out ' + os.path.basename(source) + ')\n')
|
||||||
if emulator:
|
if emulator:
|
||||||
fp.write('enable_testing()\n')
|
fp.write('enable_testing()\n')
|
||||||
fp.write('add_test(emulator-in-cmake a.out)\n')
|
fp.write('add_test(NAME emulator-in-cmake COMMAND a.out)\n')
|
||||||
|
|
||||||
os.mkdir('build')
|
os.mkdir('build')
|
||||||
os.chdir('build')
|
os.chdir('build')
|
||||||
@ -67,11 +68,12 @@ def test_cmake_build_system(build_dir, language, source, emulator, linker_flags)
|
|||||||
if emulator:
|
if emulator:
|
||||||
if subprocess.call(['ctest']):
|
if subprocess.call(['ctest']):
|
||||||
return 1
|
return 1
|
||||||
shutil.copy('a.out', build_dir)
|
shutil.copy('a.out' + exe_suffix, build_dir)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def test_source(source, language, build_system, emulator, linker_flags):
|
def test_source(source, language, build_system, emulator, linker_flags,
|
||||||
|
exe_suffix):
|
||||||
result = 0
|
result = 0
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
build_dir = tempfile.mkdtemp()
|
build_dir = tempfile.mkdtemp()
|
||||||
@ -80,14 +82,15 @@ def test_source(source, language, build_system, emulator, linker_flags):
|
|||||||
if build_system == 'None':
|
if build_system == 'None':
|
||||||
result += test_none_build_system(build_dir, language, source, linker_flags)
|
result += test_none_build_system(build_dir, language, source, linker_flags)
|
||||||
elif build_system == 'CMake':
|
elif build_system == 'CMake':
|
||||||
result += test_cmake_build_system(build_dir, language, source, emulator, linker_flags)
|
result += test_cmake_build_system(build_dir, language, source, emulator,
|
||||||
|
linker_flags, exe_suffix)
|
||||||
else:
|
else:
|
||||||
print('Unknown build system: ' + build_system)
|
print('Unknown build system: ' + build_system)
|
||||||
result += 1
|
result += 1
|
||||||
|
|
||||||
if emulator:
|
if emulator:
|
||||||
cmd = emulator
|
cmd = emulator
|
||||||
cmd += ' ' + os.path.join(build_dir, 'a.out')
|
cmd += ' ' + os.path.join(build_dir, 'a.out' + exe_suffix)
|
||||||
print('Running ' + cmd + '...')
|
print('Running ' + cmd + '...')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
result += subprocess.call(cmd, shell=True)
|
result += subprocess.call(cmd, shell=True)
|
||||||
@ -98,30 +101,34 @@ def test_source(source, language, build_system, emulator, linker_flags):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def test_build_system(test_dir, language, build_system, emulator, linker_flags):
|
def test_build_system(test_dir, language, build_system, emulator, linker_flags,
|
||||||
|
exe_suffix):
|
||||||
print('\n\n--------------------------------------------------------')
|
print('\n\n--------------------------------------------------------')
|
||||||
print('Testing ' + build_system + ' build system with the ' +
|
print('Testing ' + build_system + ' build system with the ' +
|
||||||
language + ' language\n')
|
language + ' language\n')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
result = 0
|
result = 0
|
||||||
for source in glob.glob(os.path.join(test_dir, language, '*')):
|
for source in glob.glob(os.path.join(test_dir, language, '*')):
|
||||||
result += test_source(source, language, build_system, emulator, linker_flags)
|
result += test_source(source, language, build_system, emulator,
|
||||||
|
linker_flags, exe_suffix)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def test_language(test_dir, language, build_systems, emulator, linker_flags):
|
def test_language(test_dir, language, build_systems, emulator, linker_flags,
|
||||||
|
exe_suffix):
|
||||||
result = 0
|
result = 0
|
||||||
for build_system in build_systems:
|
for build_system in build_systems:
|
||||||
result += test_build_system(test_dir,
|
result += test_build_system(test_dir,
|
||||||
language,
|
language,
|
||||||
build_system,
|
build_system,
|
||||||
emulator,
|
emulator,
|
||||||
linker_flags)
|
linker_flags,
|
||||||
|
exe_suffix)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def run_tests(test_dir, languages=('C', 'C++'), build_systems=('None', 'CMake'),
|
def run_tests(test_dir, languages=('C', 'C++'), build_systems=('None', 'CMake'),
|
||||||
emulator=None, linker_flags=None):
|
emulator=None, linker_flags=None, exe_suffix=''):
|
||||||
"""Run the tests found in test_dir where each directory corresponds to an
|
"""Run the tests found in test_dir where each directory corresponds to an
|
||||||
entry in languages. Every source within a language directory is built. The
|
entry in languages. Every source within a language directory is built. The
|
||||||
output executable is also run with the emulator if provided."""
|
output executable is also run with the emulator if provided."""
|
||||||
@ -131,7 +138,8 @@ def run_tests(test_dir, languages=('C', 'C++'), build_systems=('None', 'CMake'),
|
|||||||
language,
|
language,
|
||||||
build_systems,
|
build_systems,
|
||||||
emulator,
|
emulator,
|
||||||
linker_flags)
|
linker_flags,
|
||||||
|
exe_suffix)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@ -146,6 +154,8 @@ if __name__ == '__main__':
|
|||||||
help='Emulator used to test generated executables')
|
help='Emulator used to test generated executables')
|
||||||
parser.add_argument('--linker-flags', '-w', nargs='+',
|
parser.add_argument('--linker-flags', '-w', nargs='+',
|
||||||
help='Extra compilation linker flags')
|
help='Extra compilation linker flags')
|
||||||
|
parser.add_argument('--exe-suffix', '-s', default='',
|
||||||
|
help='Suffix for generated executables')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
test_dir = os.path.dirname(os.path.abspath(__file__))
|
test_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
@ -154,4 +164,5 @@ if __name__ == '__main__':
|
|||||||
languages=args.languages,
|
languages=args.languages,
|
||||||
build_systems=args.build_systems,
|
build_systems=args.build_systems,
|
||||||
emulator=args.emulator,
|
emulator=args.emulator,
|
||||||
linker_flags=args.linker_flags) != 0)
|
linker_flags=args.linker_flags,
|
||||||
|
exe_suffix=args.exe_suffix) != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user