⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 277311 in webkit


Ignore:
Timestamp:
May 10, 2021, 5:41:50 PM (5 years ago)
Author:
Chris Gambrell
Message:

[LayoutTests] Decouple http/tests/media/resources/create-id3-db.php from webserver
https://bugs.webkit.org/show_bug.cgi?id=224561
<rdar://problem/76653054>

Reviewed by Jonathan Bedard.

Replacing the creation of metadata.db with JSON into a new file named metadata.json. This standalone script remains in PHP to be able to still use getid3.

  • http/tests/media/resources/create-id3-db.php: Removed.
  • http/tests/resources/dir-helpers.php: Removed.
  • http/tests/resources/portabilityLayer.php: Removed.
  • media/content/create-id3-db: Copied from LayoutTests/http/tests/media/resources/create-id3-db.php.
Location:
trunk/LayoutTests
Files:
2 deleted
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r277308 r277311  
     12021-05-10  Chris Gambrell  <cgambrell@apple.com>
     2
     3        [LayoutTests] Decouple http/tests/media/resources/create-id3-db.php from webserver
     4        https://bugs.webkit.org/show_bug.cgi?id=224561
     5        <rdar://problem/76653054>
     6
     7        Reviewed by Jonathan Bedard.
     8
     9        Replacing the creation of metadata.db with JSON into a new file named metadata.json. This standalone script remains in PHP to be able to still use getid3.
     10
     11        * http/tests/media/resources/create-id3-db.php: Removed.
     12        * http/tests/resources/dir-helpers.php: Removed.
     13        * http/tests/resources/portabilityLayer.php: Removed.
     14        * media/content/create-id3-db: Copied from LayoutTests/http/tests/media/resources/create-id3-db.php.
     15
    1162021-05-10  Amir Mark Jr  <amir_mark@apple.com>
    217
  • trunk/LayoutTests/media/content/create-id3-db

    • Property svn:executable set to *
    r277309 r277311  
     1#!/usr/bin/env php
     2
    13<?php
    24
     
    79
    810
    9     // This script creates, overwriting if needed, the "metadata.db"
     11    // This script creates, overwriting if needed, the "metadata.json"
    1012    // file used by scripts such as "serve-video.py".
    1113    //
    12     // For creating or updating an existing file you have to run the
    13     // http server used by the tests with:
    14     //
    15     // $ Tools/Scripts/run-webkit-httpd
    16     //
    17     // Then you will just have to use a browser to open an URL of the
    18     // type:
    19     //
    20     // http://127.0.0.1:8000/media/resources/create-id3-db.php?name=../../../../media/content/silence.wav
    21     //
    22     // With this, a new "metadaba.db" file will be create in the
     14    // For creating or updating an existing file you have to run
     15    // the file as an executable, passing a single argument which
     16    // is the name of the file we are accessing to get the media
     17    // directory
     18    //
     19    // With this, a new "metadaba.json" file will be create in the
    2320    // directory containing the referred file. In this example, the
    2421    // database will be created at:
    2522    //
    26     // $ LayoutTests/media/content/metadata.db
    27 
    28 
    29     require_once '../../resources/portabilityLayer.php';
    30     require_once '../../resources/dir-helpers.php';
     23    // $ LayoutTests/media/content/metadata.json
     24
     25
     26    function tmpdir($dir=FALSE, $prefix='php')
     27    {
     28        if ($dir) {
     29            $tmpFile = tempnam($dir, $prefix);
     30        } else {
     31            if (!sys_get_temp_dir())
     32                return FALSE;
     33            $tmpFile = tempnam(sys_get_temp_dir(), $prefix);
     34        }
     35
     36        if (!file_exists($tmpFile))
     37            return FALSE;
     38        unlink($tmpFile);
     39        mkdir($tmpFile);
     40        if (!is_dir($tmpFile))
     41            return FALSE;
     42
     43        return $tmpFile;
     44    }
     45
     46
     47    function rrmdir($dir)
     48    {
     49        if (is_dir($dir)) {
     50            $objects = array_diff(scandir($dir), array(".", ".."));
     51            foreach ($objects as $object)
     52                (is_dir($dir . "/" . $object)) ? rrmdir($dir . "/" . $object) : unlink($dir . "/" . $object);
     53            reset($objects);
     54            rmdir($dir);
     55        }
     56    }
     57
     58
     59    function rcopy($src, $dst)
     60    {
     61        if (file_exists($dst))
     62            rrmdir($dst);
     63        if (is_dir($src)) {
     64            mkdir($dst);
     65            $files = array_diff(scandir($src), array(".", ".."));
     66            foreach ($files as $file)
     67              rcopy("$src/$file", "$dst/$file");
     68        } else if (file_exists($src)) {
     69            copy($src, $dst);
     70        }
     71    }
     72
     73
     74    function first_dir($name, $dir=FALSE)
     75    {
     76        $result = FALSE;
     77        $root = $dir ? $dir : "./";
     78        $queue = array(realpath($root));
     79
     80        while (sizeof($queue)) {
     81            $vertex = array_pop($queue);
     82            $objects = array_diff(scandir($vertex), array(".", ".."));
     83            foreach ($objects as $object) {
     84                $fullPath = $vertex . "/" . $object;
     85                if (is_dir($fullPath)) {
     86                    if ($name == basename($fullPath)) {
     87                        $result = $fullPath;
     88                        return $result;
     89                    } else {
     90                        array_unshift($queue, $fullPath);
     91                    }
     92                }
     93            }
     94        }
     95    }
     96
    3197
    3298    // 500 on errors
     
    34100    $htmlMessage = "";
    35101
    36     if (!array_key_exists("name", $_GET)) {
     102    if (sizeof($argv) < 2) {
    37103        trigger_error("You have not specified a 'name' parameter.", E_USER_WARNING);
    38104        goto answering;
    39105    }
    40     $mediaDirectory = dirname($_GET["name"]);
     106    $mediaDirectory = dirname($argv[1]);
    41107
    42108    if (!is_dir($mediaDirectory)) {
     
    44110        goto answering;
    45111    }
    46     $databaseFile = realpath($mediaDirectory) . "/metadata.db";
     112    $databaseFile = realpath($mediaDirectory) . "/metadata.json";
    47113
    48114    if (file_exists($databaseFile)) {
     
    139205    }
    140206
    141     if (!file_put_contents($databaseFile, serialize($playFiles))) {
     207    if (!file_put_contents($databaseFile, json_decode($playFiles))) {
    142208        trigger_error("Impossible to write the getid3 db.", E_USER_WARNING);
    143209        goto answering;
Note: See TracChangeset for help on using the changeset viewer.