WebKit Bugzilla
Attachment 342196 Details for
Bug 185783
: test262/Runner.pm: add unit tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185783-20180607144939.patch (text/plain), 14.38 KB, created by
valerie
on 2018-06-07 11:49:40 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
valerie
Created:
2018-06-07 11:49:40 PDT
Size:
14.38 KB
patch
obsolete
>Subversion Revision: 232587 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index d31a51785095d79f6c0d0c68cade76d33a26559a..cad2e2d4000019b09a2143df5d11b96e70d9086e 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,24 @@ >+2018-06-07 Valerie R Young <valerie@bocoup.com> >+ >+ test262/Runner.pm: add unit tests >+ https://bugs.webkit.org/show_bug.cgi?id=185783 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Scripts/webkitperl/test262_unittest/README: Added. >+ * Scripts/webkitperl/test262_unittest/fixtures/expectations-compare.yaml: Added. >+ * Scripts/webkitperl/test262_unittest/fixtures/expectations.yaml: Added. >+ * Scripts/webkitperl/test262_unittest/fixtures/test/LICENSE: Added. >+ * Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-failing-with-new-error.js: Added. >+ * Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-failing.js: Added. >+ * Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-passing.js: Added. >+ (f): >+ * Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-pass-now-failing.js: Added. >+ * Scripts/webkitperl/test262_unittest/fixtures/test/fail.js: Added. >+ * Scripts/webkitperl/test262_unittest/fixtures/test/pass.js: Added. >+ (f): >+ * Scripts/webkitperl/test262_unittest/test262-runner-tests.pl: Added. >+ > 2018-06-07 Brendan McLoughlin <brendan@bocoup.com> > > Update web-platform-tests github location in webkitpy.w3c.test_importer >diff --git a/Tools/Scripts/webkitperl/test262_unittest/README b/Tools/Scripts/webkitperl/test262_unittest/README >new file mode 100644 >index 0000000000000000000000000000000000000000..f5c6ed4b6ebcf0aa4a34130d94d35d15d43ca9ed >--- /dev/null >+++ b/Tools/Scripts/webkitperl/test262_unittest/README >@@ -0,0 +1,6 @@ >+These unit tests test: >+ webkit/Tools/Scripts/test262-runner >+ webkit/Tools/Scripts/test262-import >+ >+Helper perl modules for these scripts are located in: >+ webkit/Tools/Scripts/test262/ >\ No newline at end of file >diff --git a/Tools/Scripts/webkitperl/test262_unittest/fixtures/expectations-compare.yaml b/Tools/Scripts/webkitperl/test262_unittest/fixtures/expectations-compare.yaml >new file mode 100644 >index 0000000000000000000000000000000000000000..e1b85d49b19fdd52642a3d33888de179bcaf626f >--- /dev/null >+++ b/Tools/Scripts/webkitperl/test262_unittest/fixtures/expectations-compare.yaml >@@ -0,0 +1,4 @@ >+--- >+test/fail.js: >+ default: 'Test262: This test fails.' >+ strict mode: 'Test262: This test fails.' >diff --git a/Tools/Scripts/webkitperl/test262_unittest/fixtures/expectations.yaml b/Tools/Scripts/webkitperl/test262_unittest/fixtures/expectations.yaml >new file mode 100644 >index 0000000000000000000000000000000000000000..b662d4e32b255cbc1d976d86e22131447462053c >--- /dev/null >+++ b/Tools/Scripts/webkitperl/test262_unittest/fixtures/expectations.yaml >@@ -0,0 +1,10 @@ >+--- >+test/expected-to-fail-now-passing.js: >+ default: 'Test262: This test fails.' >+ strict mode: 'Test262: This test fails.' >+test/expected-to-fail-now-failing.js: >+ default: 'Test262: This test fails.' >+ strict mode: 'Test262: This test fails.' >+test/expected-to-fail-now-failing-with-new-error.js: >+ default: 'Test262: This test fails.' >+ strict mode: 'Test262: This test fails.' >diff --git a/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/LICENSE b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/LICENSE >new file mode 100644 >index 0000000000000000000000000000000000000000..f1a691cbb1cd85b329b05b109af60a19f7a24315 >--- /dev/null >+++ b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/LICENSE >@@ -0,0 +1,26 @@ >+Copyright (C) 2018 Bocoup LLC. All rights reserved. >+ >+Redistribution and use in source and binary forms, with or without >+modification, are permitted provided that the following conditions >+are met: >+ >+1. Redistributions of source code must retain the above >+ copyright notice, this list of conditions and the following >+ disclaimer. >+2. Redistributions in binary form must reproduce the above >+ copyright notice, this list of conditions and the following >+ disclaimer in the documentation and/or other materials >+ provided with the distribution. >+ >+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY >+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE >+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, >+OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR >+TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF >+THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >+SUCH DAMAGE. >diff --git a/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-failing-with-new-error.js b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-failing-with-new-error.js >new file mode 100644 >index 0000000000000000000000000000000000000000..9c6cbab4cb0b4602c42b3a21b27c99f486a1def9 >--- /dev/null >+++ b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-failing-with-new-error.js >@@ -0,0 +1,8 @@ >+// Copyright (C) 2018 Valerie Young. All rights reserved. >+// This code is governed by the BSD license found in the LICENSE file. >+/*--- >+esid: sec-function-definitions >+description: Minimal test >+---*/ >+ >+throw "Test262Unexpected: This test fails WITH AN UNEXPECTED ERROR."; >diff --git a/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-failing.js b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-failing.js >new file mode 100644 >index 0000000000000000000000000000000000000000..712d5a112a43207ad248fb03c08cb370c5380811 >--- /dev/null >+++ b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-failing.js >@@ -0,0 +1,8 @@ >+// Copyright (C) 2018 Valerie Young. All rights reserved. >+// This code is governed by the BSD license found in the LICENSE file. >+/*--- >+esid: sec-function-definitions >+description: Minimal test >+---*/ >+ >+throw "Test262: This test fails."; >diff --git a/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-passing.js b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-passing.js >new file mode 100644 >index 0000000000000000000000000000000000000000..fa637be7f706a78aad7139705bcfc2c0c992bb6c >--- /dev/null >+++ b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-fail-now-passing.js >@@ -0,0 +1,9 @@ >+// Copyright (C) 2018 Valerie Young. All rights reserved. >+// This code is governed by the BSD license found in the LICENSE file. >+/*--- >+esid: sec-function-definitions >+description: Minimal test >+---*/ >+ >+function f() {}; >+ >diff --git a/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-pass-now-failing.js b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-pass-now-failing.js >new file mode 100644 >index 0000000000000000000000000000000000000000..712d5a112a43207ad248fb03c08cb370c5380811 >--- /dev/null >+++ b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/expected-to-pass-now-failing.js >@@ -0,0 +1,8 @@ >+// Copyright (C) 2018 Valerie Young. All rights reserved. >+// This code is governed by the BSD license found in the LICENSE file. >+/*--- >+esid: sec-function-definitions >+description: Minimal test >+---*/ >+ >+throw "Test262: This test fails."; >diff --git a/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/fail.js b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/fail.js >new file mode 100644 >index 0000000000000000000000000000000000000000..712d5a112a43207ad248fb03c08cb370c5380811 >--- /dev/null >+++ b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/fail.js >@@ -0,0 +1,8 @@ >+// Copyright (C) 2018 Valerie Young. All rights reserved. >+// This code is governed by the BSD license found in the LICENSE file. >+/*--- >+esid: sec-function-definitions >+description: Minimal test >+---*/ >+ >+throw "Test262: This test fails."; >diff --git a/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/pass.js b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/pass.js >new file mode 100644 >index 0000000000000000000000000000000000000000..fa637be7f706a78aad7139705bcfc2c0c992bb6c >--- /dev/null >+++ b/Tools/Scripts/webkitperl/test262_unittest/fixtures/test/pass.js >@@ -0,0 +1,9 @@ >+// Copyright (C) 2018 Valerie Young. All rights reserved. >+// This code is governed by the BSD license found in the LICENSE file. >+/*--- >+esid: sec-function-definitions >+description: Minimal test >+---*/ >+ >+function f() {}; >+ >diff --git a/Tools/Scripts/webkitperl/test262_unittest/test262-runner-tests.pl b/Tools/Scripts/webkitperl/test262_unittest/test262-runner-tests.pl >new file mode 100755 >index 0000000000000000000000000000000000000000..1d0aa9328b315ba4ce1f61ef952b10543e841e91 >--- /dev/null >+++ b/Tools/Scripts/webkitperl/test262_unittest/test262-runner-tests.pl >@@ -0,0 +1,145 @@ >+#!/usr/bin/env perl >+ >+# Copyright (C) 2018 Bocoup LLC. All rights reserved. >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# >+# 1. Redistributions of source code must retain the above >+# copyright notice, this list of conditions and the following >+# disclaimer. >+# 2. Redistributions in binary form must reproduce the above >+# copyright notice, this list of conditions and the following >+# disclaimer in the documentation and/or other materials >+# provided with the distribution. >+# >+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY >+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE >+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, >+# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR >+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF >+# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >+# SUCH DAMAGE. >+ >+use strict; >+use warnings; >+ >+use Test::More; >+use File::Spec; >+use FindBin; >+use Cwd qw(abs_path); >+use File::Path qw(rmtree); >+use File::Temp qw(tempfile); >+use File::Compare qw(compare); >+ >+# This test should not be run on Windows >+if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'WinCairo') { >+ plan(tests => 1); >+ is(1, 1, 'do nothing for Windows builds.'); >+ exit 0; >+} >+ >+my $Bin = $FindBin::Bin; >+my $runner = abs_path("$Bin/../../test262-runner"); >+my $mockTest262 = abs_path("$Bin/fixtures"); >+ >+my @testCases = ( >+ { >+ "TESTNAME" => "test262 test failed, ignore expectations", >+ "EXITSTATUS" => 1, >+ "TEST262TESTS_ARG" => "--test-only test/fail.js", >+ "EXPECTATION_ARG" => "--ignore-expectations", >+ "EXPECTED_NEW_FAIL_COUNT" => 2, >+ }, >+ { >+ "TESTNAME" => "test262 test passed, ignore expectations", >+ "EXITSTATUS" => 0, >+ "TEST262TESTS_ARG" => "--test-only test/pass.js", >+ "EXPECTATION_ARG" => "--ignore-expectations", >+ "EXPECTED_NEW_FAIL_COUNT" => 0, >+ }, >+ { >+ "TESTNAME" => "test262 tests newly failed", >+ "EXITSTATUS" => 1, >+ "TEST262TESTS_ARG" => "--test-only test/expected-to-pass-now-failing.js", >+ "EXPECTATION_ARG" => "--expectations $Bin/fixtures/expectations.yaml", >+ "EXPECTED_NEW_FAIL_COUNT" => 2, >+ }, >+ { >+ "TESTNAME" => "test262 tests newly passed", >+ "EXITSTATUS" => 0, >+ "TEST262TESTS_ARG" => "--test-only test/expected-to-fail-now-passing.js", >+ "EXPECTATION_ARG" => "--expectations $Bin/fixtures/expectations.yaml", >+ "EXPECTED_NEW_FAIL_COUNT" => 0, >+ }, >+ { >+ "TESTNAME" => "test262 tests fails, expected failure", >+ "EXITSTATUS" => 0, >+ "TEST262TESTS_ARG" => "--test-only test/expected-to-fail-now-failing.js", >+ "EXPECTATION_ARG" => "--expectations $Bin/fixtures/expectations.yaml", >+ "EXPECTED_NEW_FAIL_COUNT" => 0, >+ }, >+ { >+ "TESTNAME" => "test262 tests fails, with unexpected error string", >+ "EXITSTATUS" => 1, >+ "TEST262TESTS_ARG" => "--test-only test/expected-to-fail-now-failing-with-new-error.js", >+ "EXPECTATION_ARG" => "--expectations $Bin/fixtures/expectations.yaml", >+ "EXPECTED_NEW_FAIL_COUNT" => 2, >+ }, >+); >+ >+my $testCasesCount = (scalar(@testCases) * 2) + 1; >+plan(tests => $testCasesCount); >+ >+## Test error codes and expected output messages of tests ## >+ >+foreach my $testcase (@testCases) { >+ >+ my $test = $testcase->{TEST262TESTS_ARG}; >+ my $expectation = $testcase->{EXPECTATION_ARG}; >+ my $test262loc = "--t262 $mockTest262"; >+ >+ my $cmd = qq($runner --release $test262loc $test $expectation); >+ my $output = qx($cmd); >+ >+ # Test the resulting exit code >+ my $exitcode = $? >> 8; >+ my $expectedexitcode = $testcase->{EXITSTATUS}; >+ my $testname = $testcase->{TESTNAME} . " (exit code: $expectedexitcode)"; >+ is($exitcode, $testcase->{EXITSTATUS}, $testname); >+ >+ # Test the number of occurences of string "! NEW FAIL" >+ my @newfailcount = $output =~ /! NEW FAIL/g; >+ my $expectednewfailures = $testcase->{EXPECTED_NEW_FAIL_COUNT}; >+ $testname = $testcase->{TESTNAME} . " (new failures: $expectednewfailures)"; >+ is(scalar(@newfailcount), $expectednewfailures, $testname); >+} >+ >+## Test format of saved expectations file ## >+ >+my $test262loc = "--t262 $mockTest262"; >+my ($expectationsfh, $expectationsfile) = tempfile(); >+my $expect = "--expectations $expectationsfile"; >+my $test = "--test-only test/fail.js"; >+my $cmd = qq($runner --release --save --ignore-expectations $test262loc $test $expect); >+qx($cmd); >+ >+my $expectedexpectationsfile = "$Bin/fixtures/expectations-compare.yaml"; >+my $filesmatch = compare($expectationsfile, $expectedexpectationsfile); >+ok($filesmatch == 0, "expectations yaml file format"); >+ >+close $expectationsfh; >+ >+END { >+ # Clean up test262 results directory after running tests >+ my $resultsDir = $ENV{PWD} . "/test262-results"; >+ if (-e $resultsDir) { >+ rmtree($resultsDir); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185783
:
340736
|
340867
|
340957
|
341002
|
341027
|
341028
|
341105
|
342196
|
342205
|
342543
|
342544