xslate / p5-Text-Xslate

Scalable template engine for Perl5
https://metacpan.org/release/Text-Xslate
Other
121 stars 47 forks source link

Guarantee that test cleans up after itself. #189

Closed jkeenan closed 6 years ago

jkeenan commented 6 years ago

The constructors in 040_issue95.t were not specifying a value for 'cache_dir'. As a consequence, directories and files created during testing were being placed underneath user's home directory and not being removed automatically.

Have those directories and files be created in temporary directories with automatic cleanup.

jkeenan commented 6 years ago

This problem was exposed when I used 'cpanm' to install Text::Xslate against several monthly development releases of Perl. Here is what happened once I cleared out ~/.xslate_cache.

$ date && ls -l ~/.xslate_cache
Mon Dec 18 18:01:19 EST 2017
ls: cannot access /home/jkeenan/.xslate_cache: No such file or directory

$ cpanm Text::Xslate
--> Working on Text::Xslate
Fetching http://www.cpan.org/authors/id/S/SK/SKAJI/Text-Xslate-v3.5.3.tar.gz ... OK
# all dependencies installed successfully
Building and testing Text-Xslate-v3.5.3 ... OK
Successfully installed Text-Xslate-v3.5.3
8 distributions installed

$ date && ls -l ~/.xslate_cache
Mon Dec 18 18:04:46 EST 2017
total 12
drwxr-xr-x 2 jkeenan jkeenan 4096 Dec 18 18:04 %2Fhome%2Fjkeenan%2F.cpanm%2Fwork%2F1513638111.17135%2FText-Xslate-v3.5.3%2Fpath_a
drwxr-xr-x 2 jkeenan jkeenan 4096 Dec 18 18:04 %2Fhome%2Fjkeenan%2F.cpanm%2Fwork%2F1513638111.17135%2FText-Xslate-v3.5.3%2Fpath_b
drwxr-xr-x 2 jkeenan jkeenan 4096 Dec 18 18:04 HASH

$ find ~/.xslate_cache -type d | xargs ls -ltr
/home/jkeenan/.xslate_cache:
total 12
drwxr-xr-x 2 jkeenan jkeenan 4096 Dec 18 18:04 HASH
drwxr-xr-x 2 jkeenan jkeenan 4096 Dec 18 18:04 %2Fhome%2Fjkeenan%2F.cpanm%2Fwork%2F1513638111.17135%2FText-Xslate-v3.5.3%2Fpath_a
drwxr-xr-x 2 jkeenan jkeenan 4096 Dec 18 18:04 %2Fhome%2Fjkeenan%2F.cpanm%2Fwork%2F1513638111.17135%2FText-Xslate-v3.5.3%2Fpath_b

/home/jkeenan/.xslate_cache/HASH:
total 36
-rw-r--r-- 1 jkeenan jkeenan 594 Dec 18 18:03 Xc
-rw-r--r-- 1 jkeenan jkeenan 594 Dec 18 18:03 Zc
-rw-r--r-- 1 jkeenan jkeenan 594 Dec 18 18:03 Yc
-rw-r--r-- 1 jkeenan jkeenan 950 Dec 18 18:03 recurse.ttc
-rw-r--r-- 1 jkeenan jkeenan 447 Dec 18 18:03 text.txc
-rw-r--r-- 1 jkeenan jkeenan 683 Dec 18 18:03 body.txc
-rw-r--r-- 1 jkeenan jkeenan 760 Dec 18 18:03 page.txc
-rw-r--r-- 1 jkeenan jkeenan 808 Dec 18 18:04 contentc
-rw-r--r-- 1 jkeenan jkeenan 552 Dec 18 18:04 basec

/home/jkeenan/.xslate_cache/%2Fhome%2Fjkeenan%2F.cpanm%2Fwork%2F1513638111.17135%2FText-Xslate-v3.5.3%2Fpath_a:
total 8
-rw-r--r-- 1 jkeenan jkeenan 1037 Dec 18 18:04 sub.txc
-rw-r--r-- 1 jkeenan jkeenan  842 Dec 18 18:04 base.txc

/home/jkeenan/.xslate_cache/%2Fhome%2Fjkeenan%2F.cpanm%2Fwork%2F1513638111.17135%2FText-Xslate-v3.5.3%2Fpath_b:
total 4
-rw-r--r-- 1 jkeenan jkeenan 1145 Dec 18 18:04 sub.txc

The pull request appears to resolve the problem.

Thank you very much. Jim Keenan

skaji commented 6 years ago

@jkeenan thanks!

skaji commented 6 years ago

Released https://metacpan.org/release/SKAJI/Text-Xslate-v3.5.4

jkeenan commented 6 years ago

Thanks for your prompt attention to this matter.

However, it appears that data is still being written to a hidden directory underneath the user's home directory -- probably from some other file in the test suite.

I just pulled from upstream (your repo) into master and ran the test suite. Here is the impact on my home directory.

# Before starting test suite
[~] 632 $ rm -rf .xslate_cache/
# After running test suite
[~] 633 $ ls -l .xslate_cache/
total 4
drwxrwxr-x 2 jkeenan jkeenan 4096 Dec 19 09:27 HASH
[~] 634 $ ls -l .xslate_cache/HASH
total 36
-rw-rw-r-- 1 jkeenan jkeenan 552 Dec 19 09:27 basec
-rw-rw-r-- 1 jkeenan jkeenan 683 Dec 19 09:26 body.txc
-rw-rw-r-- 1 jkeenan jkeenan 808 Dec 19 09:27 contentc
-rw-rw-r-- 1 jkeenan jkeenan 760 Dec 19 09:26 page.txc
-rw-rw-r-- 1 jkeenan jkeenan 950 Dec 19 09:26 recurse.ttc
-rw-rw-r-- 1 jkeenan jkeenan 447 Dec 19 09:26 text.txc
-rw-rw-r-- 1 jkeenan jkeenan 594 Dec 19 09:26 Xc
-rw-rw-r-- 1 jkeenan jkeenan 594 Dec 19 09:26 Yc
-rw-rw-r-- 1 jkeenan jkeenan 594 Dec 19 09:26 Zc

So there is more cleanup to be done.

Thank you very much. Jim Keenan