Unit Testing File Modifications

后端 未结 6 1042
轮回少年
轮回少年 2020-12-29 05:47

A common task in programs I\'ve been working on lately is modifying a text file in some way. (Hey, I\'m on Linux. Everything\'s a file. And I do large-scale system admin.)

6条回答
  •  -上瘾入骨i
    2020-12-29 06:22

    I think you are on the right track. Depending on what you need to do chroot may help you set up an environment for your scrpits that 'looks' real, but isn't.

    If that doesn't work then you could write your scripts to take a 'root' path as an argument.

    In a production run the root path is just /. For testing you create a shadow environment under /tmp/test and then run your scripts with a root path of /tmp/test.

提交回复
热议问题