Skip to content
This repository was archived by the owner on Jan 15, 2021. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d1ad8f6

Browse files
committedJun 16, 2015
Merge pull request #268 from autopulated/master
fix handling of nested subirectories in test directory; add test for that
2 parents dfcf14c + b6b137c commit d1ad8f6

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed
 

‎yotta/lib/cmakegen.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def generateTestDirList(self, builddir, dirname, source_files, component, immedi
411411
for f in source_files:
412412
if f.lang in ('c', 'cpp', 'objc', 's'):
413413
subrelpath = os.path.relpath(f.relpath, dirname)
414-
subdir = os.path.split(subrelpath)[0]
414+
subdir = fsutils.fullySplitPath(subrelpath)[0]
415415
if subdir:
416416
subdirs[subdir].append(f)
417417
else:

‎yotta/test/cli/build.py

+52-2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,43 @@
134134
'''
135135
}
136136

137+
Test_Tests = {
138+
'module.json':'''{
139+
"name": "test-tests",
140+
"version": "0.0.0",
141+
"description": "Test yotta's compilation of tests.",
142+
"keywords": [],
143+
"author": "James Crosby <james.crosby@arm.com>",
144+
"licenses": [
145+
{
146+
"url": "https://spdx.org/licenses/Apache-2.0",
147+
"type": "Apache-2.0"
148+
}
149+
],
150+
"dependencies": {},
151+
"targetDependencies": {}
152+
}''',
153+
'source/foo.c':'''#include "stdio.h"
154+
int foo(){
155+
printf("foo!\\n");
156+
return 7;
157+
}''',
158+
'test-tests/foo.h':'int foo();',
159+
'test/a/bar.c':'#include "test-tests/foo.h"\nint main(){ foo(); return 0; }',
160+
'test/b/a/bar.c':'#include "test-tests/foo.h"\nint bar(); int main(){ foo(); bar(); return 0; }',
161+
'test/b/b/bar.c':'#include "stdio.h"\nint bar(){ printf("bar!\\n"); return 7; }',
162+
'test/c/a/a/bar.c':'#include "test-tests/foo.h"\nint bar(); int main(){ foo(); bar(); return 0; }',
163+
'test/c/b/a/bar.c':'#include "stdio.h"\nint bar(){ printf("bar!\\n"); return 7; }',
164+
'test/d/a/a/bar.c':'#include "test-tests/foo.h"\nint bar(); int main(){ foo(); bar(); return 0; }',
165+
'test/d/a/b/bar.c':'#include "stdio.h"\nint bar(){ printf("bar!\\n"); return 7; }',
166+
'test/e/a/a/a/bar.c':'#include "test-tests/foo.h"\nint bar(); int main(){ foo(); bar(); return 0; }',
167+
'test/e/b/a/a/bar.c':'#include "stdio.h"\nint bar(){ printf("bar!\\n"); return 7; }',
168+
'test/f/a/a/a/bar.c':'#include "test-tests/foo.h"\nint bar(); int main(){ foo(); bar(); return 0; }',
169+
'test/f/a/b/a/bar.c':'#include "stdio.h"\nint bar(){ printf("bar!\\n"); return 7; }',
170+
'test/g/a/a/a/bar.c':'#include "test-tests/foo.h"\nint bar(); int main(){ foo(); bar(); return 0; }',
171+
'test/g/a/a/b/bar.c':'#include "stdio.h"\nint bar(){ printf("bar!\\n"); return 7; }'
172+
}
173+
137174
def isWindows():
138175
# can't run tests that hit github without an authn token
139176
return os.name == 'nt'
@@ -171,20 +208,33 @@ def test_buildTrivialExe(self):
171208
rmRf(test_dir)
172209

173210
@unittest.skipIf(isWindows(), "can't build natively on windows yet")
174-
def test_buildZComplex(self):
211+
def test_buildComplex(self):
175212
test_dir = self.writeTestFiles(Test_Complex)
176213

177214
stdout = self.runCheckCommand(['--target', systemDefaultTarget(), 'build'], test_dir)
178215

179216
rmRf(test_dir)
180217

181218
@unittest.skipIf(isWindows(), "can't build natively on windows yet")
182-
def test_buildZZComplexSpaceInPath(self):
219+
def test_buildComplexSpaceInPath(self):
183220
test_dir = self.writeTestFiles(Test_Complex, True)
184221

185222
stdout = self.runCheckCommand(['--target', systemDefaultTarget(), 'build'], test_dir)
186223

187224
rmRf(test_dir)
225+
226+
@unittest.skipIf(isWindows(), "can't build natively on windows yet")
227+
def test_buildTests(self):
228+
test_dir = self.writeTestFiles(Test_Tests, True)
229+
stdout = self.runCheckCommand(['--target', systemDefaultTarget(), 'build'], test_dir)
230+
stdout = self.runCheckCommand(['--target', systemDefaultTarget(), 'test'], test_dir)
231+
self.assertIn('test-a', stdout)
232+
self.assertIn('test-c', stdout)
233+
self.assertIn('test-d', stdout)
234+
self.assertIn('test-e', stdout)
235+
self.assertIn('test-f', stdout)
236+
self.assertIn('test-g', stdout)
237+
rmRf(test_dir)
188238

189239

190240
def runCheckCommand(self, args, test_dir):

0 commit comments

Comments
 (0)
This repository has been archived.