Merge: tests: measure time with elapsed time instead of user-mode time
authorJean Privat <jean@pryen.org>
Thu, 15 Jun 2017 19:43:36 +0000 (15:43 -0400)
committerJean Privat <jean@pryen.org>
Thu, 15 Jun 2017 19:43:36 +0000 (15:43 -0400)
This will help to identify where the real elapsed time is going.

Pull-Request: #2491
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

bin/nit-makepackage
lib/core/file.nit
share/man/nit-makepackage.md [new file with mode: 0644]
src/modelize/modelize_property.nit

index 3ee3090..a03af86 100755 (executable)
 #
 # Default values are guessed from git and the file system.
 
+while true; do
+       case "$1" in
+               "")
+                       break
+                       ;;
+               -h|--help)
+                       echo "nit-makepackage: creates a package.ini in the current directory"
+                       echo "There is no option (yet)"
+                       exit
+                       ;;
+               *)
+                       echo >&2 "nit-makepackage does not accept options yet"
+                       exit 1
+                       ;;
+       esac
+done
+
+
 name=`basename $PWD`
 maintainer=`git shortlog -esn . | head -n 1 | sed 's/\s*[0-9]*\s*//'`
 dir=`git rev-parse --show-prefix`
index 09b20d9..643fe08 100644 (file)
@@ -898,9 +898,7 @@ redef class Text
 
        # return true if a file with this names exists
        fun file_exists: Bool do return to_cstring.file_exists
-end
 
-redef class String
        # The status of a file. see POSIX stat(2).
        fun file_stat: nullable FileStat
        do
@@ -943,14 +941,14 @@ redef class String
                if extension == null then
                        extension = file_extension
                        if extension == null then
-                               return self
+                               return self.to_s
                        else extension = ".{extension}"
                end
 
                if has_suffix(extension) then
-                       return substring(0, length - extension.length)
+                       return substring(0, length - extension.length).to_s
                end
-               return self
+               return self.to_s
        end
 
        # Extract the basename of a path and strip the `extension`
@@ -989,7 +987,7 @@ redef class String
 
                if extension != null then
                        return n.strip_extension(extension)
-               else return n
+               else return n.to_s
        end
 
        # Extract the dirname of a path
@@ -1018,7 +1016,7 @@ redef class String
                while l > 0 and s.chars[l] == '/' do l -= 1 # remove all trailing `/`
                var pos = s.chars.last_index_of_from('/', l)
                if pos > 0 then
-                       return s.substring(0, pos)
+                       return s.substring(0, pos).to_s
                else if pos == 0 then
                        return "/"
                else
@@ -1115,11 +1113,11 @@ redef class String
        # Note: You may want to use `simplify_path` on the result.
        #
        # Note: This method works only with POSIX paths.
-       fun join_path(path: String): String
+       fun join_path(path: Text): String
        do
-               if path.is_empty then return self
-               if self.is_empty then return path
-               if path.chars[0] == '/' then return path
+               if path.is_empty then return self.to_s
+               if self.is_empty then return path.to_s
+               if path.chars[0] == '/' then return path.to_s
                if self.last == '/' then return "{self}{path}"
                return "{self}/{path}"
        end
@@ -1134,7 +1132,7 @@ redef class String
        #     assert "".to_program_name == "./" # At least, your shell will detect the error.
        fun to_program_name: String do
                if self.has_prefix("/") then
-                       return self
+                       return self.to_s
                else
                        return "./{self}"
                end
@@ -1154,7 +1152,7 @@ redef class String
        #     var b = "/bar"
        #     var c = "baz/foobar"
        #     assert a/b/c == "/bar/baz/foobar"
-       fun /(path: String): String do return join_path(path)
+       fun /(path: Text): String do return join_path(path)
 
        # Returns the relative path needed to go from `self` to `dest`.
        #
@@ -1318,7 +1316,7 @@ redef class String
        do
                var last_slash = chars.last_index_of('.')
                if last_slash > 0 then
-                       return substring( last_slash+1, length )
+                       return substring( last_slash+1, length ).to_s
                else
                        return null
                end
diff --git a/share/man/nit-makepackage.md b/share/man/nit-makepackage.md
new file mode 100644 (file)
index 0000000..7569395
--- /dev/null
@@ -0,0 +1,18 @@
+# NAME
+
+nit-makepackage - helper script to setup package metadata
+
+# SYNOPSIS
+
+nit-makepackage
+
+# DESCRIPTION
+
+`nit-makepackage` creates (or overrides) a package.ini template file in the current directory.
+The result must be examined and adapted.
+
+Default values are guessed from git and the file system.
+
+# SEE ALSO
+
+The Nit language documentation and the source code of its tools and libraries may be downloaded from <http://nitlanguage.org>
index a7f75ff..e805d4e 100644 (file)
@@ -769,22 +769,21 @@ redef class AMethPropdef
        do
                var n_kwinit = n_kwinit
                var n_kwnew = n_kwnew
-               var is_init = n_kwinit != null or n_kwnew != null
+               var is_new = n_kwnew != null
+               var is_init = n_kwinit != null or is_new
                var name: String
                var amethodid = self.n_methid
                var name_node: ANode
                if amethodid == null then
-                       if not is_init then
-                               name = "main"
-                               name_node = self
-                       else if n_kwinit != null then
+                       if n_kwinit != null then
                                name = "init"
                                name_node = n_kwinit
                        else if n_kwnew != null then
                                name = "new"
                                name_node = n_kwnew
                        else
-                               abort
+                               name = "main"
+                               name_node = self
                        end
                else if amethodid isa AIdMethid then
                        name = amethodid.n_id.text
@@ -828,8 +827,8 @@ redef class AMethPropdef
                                mprop.is_root_init = true
                        end
                        mprop.is_init = is_init
-                       mprop.is_new = n_kwnew != null
-                       if mprop.is_new then mclassdef.mclass.has_new_factory = true
+                       mprop.is_new = is_new
+                       if is_new then mclassdef.mclass.has_new_factory = true
                        if name == "sys" then mprop.is_toplevel = true # special case for sys allowed in `new` factories
                        if not self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, false, mprop) then
                                mprop.is_broken = true