Merge remote-tracking branch 'canonical/next'
[sinan.git] / smoketests / tests / test_dir_test.py
blob7dc5dc988616aaca00dd30fca002242eb44adc92
1 import unittest
2 import sin_testing as st
3 import pexpect
4 import os
6 class TestFail(st.SmokeTest):
9 @st.sinan("build")
10 def build(self, child, app_desc):
11 if not os.path.isfile(os.path.join(os.getcwd(),
12 "test", "test_module.erl")):
13 raise "Nome module file"
15 child.expect(pexpect.EOF)
17 if not os.path.isfile(os.path.join(os.getcwd(),
18 "_build", app_desc.project_name,
19 "lib", app_desc.project_name + "-" +
20 app_desc.project_version, "ebin",
21 "test_module.beam")):
22 raise "File Not Built"
25 def output_testdir(self):
26 path = os.path.join(os.getcwd(), "test")
27 try:
28 os.makedirs(path)
29 except OSError as exc:
30 if exc.errno == errno.EEXIST:
31 pass
32 else: raise
34 Module = """
35 -module(test_module).
37 -export([test/0]).
39 test() ->
40 ok."""
42 module_file = os.path.join(path, "test_module.erl")
43 new_file = open(module_file, "w")
44 new_file.write(Module)
45 new_file.close()
47 @st.sinan("gen foo")
48 def run_custom_gen(self, child, appdesc):
49 child.expect("your name> ")
50 child.sendline(appdesc.user_name)
51 child.expect("your email> ")
52 child.sendline(appdesc.email)
53 child.expect('copyright holder \("%s"\)> ' % appdesc.user_name)
54 child.sendline()
55 child.expect('project version> ')
56 child.sendline(appdesc.project_version)
57 child.expect('Please specify the ERTS version \(".*"\)> ')
58 child.sendline()
59 child.expect('Is this a single application project \("n"\)> ')
60 child.sendline("y")
61 child.expect('Would you like a build config\? \("y"\)> ')
62 child.sendline()
63 child.expect("Project was created, you should be good to go!")
64 child.expect(pexpect.EOF)
67 def test_gen_name(self):
68 appdesc = st.AppDesc(user_name = "Smoke Test Gen",
69 email = "noreply@erlware.org",
70 copyright_holder = "Smoke Test Copy, LLC.",
71 # This needs to match the gen name since
72 # we are overriding it
73 project_name = "foo",
74 project_version = "0.134.0.0")
76 self.run_custom_gen(appdesc)
78 currentdir = os.getcwd()
79 projdir = os.path.join(currentdir, appdesc.project_name)
80 os.chdir(projdir)
82 self.output_testdir()
83 self.build(appdesc)
85 os.chdir(currentdir)
87 if __name__ == '__main__':
88 unittest.main()