File: spec_helper.lua

package info (click to toggle)
lua-cliargs 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 388 kB
  • sloc: sh: 118; javascript: 14; makefile: 5
file content (44 lines) | stat: -rw-r--r-- 760 bytes parent folder | download
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
-- luacheck: ignore 111

local exports = {}
local split = require 'cliargs.utils.split'
local busted = require 'busted'

function odescribe(desc, runner)
  busted.describe("#only " .. desc, runner)
end

function xdescribe()
end

function oit(desc, runner)
  busted.it("#only " .. desc, runner)
end

function xit(desc, _)
  busted.it(desc)
end

exports.parse = function(cli, str)
  return cli:parse(split(str, '%s+'))
end

exports.trim = function(s)
  local lines = split(s, "\n")
  local _

  if #lines == 0 then
    return s
  end

  local padding = lines[1]:find('%S') or 0
  local buffer = ''

  for _, line in pairs(lines) do
    buffer = buffer .. line:sub(padding, -1):gsub("%s+$", '') .. "\n"
  end

  return buffer:gsub("%s+$", '')
end

return exports