Changeset 202433 in webkit
- Timestamp:
- Jun 24, 2016 11:34:20 AM (8 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r202418 r202433 1 2016-06-24 David Kilzer <ddkilzer@apple.com> 2 3 parser_unittests.pl should not hardcode list of tests 4 <https://webkit.org/b/159074> 5 6 Reviewed by Daniel Bates. 7 8 * Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl: 9 Update to read the list of tests from the 'resources' directory, 10 and instead map file extensions to subroutine names. Switch to 11 use File::Basename::fileparse() to get basename and file 12 extension for each test. 13 (readTestFiles): Added. Reads files from the directory passed 14 in and ignores: hidden files, anything that isn't a plain file, 15 and expected test results files. 16 1 17 2016-06-23 Simon Fraser <simon.fraser@apple.com> 2 18 -
trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl
r189355 r202433 2 2 # 3 3 # Copyright (C) 2011 Google Inc. All rights reserved. 4 # Copyright (C) 2015-2016 Apple Inc. All rights reserved. 4 5 # 5 6 # This library is free software; you can redistribute it and/or … … 19 20 20 21 # This script tests the parser of prepare-ChangeLog (i.e. get_function_line_ranges_for_XXXX()). 21 # This script runs the unittests specified in @testFiles.22 # This script runs the unittests in the 'resources' subdirectory. 22 23 23 24 use strict; … … 36 37 sub captureOutput($); 37 38 sub convertAbsolutepathToWebKitPath($); 39 sub readTestFiles($); 38 40 39 my %testFiles = ("perl_unittests.pl" => "get_function_line_ranges_for_perl", 40 "python_unittests.py" => "get_function_line_ranges_for_python", 41 "java_unittests.java" => "get_function_line_ranges_for_java", 42 "cpp_unittests.cpp" => "get_function_line_ranges_for_cpp", 43 "javascript_unittests.js" => "get_function_line_ranges_for_javascript", 44 "css_unittests.css" => "get_selector_line_ranges_for_css", 45 "css_unittests_warning.css" => "get_selector_line_ranges_for_css", 46 "swift_unittests.swift" => "get_function_line_ranges_for_swift", 47 ); 41 use constant EXPECTED_RESULTS_SUFFIX => "-expected.txt"; 42 43 my %methodForFileExtension = ( 44 ".cpp" => "get_function_line_ranges_for_cpp", 45 ".css" => "get_selector_line_ranges_for_css", 46 ".java" => "get_function_line_ranges_for_java", 47 ".js" => "get_function_line_ranges_for_javascript", 48 ".pl" => "get_function_line_ranges_for_perl", 49 ".py" => "get_function_line_ranges_for_python", 50 ".swift" => "get_function_line_ranges_for_swift", 51 ); 48 52 49 53 my $resetResults; 50 54 GetOptions('reset-results' => \$resetResults); 51 55 56 my $resourcesDirectory = File::Spec->catdir($FindBin::Bin, "resources"); 57 my @suffixList = keys %methodForFileExtension; 58 my @testFiles = readTestFiles($resourcesDirectory); 52 59 my @testSet; 53 foreach my $testFile (sort keys %testFiles) { 54 my $basename = $testFile; 55 $basename = $1 if $basename =~ /^(.*)\.[^\.]*$/; 56 push @testSet, {method => $testFiles{$testFile}, 57 inputFile => File::Spec->catdir($FindBin::Bin, "resources", $testFile), 58 expectedFile => File::Spec->catdir($FindBin::Bin, "resources", $basename . "-expected.txt")}; 60 foreach my $testFile (sort @testFiles) { 61 my ($basename, undef, $extension) = fileparse($testFile, @suffixList); 62 push @testSet, { 63 method => $methodForFileExtension{$extension}, 64 inputFile => File::Spec->catfile($resourcesDirectory, $testFile), 65 expectedFile => File::Spec->catfile($resourcesDirectory, $basename . EXPECTED_RESULTS_SUFFIX), 66 }; 59 67 } 60 68 … … 131 139 return $string; 132 140 } 141 142 sub readTestFiles($) 143 { 144 my ($directory) = @_; 145 my @files; 146 opendir(DIR, $directory) || die "Could not open $directory: $!"; 147 while (readdir(DIR)) { 148 next if /^\./; 149 next if ! -f File::Spec->catfile($directory, $_); 150 next if /\Q@{[EXPECTED_RESULTS_SUFFIX]}\E$/; 151 push @files, $_; 152 } 153 closedir(DIR); 154 return @files; 155 }
Note: See TracChangeset
for help on using the changeset viewer.