| 1 |
From 407c6a5db6c1f1cfb40bd6113f07f067d07885a4 Mon Sep 17 00:00:00 2001 |
| 2 |
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <[email protected]> |
| 3 |
Origin: https://github.com/mustache/mustache/pull/258 |
| 4 |
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=954503 |
| 5 |
Date: Mon, 27 Apr 2020 11:16:17 +0200 |
| 6 |
Subject: [PATCH] Fix test race condition. |
| 7 |
|
| 8 |
The test suite randomly fails with errors such as: |
| 9 |
|
| 10 |
~~~ |
| 11 |
1) Failure: |
| 12 |
AutoloadingTest#test_autoload_lowercase [/builddir/build/BUILD/mustache-1.1.1/usr/share/gems/gems/mustache-1.1.1/test/autoloading_test.rb:17]: |
| 13 |
Expected: Comments |
| 14 |
Actual: nil |
| 15 |
~~~ |
| 16 |
|
| 17 |
This happens when `test_namespaced*` test cases are executed earlier |
| 18 |
than the remaining test cases, because they are defining |
| 19 |
`view_namespace` but not cleaning up afterwards. |
| 20 |
--- |
| 21 |
test/autoloading_test.rb | 4 ++++ |
| 22 |
1 file changed, 4 insertions(+) |
| 23 |
|
| 24 |
diff --git a/test/autoloading_test.rb b/test/autoloading_test.rb |
| 25 |
index 0a7ad762..77eb3557 100644 |
| 26 |
--- a/test/autoloading_test.rb |
| 27 |
+++ b/test/autoloading_test.rb |
| 28 |
@@ -7,6 +7,10 @@ def setup |
| 29 |
Mustache.view_path = File.dirname(__FILE__) + '/fixtures' |
| 30 |
end |
| 31 |
|
| 32 |
+ def teardown |
| 33 |
+ Mustache.remove_instance_variable(:@view_namespace) if Mustache.instance_variable_defined?(:@view_namespace) |
| 34 |
+ end |
| 35 |
+ |
| 36 |
def test_autoload |
| 37 |
klass = Mustache.view_class(:Comments) |
| 38 |
assert_equal Comments, klass |