File: test-modulefiles.rst

package info (click to toggle)
modules 5.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,036 kB
  • sloc: exp: 79,659; sh: 6,142; tcl: 5,900; makefile: 1,493; ansic: 474; python: 265; csh: 202; perl: 47; ruby: 44; lisp: 13
file content (61 lines) | stat: -rw-r--r-- 2,523 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
.. _test-modulefiles:

Testing Modulefiles
===================

The following is an example for a ``ModulesTest`` subroutine of a Modulefile and its output.
It checks whether the :file:`TESTDIR` is a directory, checks that it can enter it,
and whether a file :file:`TESTFILE` can successfully be created there.

This code gets executed when you use the :subcmd:`module test modulefile<test>` command.

Code
----

.. literalinclude:: ../../example/test-modulefiles/modulefiles/test_dir_and_file
   :language: tcl
   :caption: test_dir_and_file


Usage example
-------------

Enable the modulepath where the example modulefiles are located::

   $ module use example/test-modulefiles/modulefiles

Run the test both with the test directory not existing and existing::

    $ module test test_dir_and_file
    -------------------------------------------------------------------
    Module Specific Test for .../modulefiles/test_dir_and_file:
    
    Running ModulesTest for directory existence...
    ERROR: Is not a directory: /tmp/testuser/testdir
    Running ModulesTest for directory existence...done
    Running ModulesTest for directory permissions...
    ERROR: Was not able to enter directory /tmp/testuser/testdir: couldn't change working directory to "/tmp/testuser/testdir": no such file or directory
    Running ModulesTest for directory permissions...done
    Running ModulesTest for file creation...
    ERROR: Was not able to create file /tmp/testuser/testdir/testfile: couldn't open "/tmp/testuser/testdir/testfile": no such file or directory
    Running ModulesTest for file creation...done
    Test result: FAIL
    -------------------------------------------------------------------
    $ mkdir /tmp/$USER/testdir
    $ module test test_dir_and_file
    -------------------------------------------------------------------
    Module Specific Test for .../modulefiles/test_dir_and_file:
    
    Running ModulesTest for directory existence...
    Is a directory: /tmp/testuser/testdir
    Running ModulesTest for directory existence...done
    Running ModulesTest for directory permissions...
    Was able to enter directory /tmp/testuser/testdir
    Running ModulesTest for directory permissions...done
    Running ModulesTest for file creation...
    Was able to create file /tmp/testuser/testdir/testfile
    Running ModulesTest for file creation...done
    Test result: PASS
    -------------------------------------------------------------------

.. vim:set tabstop=2 shiftwidth=2 expandtab autoindent: