Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

(#17994) Generate a new file and dir each time

Previously, the test would reuse the same file and dir each time,
assuming that the chmod would set the initial mode correctly at the
start of each test using a numeric mode. However, on debian (at

    You can set or clear the bits with symbolic modes like
    u+s and g-s, and you can set (but not clear) the bits with
    a numeric mode.

Since we can't reliably set the initial mode using chmod, this commit
modifies the test to delete the file/dir at the start of every
test. This ensures that state from one test doesn't leak across.

Also, modifies the assert_match to account that the file path may
contain special regexp characters that need to be escaped.
  • Loading branch information...
commit 076a5d53e1739cbfb530fe25211b2f71be4ed892 1 parent a622f0e
Josh Cooper joshcooper authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 acceptance/tests/resource/file/symbolic_modes.rb
10 acceptance/tests/resource/file/symbolic_modes.rb
@@ -7,7 +7,7 @@ module FileModeAssertions
def assert_create(agent, manifest, path, expected_mode)
testcase.apply_manifest_on(agent, manifest) do
- assert_match(/File\[#{path}\]\/ensure: created/, testcase.stdout, "Failed to create #{path}")
+ assert_match(/File\[#{Regexp.escape(path)}\]\/ensure: created/, testcase.stdout, "Failed to create #{path}")
assert_mode(agent, path, expected_mode)
@@ -45,8 +45,10 @@ def initialize(testcase, agent, basedir, symbolic_mode)
@basedir = basedir
@symbolic_mode = symbolic_mode
- @file = "#{basedir}/symbolic-mode-file"
- @dir = "#{basedir}/symbolic-mode-dir"
+ @file = "#{basedir}/file"
+ @dir = "#{basedir}/dir"
+ testcase.on(agent, "rm -rf #{@file} #{@dir}")
def get_manifest(path, type, symbolic_mode)
@@ -57,8 +59,6 @@ def get_manifest(path, type, symbolic_mode)
class CreatesModeTest < ActionModeTest
def initialize(testcase, agent, basedir, symbolic_mode)
super(testcase, agent, basedir, symbolic_mode)
- testcase.on(agent, "rm -rf #{@file} #{@dir}")
def assert_file_mode(expected_mode)
Please sign in to comment.
Something went wrong with that request. Please try again.