From c686cc60994e41a359c2ff9e6dcf5110ccd15082 Mon Sep 17 00:00:00 2001
From: Rick Waldron <waldron.rick@gmail.com>
Date: Thu, 7 Jun 2018 22:38:36 -0400
Subject: [PATCH] Lint: disallow calls to verifyConfigurable and verifyProperty
 in same file

---
 tools/lint/lib/checks/harness.py                   | 14 ++++++++++++++
 tools/lint/lint.py                                 |  2 ++
 .../harness_verifyconfigurableproperty_invalid.js  | 12 ++++++++++++
 .../harness_verifyconfigurableproperty_valid.js    | 10 ++++++++++
 4 files changed, 38 insertions(+)
 create mode 100644 tools/lint/lib/checks/harness.py
 create mode 100644 tools/lint/test/fixtures/harness_verifyconfigurableproperty_invalid.js
 create mode 100644 tools/lint/test/fixtures/harness_verifyconfigurableproperty_valid.js

diff --git a/tools/lint/lib/checks/harness.py b/tools/lint/lib/checks/harness.py
new file mode 100644
index 0000000000..7876fadafd
--- /dev/null
+++ b/tools/lint/lib/checks/harness.py
@@ -0,0 +1,14 @@
+import yaml
+
+from ..check import Check
+
+class CheckHarness(Check):
+    '''Ensure tests don't misuse harness APIs.'''
+    ID = 'HARNESS'
+
+    def run(self, name, meta, source):
+        print(source)
+        if 'verifyConfigurable(' in source and 'verifyProperty(' in source:
+            return 'verifyConfigurable & verifyProperty may not be used in the same file'
+        else:
+            return
diff --git a/tools/lint/lint.py b/tools/lint/lint.py
index 1161a8526a..2c40c4a4c6 100755
--- a/tools/lint/lint.py
+++ b/tools/lint/lint.py
@@ -30,6 +30,7 @@ from lib.checks.esid import CheckEsid
 from lib.checks.features import CheckFeatures
 from lib.checks.frontmatter import CheckFrontmatter
 from lib.checks.harnessfeatures import CheckHarnessFeatures
+from lib.checks.harness import CheckHarness
 from lib.checks.license import CheckLicense
 from lib.checks.negative import CheckNegative
 from lib.checks.filename import CheckFileName
@@ -51,6 +52,7 @@ checks = [
     CheckFrontmatter(),
     CheckFeatures('features.txt'),
     CheckHarnessFeatures(),
+    CheckHarness(),
     CheckLicense(),
     CheckNegative()
 ]
diff --git a/tools/lint/test/fixtures/harness_verifyconfigurableproperty_invalid.js b/tools/lint/test/fixtures/harness_verifyconfigurableproperty_invalid.js
new file mode 100644
index 0000000000..925c5a6609
--- /dev/null
+++ b/tools/lint/test/fixtures/harness_verifyconfigurableproperty_invalid.js
@@ -0,0 +1,12 @@
+HARNESS - verifyConfigurable & verifyProperty may not be used in the same file
+^ expected errors | v input
+// Copyright (C) 2017 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-whatever
+description: Minimal test
+includes: [verifyProperty.js]
+---*/
+
+verifyConfigurable(Object, '');
+verifyProperty(Object, {});
diff --git a/tools/lint/test/fixtures/harness_verifyconfigurableproperty_valid.js b/tools/lint/test/fixtures/harness_verifyconfigurableproperty_valid.js
new file mode 100644
index 0000000000..f01afd16e9
--- /dev/null
+++ b/tools/lint/test/fixtures/harness_verifyconfigurableproperty_valid.js
@@ -0,0 +1,10 @@
+^ expected errors | v input
+// Copyright (C) 2017 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-whatever
+description: Minimal test
+includes: [verifyProperty.js]
+---*/
+
+verifyConfigurable(Object, '');
-- 
GitLab