Skip to content

Commit 7bc0f48

Browse files
arichardsonlemzwerg
authored andcommitted
[tests] Allow arbitrary build directories.
* tests/issue-1063/main.c (main): I am building with a build directory that is not directly inside the source tree, so the path `../tests/data/As.I.Lay.Dying.ttf` does not resolve to the test input file. This change passes the test data directory as an environment variable to allow arbitrary build directories. * tests/meson.build: Updated.
1 parent 685acc0 commit 7bc0f48

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

ChangeLog

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2021-07-16 Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
2+
3+
[tests] Allow arbitrary build directories.
4+
5+
* tests/issue-1063/main.c (main): I am building with a build
6+
directory that is not directly inside the source tree, so the path
7+
`../tests/data/As.I.Lay.Dying.ttf` does not resolve to the test
8+
input file. This change passes the test data directory as an
9+
environment variable to allow arbitrary build directories.
10+
11+
* tests/meson.build: Updated.
12+
113
2021-07-15 Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
214

315
* tests/issue-1063/main.c (main): Fix uninitialized variable.

tests/issue-1063/main.c

+25-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
1+
#include <limits.h>
12
#include <stdio.h>
23

34
#include <freetype/freetype.h>
45
#include <ft2build.h>
56

7+
68
int
79
main( void )
810
{
9-
FT_Library library;
10-
FT_Face face = NULL;
11+
FT_Library library;
12+
FT_Face face = NULL;
13+
14+
/*
15+
* We assume that `FREETYPE_TESTS_DATA_DIR` was set by `meson test`.
16+
* Otherwise we default to `../tests/data`.
17+
*
18+
* TODO (David): Rewrite this to pass the test directory through the
19+
* command-line.
20+
*/
21+
const char* testdata_dir = getenv( "FREETYPE_TESTS_DATA_DIR" );
22+
char filepath[PATH_MAX];
23+
1124

12-
/* Assumes this is run from out/ build directory though 'meson test -C out' */
13-
const char* filepath = "../tests/data/As.I.Lay.Dying.ttf";
25+
snprintf( filepath, sizeof( filepath ), "%s/%s",
26+
testdata_dir ? testdata_dir : "../tests/data",
27+
"As.I.Lay.Dying.ttf" );
1428

1529
FT_Init_FreeType( &library );
1630
if ( FT_New_Face( library, filepath, 0, &face ) != 0 )
@@ -19,13 +33,17 @@ main( void )
1933
return 1;
2034
}
2135

22-
for ( FT_ULong i = 59; i < 171; i++ )
36+
for ( FT_ULong i = 59; i < 171; i++ )
2337
{
24-
FT_UInt gid = FT_Get_Char_Index( face, i );
25-
FT_Error code = FT_Load_Glyph( face, gid, FT_LOAD_DEFAULT );
38+
FT_UInt gid = FT_Get_Char_Index( face, i );
39+
FT_Error code = FT_Load_Glyph( face, gid, FT_LOAD_DEFAULT );
40+
41+
2642
if ( code )
2743
printf( "unknown %d for char %lu, gid %u\n", code, i, gid );
2844
}
2945

3046
return 0;
3147
}
48+
49+
/* EOF */

tests/meson.build

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,12 @@ test_issue_1063 = executable('issue-1063',
33
dependencies: freetype_dep,
44
)
55

6-
test('issue-1063', test_issue_1063, suite: 'regression')
6+
test_env = ['FREETYPE_TESTS_DATA_DIR='
7+
+ join_paths(meson.current_source_dir(), 'data')]
78

9+
test('issue-1063',
10+
test_issue_1063,
11+
env: test_env,
12+
suite: 'regression')
13+
14+
# EOF

0 commit comments

Comments
 (0)