shithub: freetype+ttf2subf

Download patch

ref: 7bc0f48c274e2d1c7525ce5025351149b0803a91
parent: 685acc04dbad5ece9b7261d21f4a2546d787436c
author: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
date: Thu Jul 15 14:26:20 EDT 2021

[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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2021-07-16  Alex Richardson  <Alexander.Richardson@cl.cam.ac.uk>
+
+	[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.
+
 2021-07-15  Alex Richardson  <Alexander.Richardson@cl.cam.ac.uk>
 
 	* tests/issue-1063/main.c (main): Fix uninitialized variable.
--- a/tests/issue-1063/main.c
+++ b/tests/issue-1063/main.c
@@ -1,17 +1,31 @@
+#include <limits.h>
 #include <stdio.h>
 
 #include <freetype/freetype.h>
 #include <ft2build.h>
 
+
 int
 main( void )
 {
-  FT_Library library;
-  FT_Face    face = NULL;
+  FT_Library  library;
+  FT_Face     face = NULL;
 
-  /* Assumes this is run from out/ build directory though 'meson test -C out' */
-  const char* filepath = "../tests/data/As.I.Lay.Dying.ttf";
+  /*
+   * We assume that `FREETYPE_TESTS_DATA_DIR` was set by `meson test`.
+   * Otherwise we default to `../tests/data`.
+   *
+   * TODO (David): Rewrite this to pass the test directory through the
+   * command-line.
+   */
+  const char*  testdata_dir = getenv( "FREETYPE_TESTS_DATA_DIR" );
+  char         filepath[PATH_MAX];
 
+
+  snprintf( filepath, sizeof( filepath ), "%s/%s",
+            testdata_dir ? testdata_dir : "../tests/data",
+            "As.I.Lay.Dying.ttf" );
+
   FT_Init_FreeType( &library );
   if ( FT_New_Face( library, filepath, 0, &face ) != 0 )
   {
@@ -19,10 +33,12 @@
     return 1;
   }
 
-  for ( FT_ULong i = 59; i < 171; i++ )
+  for ( FT_ULong  i = 59; i < 171; i++ )
   {
-    FT_UInt  gid  = FT_Get_Char_Index( face, i );
-    FT_Error code = FT_Load_Glyph( face, gid, FT_LOAD_DEFAULT );
+    FT_UInt   gid  = FT_Get_Char_Index( face, i );
+    FT_Error  code = FT_Load_Glyph( face, gid, FT_LOAD_DEFAULT );
+
+
     if ( code )
       printf( "unknown %d for char %lu, gid %u\n", code, i, gid );
   }
@@ -29,3 +45,5 @@
 
   return 0;
 }
+
+/* EOF */
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -3,5 +3,12 @@
   dependencies: freetype_dep,
 )
 
-test('issue-1063', test_issue_1063, suite: 'regression')
+test_env = ['FREETYPE_TESTS_DATA_DIR='
+            + join_paths(meson.current_source_dir(), 'data')]
 
+test('issue-1063',
+  test_issue_1063,
+  env: test_env,
+  suite: 'regression')
+
+# EOF