documents builds the documents that get submitted. Empty files are skipped, printing a warning.
(submitPaths []string, exercise workspace.Exercise)
| 216 | // documents builds the documents that get submitted. |
| 217 | // Empty files are skipped, printing a warning. |
| 218 | func (s *submitCmdContext) documents(submitPaths []string, exercise workspace.Exercise) ([]workspace.Document, error) { |
| 219 | docs := make([]workspace.Document, 0, len(submitPaths)) |
| 220 | for _, file := range submitPaths { |
| 221 | // Don't submit empty files |
| 222 | info, err := os.Stat(file) |
| 223 | if err != nil { |
| 224 | return nil, err |
| 225 | } |
| 226 | if info.Size() == 0 { |
| 227 | |
| 228 | msg := ` |
| 229 | |
| 230 | WARNING: Skipping empty file |
| 231 | %s |
| 232 | |
| 233 | ` |
| 234 | fmt.Fprintf(Err, msg, file) |
| 235 | continue |
| 236 | } |
| 237 | doc, err := workspace.NewDocument(exercise.Filepath(), file) |
| 238 | if err != nil { |
| 239 | return nil, err |
| 240 | } |
| 241 | docs = append(docs, doc) |
| 242 | } |
| 243 | return docs, nil |
| 244 | } |
| 245 | |
| 246 | func (s *submitCmdContext) metadata(exercise workspace.Exercise) (*workspace.ExerciseMetadata, error) { |
| 247 | metadata, err := workspace.NewExerciseMetadata(exercise.Filepath()) |
no test coverage detected